/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright of BelajarForexPro.com / LearnForexPro.com - Supported by FCMarket.com"
#property link      "http://www.belajarforexpro.com/expertadvisor.php"
#property show_inputs

#include <stdlib.mqh>

string gs_76 = "SUPER HEDGING v1.73 by BelajarForexPro.com & LearnForexPro.com";
extern string Note = "*** SUPER HEDGING v1.73 ***";
extern string Note1 = "This Expert Advisor is a copyright of";
extern string Note2 = "http://www.learnforexpro.com";
extern string Note3 = "http://www.belajarforexpro.com";
extern string Note4 = "---------------------------------------------------------------------";
extern string Note22 = "----- AVAILABLE MODE -----";
extern string Note23 = "Hedging : h, h2, hn, hn2, ht, ht2";
extern string Note25 = "Input mode in \"Mode\" below, then OK";
extern string Mode = "normal";
extern string Note5 = "----- CLOSE ALL POSITION -----";
extern bool CloseAll = FALSE;
extern string Note6 = "----- BASIC PARAMETER -----";
extern int EALoop = 1;
extern double LotSize = 0.1;
extern bool TimeLimit = FALSE;
extern bool CloseOneCloseAll = TRUE;
bool gi_196 = FALSE;
bool gi_200 = TRUE;
double gd_204 = 1.0;
extern int CloseWhileHedgingProfit = 10;
extern string Note21 = "----- SAFER -----";
extern bool Start_Safer = FALSE;
extern int Safer = 3;
extern double Safer_Money_CutLoss = 0.0;
extern int Safer_StartLevel = 6;
extern int Safer_EndLevel = 0;
extern string Note7 = "----- INCREMENTAL RANGE -----";
extern int increase = 18;
extern int IncreaseStartLevel = 2;
extern int IncreaseEndLevel = 6;
extern string Note8 = "----- HEDGING STRATEGY -----";
extern bool Hedging = TRUE;
extern int HedgeGap = 28;
extern double Multiplier = 2.0;
extern int TakeProfit = 150;
extern int StopLoss = 0;
extern bool GapAdjustment = FALSE;
string g_comment_304 = "Super Hedging EA";
string gs_unused_312 = "----- AVERAGING STRATEGY -----";
bool gi_320 = FALSE;
int gi_324 = 30;
double gd_328 = 1.5;
int gi_336 = 50;
int gi_340 = 100;
double gd_344 = 0.0;
bool gi_352 = FALSE;
int gi_356 = 130;
int gi_360 = 5;
int gi_364 = 0;
bool gi_368 = FALSE;
double gd_unused_372 = 6.0;
double gd_unused_380 = 20.0;
string gs_unused_388 = "buy";
string gs_eurusd_396 = "EURUSD";
string gs_usdchf_404 = "USDCHF";
bool gi_412 = FALSE;
bool gi_416 = FALSE;
bool gi_unused_420 = TRUE;
double gd_424 = 0.0;
int gi_432 = 10;
int gi_436 = 20;
int gi_440 = 0;
int gi_444 = 8;
int gi_448 = 3;
int gi_452 = 15;
int gi_456 = 10;
extern string Note12 = "----- INITIAL ORDER -----";
extern string InitialOrder = "auto";
extern int ShortEMA = 5;
extern int LongEMA = 14;
string gs_unused_484 = "----- START WITH STRADDLE -----";
bool gi_492 = FALSE;
int gi_496 = 8;
double gd_unused_500 = 0.0;
double gd_unused_508 = 0.0;
int gi_516 = 20;
int gi_520 = 0;
extern string Note14 = "----- TRAILING STOP -----";
extern int TrailingStop = 15;
extern int TrailingStopStartLevel = 1;
extern int TrailingStopEndLevel = 4;
extern int Rebound = 3;
extern string Note15 = "----- TRAILING STOP 2-----";
extern int TrailingStop_2 = 6;
extern int TrailingStop_2_StartLevel = 4;
extern int TrailingStop_2_EndLevel = 5;
extern int Rebound_2 = 1;
extern string Note16 = "----- TRAILING STOP 3-----";
extern int TrailingStop_3 = 4;
extern int TrailingStop_3_StartLevel = 5;
extern int TrailingStop_3_EndLevel = 0;
extern int Rebound_3 = 1;
string gs_unused_596 = "----- TRAILING STOP 4-----";
int gi_604 = 0;
int gi_608 = 5;
int gi_612 = 0;
int gi_616 = 2;
extern string Note18 = "----- MONEY MANAGEMENT -----";
extern double MaxRiskPercentage = 100.0;
extern double MaxProfit = 0.0;
extern double MaxLoss = 0.0;
extern int MaxLevelAllowed = 0;
extern int LevelStopOpen = 0;
string gs_unused_660 = "----- DOUBLER -----";
bool gi_668 = FALSE;
bool gi_672 = FALSE;
double gd_676 = 0.1;
int gi_684 = 10;
int gi_688 = 10;
int gi_692 = 10;
double gd_696 = 0.0;
double gd_704 = 0.1;
int gi_712 = 1;
int gi_716 = 0;
int gi_720 = 1;
extern string Note20 = "----- TIME -----";
extern string StartEATime = "2008.8.8 17:26";
extern string EndEATime = "0";
extern string StopLoopTime = "0";
bool gi_756 = TRUE;
bool gi_760 = FALSE;
bool gi_764 = TRUE;
bool gi_768 = TRUE;
bool gi_unused_772 = TRUE;
bool gi_776 = FALSE;
bool gi_780 = FALSE;
bool gi_unused_784 = TRUE;
bool gi_unused_788 = FALSE;
bool gi_unused_792 = FALSE;
bool gi_796 = FALSE;
bool gi_unused_800 = FALSE;
int g_ticket_804;
int gi_808 = 0;
string gs_eurusd_812 = "EURUSD";
string gs_gbpusd_820 = "GBPUSD";
string gs_eurgbp_828 = "EURGBP";
int g_count_836;
int g_count_840;
int g_count_844;
int g_count_848;
int gi_852 = 0;
int gi_856 = 0;
int gi_860;
int g_error_864;
int g_ord_total_868;
int g_pos_872;
int gi_876 = 1;
int gi_880 = 0;
int gi_884 = 0;
double gd_888;
double gd_896;
double g_ord_lots_904;
double g_ord_lots_912;
double gd_920 = 0.0;
double gd_928 = 0.0;
double g_bid_936;
double g_ask_944;
double g_bid_952 = 0.0;
double g_ask_960 = 0.0;
double gd_968 = 0.0;
double gd_976 = 0.0;
double gd_984 = 0.0;
double gd_992 = 0.0;
double g_ord_open_price_1000 = 0.0;
double g_ord_open_price_1008 = 0.0;
double gd_unused_1016 = 0.0;
double gd_unused_1024 = 0.0;
double gd_1032 = 0.0;
double gd_1040 = 0.0;
double gd_unused_1048 = 0.0;
double gd_unused_1056 = 0.0;
double gd_1064 = 0.0;
double g_bid_1072 = 0.0;
double g_ask_1080 = 0.0;
double g_bid_1088;
double gd_1096;
double gd_1104;
double g_bid_1112;
double gd_1120;
double g_ask_1128;
double gd_1136;
double gd_1144;
double g_ask_1152;
double gd_1160;
double g_bid_1168;
double gd_1176;
double gd_1184;
double g_bid_1192;
double gd_1200;
double g_ask_1208;
double gd_1216;
double gd_1224;
double g_ask_1232;
double gd_1240;
double gd_1248;
double gd_1256;
double gd_unused_1264;
double gd_unused_1272;
double gd_1280;
double gd_1288;
double gd_1296;
double gd_unused_1304;
double gd_unused_1312;
double gd_1320;
double g_bid_1328;
double gd_1336;
double gd_1344;
double gd_unused_1352;
double g_ask_1360;
double gd_1368;
double gd_1376;
double gd_unused_1384;
double gd_1392;
double gd_1400;
string g_dbl2str_1408;
double gd_1416;
double gd_1424;
double gd_1432;
double gd_1440;
double gd_1448;
double gd_1456;
double g_ord_open_price_1464;
double g_ord_open_price_1472;
double gd_1480;
double gd_1488;
int gi_1496;
int gi_1500;
bool gi_1508;
bool gi_1512;
bool gi_1516;
bool gi_1520;
bool gi_1524;
bool gi_1528;
bool gi_1532;
bool gi_1536;
bool gi_1540;
bool gi_1544;
int gi_1548;
int gi_unused_1552;
int gi_unused_1556;
int gi_unused_1560;
int gi_unused_1564;
bool gi_1568;
bool gi_1572;
bool gi_1576;
double g_ord_lots_1580;
double g_ord_lots_1588;
double gd_1596;
double gd_1604;
double gd_1612;
double gd_1620;
double gd_1628;
double gd_1636;
double gd_1644;
double gd_1652;
double gd_1660;
double gd_1668;
double gd_1676;
double gd_1684;
double gd_1692;
double gd_1700;
double gd_1708;
double g_price_1716;
double g_price_1724;
double gd_1732;
double g_price_1740;
double g_price_1748;
double g_high_1756;
double g_low_1764;
double g_ord_open_price_1772;
double g_ord_open_price_1780;
double gd_1788;
double gd_1796;
int gi_1804 = 5;
int gi_1808 = 14;
int gi_1812;
int gi_1816;
int g_datetime_1820;
int gi_1824;
bool gi_1828;
int gi_unused_1832;
int gi_unused_1836;
bool gi_1840;
bool gi_1844;
int g_file_1848;
int g_file_1852;
int gi_1856;
bool gi_1860;
bool gi_1864;
bool gi_1868;
bool gi_1872;
bool gi_1876;
double gd_1880;
double gd_1888;
int gi_1896;
string gs_unused_1900 = "Color Settings";
string gs_1908 = "";
int g_magic_1916 = 12345;
string gs_unused_1920 = "2010.06.30 23:59";
int gi_unused_1928 = 168168168;
string gs_1932;
string gs_1940;
string gs_1948;
string gs_1956;
string gs_1964;
string gs_1972;
string gs_1980;
string gs_1988;
string gs_1996;
string g_name_2004 = "initialbalance.txt";
string gs_dummy_2012;
bool gi_2020;
int gi_2028;
int gi_2032;
bool gi_2036;
bool gi_2040;
double g_ask_2048;
double g_bid_2056;
double gd_2064;
double gd_2072;
double gd_2080;
double g_ord_open_price_2088;
double g_ord_open_price_2096;
double g_lots_2104;
double gd_2112;
double g_str2dbl_2120;
double gd_2128;
int gi_2136 = 5;
int gi_2140 = 4;
double gd_unused_2144;
double gd_unused_2152;
double gd_unused_2160;
double gd_unused_2168;
double gd_unused_2176;
double gd_unused_2184;
double gd_2192;
double gd_2200;
double gd_2208;
double gd_2216;
int gi_2224 = 0;
int gi_2228 = 3;
int gi_2232 = 2;
bool gi_2240;
bool gi_2244;
bool gi_2248 = TRUE;
int g_error_2252;
double g_ord_open_price_2256;
double gd_2264;
double gd_2272;
double g_price_2280;
double g_price_2288;
double g_ord_open_price_2296;
double gd_2304;
double gd_2312;
double g_price_2320;
double g_price_2328;
double g_lots_2336;
double gd_2344;
double g_point_2352;
double gd_2360;
double gd_2368;
string gs_2376;
string gs_2384;
string gs_eurusd_2392 = "EURUSD";
string gs_gbpusd_2400 = "GBPUSD";
string gs_eurgbp_2408 = "EURGBP";
int gi_2416 = 65535;
int gi_2420 = 16760576;
int gi_2424 = 3329330;
int gi_unused_2428 = 14772545;
int gi_2432 = 255;
int gi_2436 = 55295;
int gi_2440 = 16443110;
int gi_2444 = 9221330;
int gi_2448 = 8388352;
int gi_unused_2452 = 13499135;
int gi_2456 = 11119017;
int gi_2460 = 0;
int gi_2464 = 0;
int gi_2468 = 20;
int gi_2472 = 35;
int gi_2476 = 50;
int gi_2480 = 65;
int gi_2484 = 80;
int gi_2488 = 95;
int gi_2492 = 110;
int gi_2496 = 125;
int gi_2500 = 140;
int gi_2504 = 155;
int gi_2508 = 170;
int gi_2512 = 185;
int gi_2516 = 200;
int gi_2520 = 215;
int gi_2524 = 230;
int gi_2528 = 245;
int gi_2532 = 260;
int gi_2536 = 275;
int gi_2540 = 290;
int gi_2544 = 305;
int gi_2548 = 320;
int gi_2552 = 335;
int gi_2556 = 350;
int gi_2560 = 365;
int gi_2564 = 380;
int gi_2568 = 395;
int gi_2572 = 0;
int gi_2576 = 0;
int gi_2580 = 0;

int init() {
   gi_1824 = 2;

   gi_1812 = gi_1804 + gi_1824;
   gi_1816 = gi_1808 + gi_1824;
   while (true) {
      if (gi_1812 >= 24) {
         gi_1812 -= 24;
         continue;
      }
      if (gi_1812 >= 0) break;
      gi_1812 += 24;
   }
   while (true) {
      if (gi_1816 >= 24) {
         gi_1816 -= 24;
         continue;
      }
      if (gi_1816 >= 0) break;
      gi_1816 += 24;
   }
   g_point_2352 = MarketInfo(Symbol(), MODE_POINT);
   if (MarketInfo(Symbol(), MODE_DIGITS) == 3.0 || MarketInfo(Symbol(), MODE_DIGITS) == 5.0) {
      gd_2368 = MarketInfo(Symbol(), MODE_STOPLEVEL) / 10.0;
      gd_2360 = 10.0 * g_point_2352;
   } else {
      gd_2360 = g_point_2352;
      gd_2368 = MarketInfo(Symbol(), MODE_STOPLEVEL);
   }
   if (Mode == "pyr") {
      LotSize = 0.2;
      gi_324 = 10;
      gd_328 = 2;
      gi_336 = 15;
      increase = 0;
      Hedging = FALSE;
      gi_368 = FALSE;
      gi_320 = TRUE;
      gd_344 = 1;
      gi_352 = TRUE;
      Mode = "pyramid";
   }
   if (Mode == "ch") {
      HedgeGap = 9;
      Multiplier = 0.1;
      EALoop = 0;
      Mode = "Chandri";
   }
   if (Mode == "h") {
      gi_412 = FALSE;
      gi_320 = FALSE;
      TimeLimit = FALSE;
      Hedging = TRUE;
      Multiplier = 0;
      GapAdjustment = FALSE;
   }
   if (Mode == "h2") {
      gi_412 = FALSE;
      gi_320 = FALSE;
      TimeLimit = FALSE;
      Hedging = TRUE;
      Multiplier = 2;
      GapAdjustment = FALSE;
   }
   if (Mode == "hn") {
      gi_412 = FALSE;
      gi_320 = FALSE;
      EALoop = 0;
      TimeLimit = FALSE;
      Hedging = TRUE;
      Multiplier = 0;
      GapAdjustment = FALSE;
   }
   if (Mode == "hn2") {
      gi_412 = FALSE;
      gi_320 = FALSE;
      EALoop = 0;
      TimeLimit = FALSE;
      Hedging = TRUE;
      Multiplier = 2;
      GapAdjustment = FALSE;
   }
   if (Mode == "ht") {
      gi_412 = FALSE;
      gi_320 = FALSE;
      TimeLimit = TRUE;
      Hedging = TRUE;
      Multiplier = 0;
      GapAdjustment = FALSE;
   }
   if (Mode == "ht2") {
      gi_412 = FALSE;
      gi_320 = FALSE;
      TimeLimit = TRUE;
      Hedging = TRUE;
      Multiplier = 2;
      GapAdjustment = FALSE;
   }
   if (Hedging == TRUE) {
      if (HedgeGap < gd_2368) {
         HedgeGap = gd_2368;
         Print("Adjusting HedgeGap to ", HedgeGap);
      }
   }
   if (gi_320 == TRUE) {
      if (gi_324 < gd_2368) {
         gi_324 = gd_2368;
         Print("Adjusting AveragingHedgeGap to ", gi_324);
      }
   }
   return (0);
}

void LABEL(string a_name_0, string a_text_8, string a_fontname_16, int ai_24, int ai_28, color a_color_32) {
   if (ObjectFind(a_name_0) < 0) ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(a_name_0, a_text_8, 9, a_fontname_16, a_color_32);
   ObjectSet(a_name_0, OBJPROP_CORNER, 0);
   ObjectSet(a_name_0, OBJPROP_XDISTANCE, ai_24 + 5 + gi_2460);
   ObjectSet(a_name_0, OBJPROP_YDISTANCE, ai_28 + 15 + gi_2464);
}

int start() {
   int l_file_0;
  /* if (IsTesting()) {
      Alert("This Expert Advisor cant be tested by Strategy Tester!");
      return (0);
   }*/
   LABEL("TITLE_", gs_76, "Arial Bold", 0, gi_2468, gi_2416);
   while (!(ObjectFind("TITLE_") < 0)) {
      g_lots_2104 = LotSize;
      if (g_lots_2104 < MarketInfo(Symbol(), MODE_MINLOT)) {
         if (gi_2240 == FALSE) {
            Alert("**************************");
            Alert("Please Change LotSize Input");
            Alert("Expert Advisor is Disabled");
            Alert("Minimum Lot allowed is ", DoubleToStr(MarketInfo(Symbol(), MODE_MINLOT), 3));
            gi_2240 = TRUE;
         }
         return (0);
      }
      if (gi_412 == TRUE) {
         gi_672 = TRUE;
         gi_668 = FALSE;
         CloseOneCloseAll = FALSE;
         StopLoopTime = "0";
      }
      gd_2264 = 0;
      gd_2304 = 0;
      gd_2272 = 0;
      gd_2312 = 0;
      g_price_2280 = 0;
      g_price_2320 = 0;
      g_price_2288 = 0;
      g_price_2328 = 0;
      g_ord_lots_1580 = 0;
      g_ord_lots_1588 = 0;
      gd_unused_2144 = 0;
      gd_unused_2152 = 0;
      gd_unused_2160 = 0;
      gd_unused_2168 = 0;
      gd_unused_2176 = 0;
      gd_unused_2184 = 0;
      if (gd_2344 < MarketInfo(Symbol(), MODE_ASK) - MarketInfo(Symbol(), MODE_BID)) gd_2344 = MarketInfo(Symbol(), MODE_ASK) - MarketInfo(Symbol(), MODE_BID);
      if (MaxRiskPercentage > 100.0) MaxRiskPercentage = 100.0;
      if (gd_2064 == 0.0) gd_2064 = AccountBalance();
      if (gi_416 == TRUE) {
         FileDelete(g_name_2004);
         g_error_864 = GetLastError();
         if (g_error_864 != 0/* NO_ERROR */) {
            Print("Error = ", ErrorDescription(g_error_864), " while deleting Balance Amount");
            gi_416 = FALSE;
            gi_756 = FALSE;
            break;
         }
         Print("Successfully Reseting Balance");
         gi_416 = FALSE;
      }
      if (gd_424 > 0.0) {
         g_str2dbl_2120 = gd_424;
         g_file_1848 = FileOpen(g_name_2004, FILE_CSV|FILE_WRITE);
         for (int l_count_4 = 0; l_count_4 < 1; l_count_4++) gi_1856 = FileWrite(g_file_1848, DoubleToStr(gd_424, 2));
         if (gi_1856 > 0) {
            Print("InitialBalance is ", g_str2dbl_2120);
            gd_424 = 0;
            Print("MSInitialBalance= ", DoubleToStr(gd_424, 2));
         } else {
            Print("Failed setting InitialBalance");
            gi_756 = FALSE;
            break;
         }
         FileClose(g_file_1848);
      } else {
         if (gd_2112 != AccountBalance()) {
            l_file_0 = FileOpen(g_name_2004, FILE_CSV|FILE_READ);
            gd_2112 = AccountBalance();
            if (l_file_0 > 0) {
               gs_1996 = FileReadString(l_file_0);
               FileClose(l_file_0);
               g_str2dbl_2120 = StrToDouble(gs_1996);
            }
            if (l_file_0 < 0) {
               g_file_1852 = FileOpen(g_name_2004, FILE_CSV|FILE_WRITE);
               if (g_file_1852 > 0) {
                  for (l_count_4 = 0; l_count_4 < 1; l_count_4++) FileWrite(g_file_1852, DoubleToStr(gd_2112, 2));
                  FileClose(g_file_1852);
                  g_str2dbl_2120 = AccountBalance();
               }
               if (g_file_1852 < 0) {
                  Print("File Error. Closing Expert Advisor.");
                  gi_756 = FALSE;
                  break;
               }
            }
         }
      }
      if (!(ObjectFind("LABEL_OFF") < 0)) {
         if (gi_808 == 0) {
            Alert("--------------------------------");
            Alert("5.If no smiley. Check Expert Advisor Icon");
            Alert("4.Drag EA to chart until smiley appears");
            Alert("3.Right Mouse->Object List->Delete Label_OFF");
            Alert("2.Right Mouse->Expert Advisor->Remove");
            Alert("1.Clear all active positions");
            Alert("EA is OFF, to restart EA :");
            gi_808 = 1;
         }
      }
      if (gi_808 == 1) {
         gi_756 = FALSE;
         break;
      }
      gi_808 = 2;
      if (gi_768 == TRUE) {
         if (ObjectsTotal() > 0) ObjectsDeleteAll();
         if (ObjectsTotal() <= 0) gi_768 = FALSE;
      }
      if ((Hedging == TRUE && gi_320 == TRUE) || (Hedging == TRUE && gi_412 == TRUE) || (Hedging == TRUE && gi_368 == TRUE) || (gi_320 == TRUE && gi_368 == TRUE) || (gi_320 == TRUE &&
         gi_412 == TRUE)) {
         if (gi_2036 == FALSE) {
            Alert("~~~~oOOo~(_)~oOOo~~~~");
            Alert("~~~~          ( o o )        ~~~~");
            Alert("~~~~           \\|//           ~~~~");
            if (Hedging == TRUE && gi_320 == TRUE) Alert("Hedging & Averaging could not run at once");
            if (Hedging == TRUE && gi_412 == TRUE) Alert("Hedging & MS could not run at once");
            if (Hedging == TRUE && gi_368 == TRUE) Alert("Hedging & Corr could not run at once");
            if (gi_320 == TRUE && gi_412 == TRUE) Alert("Averaging & MS could not run at once");
            if (gi_320 == TRUE && gi_368 == TRUE) Alert("Averaging & Corr could not run at once");
            if (gi_412 == TRUE && gi_368 == TRUE) Alert("MS & Corr could not run at once");
         }
         gi_2036 = TRUE;
         gi_756 = FALSE;
      }
      if (AccountBalance() < MarketInfo(Symbol(), MODE_MARGINREQUIRED) * MarketInfo(Symbol(), MODE_MINLOT) + MarketInfo(Symbol(), MODE_SPREAD) * MarketInfo(Symbol(), MODE_TICKVALUE) * MarketInfo(Symbol(), MODE_MINLOT)) {
         if (gi_2040 == FALSE) Alert("Your Account Balance is not enough");
         gi_2040 = TRUE;
         gi_756 = FALSE;
      }
      if (gi_756 == TRUE) {
         ObjectDelete("LABEL_OFF");
         LABEL("LABEL_ON", "Expert Advisor is ON", "Arial Bold", 0, gi_2472, gi_2448);
         if (!IsExpertEnabled()) {
            if (gi_2020 == FALSE) {
               Alert("*******************************");
               Alert("Send email to support@belajarforexpro.com");
               Alert("Please contact BelajarForexPro.com");
               Alert("Do not turn off Expert Advisor while running!");
            }
            gi_2020 = TRUE;
         }
      } else {
         if (gi_780 == TRUE) {
            ObjectDelete("LABEL_OFF");
            LABEL("LABEL_ON", "Waiting to Start. Time Left " + ((StrToTime(StartEATime) - TimeLocal())) + " sec", "Arial Bold", 0, gi_2472, gi_2432);
         }
         if (gi_780 == FALSE) {
            if (gi_1516 == FALSE) {
               if (gi_2036 != TRUE && gi_2040 != TRUE) MessageDisplay();
               gi_1516 = TRUE;
            }
            ObjDelete();
            ObjectDelete("LABEL_ON");
            LABEL("LABEL_OFF", "Expert Advisor is OFF", "Arial Bold", 0, gi_2472, gi_2432);
         }
      }
      if (gi_756 == TRUE) {
         gd_2080 = (MarketInfo(Symbol(), MODE_HIGH) - MarketInfo(Symbol(), MODE_LOW)) / MarketInfo(Symbol(), MODE_POINT);
         if (MarketInfo(Symbol(), MODE_DIGITS) == 3.0 || MarketInfo(Symbol(), MODE_DIGITS) == 5.0) {
            gd_2200 = gd_2080 / 10.0;
            gd_2208 = MarketInfo(Symbol(), MODE_STOPLEVEL) / 10.0;
            gd_2192 = MarketInfo(Symbol(), MODE_SPREAD) / 10.0;
         } else {
            gd_2200 = gd_2080;
            gd_2208 = MarketInfo(Symbol(), MODE_STOPLEVEL);
            gd_2192 = MarketInfo(Symbol(), MODE_SPREAD);
         }
         gs_1948 = "\n[MINLOT " + DoubleToStr(MarketInfo(Symbol(), MODE_MINLOT), 3) + "] [HI-LOW " + DoubleToStr(gd_2200, 1) + "] [SPREAD " + DoubleToStr(gd_2192, 1) + "] COPYRIGHT OF BELAJARFOREXPRO.COM";
         if (IsDemo() == TRUE) gs_1956 = "DEMO";
         else gs_1956 = "REAL";
         Comment("[LOCAL ", TimeToStr(TimeLocal(), TIME_DATE|TIME_SECONDS), "] [SERVER ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_SECONDS), "] [1:", AccountLeverage(), "] [DIGITS ", Digits, "] [MIN RANGE ", DoubleToStr(gd_2208, 1) +
            "] [" + gs_1956 + "]" + gs_1948);
         if (BuyLots() > SellLots()) LABEL("SEQUENCE_", "BUY Cycle Active", "Arial Bold", 0, gi_2476, gi_2420);
         if (BuyLots() < SellLots()) LABEL("SEQUENCE_", "SELL Cycle Active", "Arial Bold", 0, gi_2476, gi_2420);
         if (BuyLots() + SellLots() > 0.0)
            if (BuyLots() == SellLots()) LABEL("SEQUENCE_", "FULL HEDGING", "Arial Bold", 0, gi_2476, gi_2420);
         if (BuyLots() + SellLots() == 0.0)
            if (BuyLots() == SellLots()) LABEL("SEQUENCE_", "Waiting for sequence", "Arial Bold", 0, gi_2476, gi_2420);
         if (BuyOpen() + SellOpen() > 0) LABEL("BUYROW_", "Buy Row: " + BuyOpen() + " Sell Row: " + SellOpen(), "Arial Bold", 135, gi_2476, gi_2420);
         else LABEL("BUYROW_", "Buy Row: " + BuyOpen() + "Sell Row: " + SellOpen(), "Arial Bold", 135, gi_2476, gi_2456);
         if (gd_1064 > 0.0) LABEL("GAP_", "Gap : " + DoubleToStr(gd_1064 / gd_2360, 0), "Arial Bold", 325, gi_2476, gi_2420);
         else ObjectDelete("GAP_");
      }
      if (gi_492 == TRUE) {
         if (gd_1652 > 0.0) {
            LABEL("STRADDLE_BUY_", "Straddle Buy @ " + DoubleToStr(g_lots_2104, 3) + " Lots @ " + DoubleToStr(gd_1652, Digits) + " TP: " + DoubleToStr(gd_1668, Digits) + " SL: " +
               DoubleToStr(gd_1676, Digits), "Arial Bold", 0, gi_2480, gi_2424);
         } else {
            LABEL("STRADDLE_BUY_", "Straddle Buy @ " + DoubleToStr(g_lots_2104, 3) + " Lots @ " + DoubleToStr(gd_1652, Digits) + " TP: " + DoubleToStr(gd_1668, Digits) + " SL: " +
               DoubleToStr(gd_1676, Digits), "Arial Bold", 0, gi_2480, gi_2456);
         }
         if (gd_1660 > 0.0) {
            LABEL("STRADDLE_SELL_", "Straddle Sell @ " + DoubleToStr(g_lots_2104, 3) + " Lots @ " + DoubleToStr(gd_1660, Digits) + " TP: " + DoubleToStr(gd_1684, Digits) + " SL: " +
               DoubleToStr(gd_1692, Digits), "Arial Bold", 0, gi_2484, gi_2432);
         } else {
            LABEL("STRADDLE_SELL_", "Straddle Sell @ " + DoubleToStr(g_lots_2104, 3) + " Lots @ " + DoubleToStr(gd_1660, Digits) + " TP: " + DoubleToStr(gd_1684, Digits) + " SL: " +
               DoubleToStr(gd_1692, Digits), "Arial Bold", 0, gi_2484, gi_2456);
         }
         if (gd_1652 + gd_1660 > 0.0) LABEL("STRADDLE_INFO_", "[Straddle] Range: " + gi_496 + " TP: " + gi_516 + " SL: " + gi_520, "Arial Bold", 0, gi_2488, gi_2420);
         else LABEL("STRADDLE_INFO_", "[Straddle] Range: " + gi_496 + " TP: " + gi_516 + " SL: " + gi_520, "Arial Bold", 0, gi_2488, gi_2456);
      }
      if (gi_320 == TRUE && gi_352 == TRUE) {
         if (BuyOpen() + SellOpen() > 0) gi_2244 = FALSE;
         else gi_2244 = TRUE;
         if (gi_2244 == TRUE) {
            if (BuyOrders() > 0) LABEL("HILOW_BUY_", "HiLow Buy @ " + DoubleToStr(g_lots_2104, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1772, Digits), "Arial Bold", 0, gi_2480, gi_2424);
            else LABEL("HILOW_BUY_", "HiLow Buy @ " + DoubleToStr(g_lots_2104, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1772, Digits), "Arial Bold", 0, gi_2480, gi_2456);
            if (SellOrders() > 0) LABEL("HILOW_SELL_", "HiLow Sell @ " + DoubleToStr(g_lots_2104, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1780, Digits), "Arial Bold", 0, gi_2484, gi_2432);
            else LABEL("HILOW_SELL_", "HiLow Sell @ " + DoubleToStr(g_lots_2104, 3) + " Lots @ " + DoubleToStr(g_ord_open_price_1780, Digits), "Arial Bold", 0, gi_2484, gi_2456);
            if (BuyOrders() + SellOrders() > 0) LABEL("HILOW_INFO_", "[HiLow] Gap: " + gi_356 + " Current: " + DoubleToStr(gd_2080, 0) + " HiLow Range: " + gi_360 + " Indi Level: " + gi_364, "Arial Bold", 0, gi_2488, gi_2420);
            else LABEL("HILOW_INFO_", "[HiLow] Gap: " + gi_356 + " Current: " + DoubleToStr(gd_2080, 0) + " HiLow Range: " + gi_360 + " Indi Level: " + gi_364, "Arial Bold", 0, gi_2488, gi_2456);
         }
      }
      if (gi_492 == FALSE && gi_2244 == FALSE) {
         if (gi_412 == TRUE) LABEL("EMA_", "[Init] Bal: " + DoubleToStr(g_str2dbl_2120, 2) + " Cut P/L($): " + gi_452 + " ReB: B @" + DoubleToStr(gd_1788, Digits) + " S @" + DoubleToStr(gd_1796, Digits), "Arial Bold", 0, gi_2492, gi_2436);
         else {
            if (InitialOrder == "auto" || InitialOrder == "m" || InitialOrder == "manual" || InitialOrder == "buy auto" || InitialOrder == "sell auto" || InitialOrder == "ba" ||
               InitialOrder == "sa") {
               if (InitialOrder == "m") InitialOrder = "manual";
               if (InitialOrder == "a") InitialOrder = "auto";
               if (InitialOrder == "ba") InitialOrder = "buy auto";
               if (InitialOrder == "sa") InitialOrder = "sell auto";
               LABEL("EMA_", "[Init] Short EMA: " + ShortEMA + " Long EMA: " + LongEMA + " Order: " + InitialOrder + ", " + Mode, "Arial Bold", 0, gi_2492, gi_2436);
            } else ObjectDelete("EMA_");
         }
         if (gi_412 == FALSE) {
            if (Hedging == TRUE || gi_320 == TRUE) {
               if (increase > 0) {
                  if (gi_880 >= IncreaseStartLevel) LABEL("INCREASE_", "[Increase] Range" + increase + " Start: " + IncreaseStartLevel + " End: " + IncreaseEndLevel, "Arial Bold", 0, gi_2496, gi_2440);
                  else LABEL("INCREASE_", "[Increase] Range" + increase + " Start: " + IncreaseStartLevel + " End: " + IncreaseEndLevel, "Arial Bold", 0, gi_2496, gi_2456);
               } else LABEL("INCREASE_", "[Increase] is OFF", "Arial Bold", 0, gi_2496, gi_2456);
               if (Hedging == TRUE) {
                  LABEL("RANGE_", "[Current] Range: " + ((HedgeGap + increase * gi_884)) + " Level: " + gi_880 + " Cut: " + MaxLevelAllowed + " Stop: " + LevelStopOpen + " P/L: " +
                     DoubleToStr(AccountProfit(), 2), "Arial Bold", 0, gi_2500, gi_2444);
               }
               if (gi_320 == TRUE) LABEL("RANGE_", "[Current] Range: " + ((gi_324 + increase * gi_884)) + " Level: " + gi_880 + " Cut: " + MaxLevelAllowed + " Stop: " + LevelStopOpen + " P/L: " + DoubleToStr(AccountProfit(), 2), "Arial Bold", 0, gi_2500, gi_2444);
               if (BuyLots() + SellLots() > 0.0 && BuyLots() == SellLots()) {
                  ObjectDelete("INITIALRANGE_");
                  LABEL("FULLHEDGE_", "[Basic] Full Hedging Position. Closing at " + CloseWhileHedgingProfit + " point(s) profit", "Arial Bold", 0, gi_2504, gi_2420);
               } else {
                  if (Hedging == TRUE) {
                     ObjectDelete("FULLHEDGE_");
                     LABEL("INITIALRANGE_", "[Basic] Hedge Gap: " + HedgeGap + " Multiplier: " + DoubleToStr(Multiplier, 2) + " Lot " + DoubleToStr(g_lots_2104, 3) + " TP: " + TakeProfit +
                        " SL: " + StopLoss, "Arial Bold", 0, gi_2504, gi_2420);
                  }
                  if (gi_320 == TRUE) {
                     ObjectDelete("FULLHEDGE_");
                     LABEL("INITIALRANGE_", "[Basic] Average Gap: " + gi_324 + " Multiplier: " + DoubleToStr(gd_328, 2) + " Lot " + DoubleToStr(g_lots_2104, 3) + " TP: " + gi_336 + " SL: " +
                        gi_340, "Arial Bold", 0, gi_2504, gi_2420);
                     if (gd_344 > 0.0) LABEL("MAXLOTSTOP_", "Max Lot Stop: " + DoubleToStr(gd_344, 3), "Arial Bold", 350, gi_2504, gi_2420);
                     else ObjectDelete("MAXLOTSTOP_");
                  }
               }
            } else {
               ObjectDelete("INCREASE_");
               ObjectDelete("RANGE_");
               ObjectDelete("INITIALRANGE_");
            }
         }
         if (gi_412 == TRUE) {
            LABEL("RANGE_", "[Current] Range: " + gi_432 + " Bal: " + DoubleToStr(AccountBalance(), 2) + " Cum P/L: " + DoubleToStr(gd_2128, 2) + " P/L: " + DoubleToStr(AccountProfit(), 2), "Arial Bold", 0, gi_2500, gi_2444);
            LABEL("INITIALRANGE_", "[Basic] MS Adj Pend: " + gi_456 + " TP: " + gi_436 + " SL: " + gi_440 + " TS: " + gi_444 + " ReB: " + gi_448, "Arial Bold", 0, gi_2504, gi_2420);
         }
         if (gi_196 == TRUE) {
            gs_1972 = "ON";
            if (gi_200 == TRUE) gs_1980 = "ON";
            else gs_1980 = "OFF";
            LABEL("AUTOLOT_", "[Basic] AutoCalLot: " + gs_1972 + " DecLot: " + gs_1980 + " LotRatio: " + DoubleToStr(gd_204, 2), "Arial Bold", 0, gi_2508, gi_2420);
         } else {
            gs_1972 = "OFF";
            LABEL("AUTOLOT_", "[Basic] AutoCalLot: OFF", "Arial Bold", 0, gi_2508, gi_2456);
         }
         if (gi_672 == FALSE) {
            if (TrailingStop > 0) {
               if (BuyLots() > SellLots()) {
                  if (g_bid_1072 > 0.0 || gd_1732 != g_bid_1072) {
                     ObjectDelete("TRAILINGSTOPSELL_");
                     ObjectDelete("TRAILINGSTOPSELL_BEP_");
                     LABEL("TRAILINGSTOPBUY_", "[TS] Buy Range: " + TrailingStop + " (" + DoubleToStr(gd_1032, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_968, Digits) + ") Start: " +
                        TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_2512, gi_2424);
                     LABEL("TRAILINGSTOPBUY_BEP_", " BEP: " + DoubleToStr(g_bid_1072, Digits), "Arial Bold", 350, gi_2512, gi_2424);
                  } else {
                     ObjectDelete("TRAILINGSTOPSELL_");
                     ObjectDelete("TRAILINGSTOPSELL_BEP_");
                     LABEL("TRAILINGSTOPBUY_", "[TS] Buy Range: " + TrailingStop + " (" + DoubleToStr(gd_1032, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_968, Digits) + ") Start: " +
                        TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_2512, gi_2456);
                     LABEL("TRAILINGSTOPBUY_BEP_", " BEP: " + DoubleToStr(g_bid_1072, Digits), "Arial Bold", 350, gi_2512, gi_2456);
                  }
               }
               if (SellLots() > BuyLots()) {
                  if (g_ask_1080 > 0.0) {
                     ObjectDelete("TRAILINGSTOPBUY_");
                     ObjectDelete("TRAILINGSTOPBUY_BEP_");
                     LABEL("TRAILINGSTOPSELL_", "[TS] Sell Range: " + TrailingStop + " (" + DoubleToStr(gd_1040, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_976, Digits) + ") Start: " +
                        TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_2512, gi_2424);
                     LABEL("TRAILINGSTOPSELL_BEP_", " BEP: " + DoubleToStr(g_ask_1080, Digits), "Arial Bold", 350, gi_2512, gi_2424);
                  } else {
                     ObjectDelete("TRAILINGSTOPBUY_");
                     ObjectDelete("TRAILINGSTOPBUY_BEP_");
                     LABEL("TRAILINGSTOPSELL_", "[TS] Sell Range: " + TrailingStop + " (" + DoubleToStr(gd_1040, Digits) + ") ReB: " + Rebound + " (" + DoubleToStr(gd_976, Digits) + ") Start: " +
                        TrailingStopStartLevel + " End: " + TrailingStopEndLevel, "Arial Bold", 0, gi_2512, gi_2456);
                     LABEL("TRAILINGSTOPSELL_BEP_", " BEP: " + DoubleToStr(g_ask_1080, Digits), "Arial Bold", 350, gi_2512, gi_2456);
                  }
               }
            } else LABEL("TRAILINGSTOP_", "[TS] is OFF ", "Arial Bold", 0, gi_2512, gi_2456);
            if (TrailingStop_2 > 0) {
               if (BuyLots() > SellLots()) {
                  if (g_bid_1088 > 0.0) {
                     ObjectDelete("TRAILINGSTOPSELL_2_");
                     ObjectDelete("TRAILINGSTOPSELL_2_BEP_");
                     LABEL("TRAILINGSTOPBUY_2_", "[TS 2] Buy Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1096, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1120, Digits) +
                        ") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_2516, gi_2424);
                     LABEL("TRAILINGSTOPBUY_2_BEP_", " BEP: " + DoubleToStr(g_bid_1088, Digits), "Arial Bold", 350, gi_2516, gi_2424);
                  } else {
                     ObjectDelete("TRAILINGSTOPSELL_2_");
                     ObjectDelete("TRAILINGSTOPSELL_2_BEP_");
                     LABEL("TRAILINGSTOPBUY_2_", "[TS 2] Buy Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1096, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1120, Digits) +
                        ") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_2516, gi_2456);
                     LABEL("TRAILINGSTOPBUY_2_BEP_", " BEP: " + DoubleToStr(g_bid_1088, Digits), "Arial Bold", 350, gi_2516, gi_2456);
                  }
               }
               if (SellLots() > BuyLots()) {
                  if (g_ask_1128 > 0.0) {
                     ObjectDelete("TRAILINGSTOPBUY_2_");
                     ObjectDelete("TRAILINGSTOPBUY_2_BEP_");
                     LABEL("TRAILINGSTOPSELL_2_", "[TS 2] Sell Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1136, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1160, Digits) +
                        ") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_2516, gi_2424);
                     LABEL("TRAILINGSTOPSELL_2_BEP_", " BEP: " + DoubleToStr(g_ask_1128, Digits), "Arial Bold", 350, gi_2516, gi_2424);
                  } else {
                     ObjectDelete("TRAILINGSTOPBUY_2_");
                     ObjectDelete("TRAILINGSTOPBUY_2_BEP_");
                     LABEL("TRAILINGSTOPSELL_2_", "[TS 2] Sell Range: " + TrailingStop_2 + " (" + DoubleToStr(gd_1136, Digits) + ") ReB: " + Rebound_2 + " (" + DoubleToStr(gd_1160, Digits) +
                        ") Start: " + TrailingStop_2_StartLevel + " End: " + TrailingStop_2_EndLevel, "Arial Bold", 0, gi_2516, gi_2456);
                     LABEL("TRAILINGSTOPSELL_2_BEP_", " BEP: " + DoubleToStr(g_ask_1128, Digits), "Arial Bold", 350, gi_2516, gi_2456);
                  }
               }
            } else LABEL("TRAILINGSTOP_2_", "[TS 2] is OFF", "Arial Bold", 0, gi_2516, gi_2456);
            if (TrailingStop_3 > 0) {
               if (BuyLots() > SellLots()) {
                  if (g_bid_1168 > 0.0) {
                     ObjectDelete("TRAILINGSTOPSELL_3_");
                     ObjectDelete("TRAILINGSTOPSELL_3_BEP_");
                     LABEL("TRAILINGSTOPBUY_3_", "[TS 3] Buy Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1176, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1200, Digits) +
                        ") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_2520, gi_2424);
                     LABEL("TRAILINGSTOPBUY_3_BEP_", " BEP: " + DoubleToStr(g_bid_1168, Digits), "Arial Bold", 350, gi_2520, gi_2424);
                  } else {
                     ObjectDelete("TRAILINGSTOPSELL_3_");
                     ObjectDelete("TRAILINGSTOPSELL_3_BEP_");
                     LABEL("TRAILINGSTOPBUY_3_", "[TS 3] Buy Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1176, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1200, Digits) +
                        ") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_2520, gi_2456);
                     LABEL("TRAILINGSTOPBUY_3_BEP_", " BEP: " + DoubleToStr(g_bid_1168, Digits), "Arial Bold", 350, gi_2520, gi_2456);
                  }
               }
               if (SellLots() > BuyLots()) {
                  if (g_bid_1168 > 0.0) {
                     ObjectDelete("TRAILINGSTOPBUY_3_");
                     ObjectDelete("TRAILINGSTOPBUY_3_BEP_");
                     LABEL("TRAILINGSTOPSELL_3_", "[TS 3] Sell Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1216, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1240, Digits) +
                        ") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_2520, gi_2424);
                     LABEL("TRAILINGSTOPSELL_3_BEP_", " BEP: " + DoubleToStr(g_ask_1208, Digits), "Arial Bold", 350, gi_2520, gi_2424);
                  } else {
                     ObjectDelete("TRAILINGSTOPBUY_3_");
                     ObjectDelete("TRAILINGSTOPBUY_3_BEP_");
                     LABEL("TRAILINGSTOPSELL_3_", "[TS 3] Sell Range: " + TrailingStop_3 + " (" + DoubleToStr(gd_1216, Digits) + ") ReB: " + Rebound_3 + " (" + DoubleToStr(gd_1240, Digits) +
                        ") Start: " + TrailingStop_3_StartLevel + " End: " + TrailingStop_3_EndLevel, "Arial Bold", 0, gi_2520, gi_2456);
                     LABEL("TRAILINGSTOPSELL_3_BEP_", " BEP: " + DoubleToStr(g_ask_1208, Digits), "Arial Bold", 350, gi_2520, gi_2456);
                  }
               }
            } else LABEL("TrailingStop_3_", "[TS 3] is OFF", "Arial Bold", 0, gi_2520, gi_2456);
            if (gi_604 > 0) {
               if (BuyLots() > SellLots()) {
                  if (gd_1248 > 0.0) {
                     ObjectDelete("TRAILINGSTOPSELL_4_");
                     ObjectDelete("TRAILINGSTOPSELL_4_BEP_");
                     LABEL("TRAILINGSTOPBUY_4_", "[TS 4] Buy Range: " + gi_604 + " (" + DoubleToStr(gd_1256, Digits) + ") ReB: " + gi_616 + " (" + DoubleToStr(gd_1280, Digits) + ") Start: " +
                        gi_608 + " End: " + gi_612, "Arial Bold", 0, gi_2524, gi_2424);
                     LABEL("TRAILINGSTOPBUY_4_BEP_", " BEP: " + DoubleToStr(gd_1248, Digits), "Arial Bold", 350, gi_2524, gi_2424);
                  } else {
                     ObjectDelete("TRAILINGSTOPSELL_4_");
                     ObjectDelete("TRAILINGSTOPSELL_4_BEP_");
                     LABEL("TRAILINGSTOPBUY_4_", "[TS 4] Buy Range: " + gi_604 + " (" + DoubleToStr(gd_1256, Digits) + ") ReB: " + gi_616 + " (" + DoubleToStr(gd_1280, Digits) + ") Start: " +
                        gi_608 + " End: " + gi_612, "Arial Bold", 0, gi_2524, gi_2456);
                     LABEL("TRAILINGSTOPBUY_4_BEP_", " BEP: " + DoubleToStr(gd_1248, Digits), "Arial Bold", 350, gi_2524, gi_2456);
                  }
               }
               if (SellLots() > BuyLots()) {
                  if (gd_1248 > 0.0) {
                     ObjectDelete("TRAILINGSTOPBUY_4_");
                     ObjectDelete("TRAILINGSTOPBUY_4_BEP_");
                     LABEL("TRAILINGSTOPSELL_4_", "[TS 4] Sell Range: " + gi_604 + " (" + DoubleToStr(gd_1296, Digits) + ") ReB: " + gi_616 + " (" + DoubleToStr(gd_1320, Digits) + ") Start: " +
                        gi_608 + " End: " + gi_612, "Arial Bold", 0, gi_2524, gi_2424);
                     LABEL("TRAILINGSTOPSELL_4_BEP_", " BEP: " + DoubleToStr(gd_1288, Digits), "Arial Bold", 350, gi_2524, gi_2424);
                  } else {
                     ObjectDelete("TRAILINGSTOPBUY_4_");
                     ObjectDelete("TRAILINGSTOPBUY_4_BEP_");
                     LABEL("TRAILINGSTOPSELL_4_", "[TS 4] Sell Range: " + gi_604 + " (" + DoubleToStr(gd_1296, Digits) + ") ReB: " + gi_616 + " (" + DoubleToStr(gd_1320, Digits) + ") Start: " +
                        gi_608 + " End: " + gi_612, "Arial Bold", 0, gi_2524, gi_2456);
                     LABEL("TRAILINGSTOPSELL_4_BEP_", " BEP: " + DoubleToStr(gd_1288, Digits), "Arial Bold", 350, gi_2524, gi_2456);
                  }
               }
            } else LABEL("TrailingStop_4_", "[TS 4] is OFF", "Arial Bold", 0, gi_2524, gi_2456);
         } else {
            ObjectDelete("TRAILINGSTOPSELL_");
            ObjectDelete("TRAILINGSTOPSELL_BEP_");
            ObjectDelete("TRAILINGSTOPBUY_");
            ObjectDelete("TRAILINGSTOPBUY_BEP_");
            ObjectDelete("TRAILINGSTOPSELL_2_");
            ObjectDelete("TRAILINGSTOPSELL_2_BEP_");
            ObjectDelete("TRAILINGSTOPBUY_2_");
            ObjectDelete("TRAILINGSTOPBUY_2_BEP_");
            ObjectDelete("TRAILINGSTOPSELL_3_");
            ObjectDelete("TRAILINGSTOPSELL_3_BEP_");
            ObjectDelete("TRAILINGSTOPBUY_3_");
            ObjectDelete("TRAILINGSTOPBUY_3_BEP_");
            ObjectDelete("TRAILINGSTOPBUY_4_");
            ObjectDelete("TRAILINGSTOPBUY_4_BEP_");
            ObjectDelete("TRAILINGSTOPSELL_4_");
            ObjectDelete("TRAILINGSTOPSELL_4_BEP_");
            LABEL("TRAILINGSTOP_", "[TS] is OFF ", "Arial Bold", 0, gi_2512, gi_2456);
         }
         if (Start_Safer) {
            if (BuyLots() > SellLots()) {
               if (g_bid_1328 > 0.0 || Safer_Money_CutLoss > 0.0) {
                  ObjectDelete("SAFERSELL");
                  ObjectDelete("SAFERSELL_BEP_");
                  LABEL("SAFERBUY", "[SAFER] Buy Range: " + Safer + " (" + DoubleToStr(gd_1344, Digits) + ") Start: " + Safer_StartLevel + " End: " + Safer_EndLevel, "Arial Bold", 0, gi_2528, gi_2424);
                  LABEL("SAFERBUY_BEP_", " BEP: " + DoubleToStr(g_bid_1328, Digits) + " Cut($): " + DoubleToStr(Safer_Money_CutLoss, 2), "Arial Bold", 350, gi_2528, gi_2424);
               } else {
                  ObjectDelete("SAFERSELL");
                  ObjectDelete("SAFERSELL_BEP_");
                  LABEL("SAFERBUY", "[SAFER] Buy Range: " + Safer + " (" + DoubleToStr(gd_1344, Digits) + ") Start: " + Safer_StartLevel + " End: " + Safer_EndLevel, "Arial Bold", 0, gi_2528, gi_2456);
                  LABEL("SAFERBUY_BEP_", " BEP: " + DoubleToStr(g_bid_1328, Digits) + " Cut($): " + DoubleToStr(Safer_Money_CutLoss, 2), "Arial Bold", 350, gi_2528, gi_2456);
               }
            }
            if (SellLots() > BuyLots()) {
               if (g_ask_1360 > 0.0 || Safer_Money_CutLoss > 0.0) {
                  ObjectDelete("SAFERBUY");
                  ObjectDelete("SAFERBUY_BEP_");
                  LABEL("SAFERSELL", "[SAFER] Sell Range: " + Safer + " (" + DoubleToStr(gd_1376, Digits) + ") Start: " + Safer_StartLevel + " End: " + Safer_EndLevel, "Arial Bold", 0, gi_2528, gi_2424);
                  LABEL("SAFERSELL_BEP_", " BEP: " + DoubleToStr(g_ask_1360, Digits) + " Cut($): " + DoubleToStr(Safer_Money_CutLoss, 2), "Arial Bold", 350, gi_2528, gi_2424);
               } else {
                  ObjectDelete("SAFERBUY");
                  ObjectDelete("SAFERBUY_BEP_");
                  LABEL("SAFERSELL", "[SAFER] Sell Range: " + Safer + " (" + DoubleToStr(gd_1376, Digits) + ") Start: " + Safer_StartLevel + " End: " + Safer_EndLevel, "Arial Bold", 0, gi_2528, gi_2456);
                  LABEL("SAFERSELL_BEP_", " BEP: " + DoubleToStr(g_ask_1360, Digits) + " Cut($): " + DoubleToStr(Safer_Money_CutLoss, 2), "Arial Bold", 350, gi_2528, gi_2456);
               }
            }
         } else LABEL("Safer_", "[SAFER] is OFF", "Arial Bold", 0, gi_2528, gi_2456);
         if (MaxRiskPercentage > 0.0) {
            if (gd_1644 < 0.0) LABEL("MAXRISK_", "[Management] Risk %: " + DoubleToStr(gd_1644, 2) + " % of " + DoubleToStr(-MaxRiskPercentage, 2) + " %", "Arial Bold", 0, gi_2532, gi_2432);
            else LABEL("MAXRISK_", "[Management] Risk %: " + DoubleToStr(gd_1644, 2) + " % of " + DoubleToStr(-MaxRiskPercentage, 2) + " %", "Arial Bold", 0, gi_2532, gi_2456);
         } else LABEL("MAXRISK_", "[Management] Risk % is OFF ", "Arial Bold", 0, gi_2532, gi_2456);
         if (MaxProfit > 0.0) {
            if (Multiplier == 0.1) {
               if (BuyLots() > SellLots()) g_dbl2str_1408 = DoubleToStr(gd_1392, 2);
               if (SellLots() > BuyLots()) g_dbl2str_1408 = DoubleToStr(gd_1400, 2);
            } else g_dbl2str_1408 = DoubleToStr(MaxProfit, 2);
            if (AccountProfit() > 0.0) LABEL("MAXPROFIT_", "Profit($) " + DoubleToStr(AccountProfit(), 2) + " of " + g_dbl2str_1408, "Arial Bold", 245, gi_2532, gi_2432);
            else LABEL("MAXPROFIT_", "Profit($) " + DoubleToStr(AccountProfit(), 2) + " of " + g_dbl2str_1408, "Arial Bold", 245, gi_2532, gi_2456);
         } else LABEL("MAXPROFIT_", "Profit($) is OFF", "Arial Bold", 245, gi_2532, gi_2456);
         if (CloseOneCloseAll == TRUE) {
            gs_1988 = "ON";
            LABEL("CLOSEONECLOSEALL_", "[Management] CloseOneCloseAll: " + gs_1988, "Arial Bold", 0, gi_2536, gi_2432);
         } else {
            gs_1988 = "OFF";
            LABEL("CLOSEONECLOSEALL_", "[Management] CloseOneCloseAll: " + gs_1988, "Arial Bold", 0, gi_2536, gi_2456);
         }
         if (MaxLoss > 0.0) {
            if (AccountProfit() < 0.0) LABEL("MAXLOSS_", "Loss($) " + DoubleToStr(AccountProfit(), 2) + " of -" + DoubleToStr(MaxLoss, 2), "Arial Bold", 245, gi_2536, gi_2432);
            else LABEL("MAXLOSS_", "Loss($) " + DoubleToStr(AccountProfit(), 2) + " of -" + DoubleToStr(MaxLoss, 2), "Arial Bold", 245, gi_2536, gi_2456);
         } else LABEL("MAXLOSS_", "Loss($) is OFF", "Arial Bold", 245, gi_2536, gi_2456);
         if (gi_668 == TRUE) {
            if (DoublerBuyLots() + DoublerSellLots() > 0.0) {
               LABEL("DOUBLER_", "[Doubler] Lot " + DoubleToStr(gd_676, 3) + " Range: " + gi_684 + " TP: " + gi_688 + " SL :" + gi_692 + " Start : " + gi_712 + " End : " + gi_716, "Arial Bold", 0, gi_2540, gi_2416);
               LABEL("DOUBLER_2_", "[Doubler] Multiplier :" + DoubleToStr(gd_696, 2) + " Addition: " + DoubleToStr(gd_704, 3), "Arial Bold", 0, gi_2544, gi_2416);
               if (gi_672 == TRUE) LABEL("DOUBLER_3_", "Disable TS: YES", "Arial Bold", 230, gi_2544, gi_2416);
               else LABEL("DOUBLER_3_", "Disable TS: NO", "Arial Bold", 230, gi_2544, gi_2416);
            } else {
               LABEL("DOUBLER_", "[Doubler] Lot " + DoubleToStr(gd_676, 3) + " Range: " + gi_684 + " TP: " + gi_688 + " SL :" + gi_692 + " Start : " + gi_712 + " End : " + gi_716, "Arial Bold", 0, gi_2540, gi_2456);
               LABEL("DOUBLER_2_", "[Doubler] Multiplier :" + DoubleToStr(gd_696, 2) + " Addition: " + DoubleToStr(gd_704, 3), "Arial Bold", 0, gi_2544, gi_2456);
               if (gi_672 == TRUE) LABEL("DOUBLER_3_", "Disable TS: YES", "Arial Bold", 230, gi_2544, gi_2456);
               else LABEL("DOUBLER_3_", "Disable TS: NO", "Arial Bold", 230, gi_2544, gi_2456);
            }
            if (DoublerBuyLots() > 0.0) {
               ObjectDelete("DOUBLER_BUY_OFF");
               ObjectDelete("DOUBLER_BUY_2_OFF");
               LABEL("DOUBLER_BUY_ON", "[Doubler] Buy " + DoubleToStr(gd_1480, 2) + " lots @ " + DoubleToStr(gd_1700, Digits) + " SL: " + DoubleToStr(gd_1628, Digits) + " TP:  " +
                  DoubleToStr(gd_1612, Digits), "Arial Bold", 0, gi_2548, gi_2424);
               LABEL("DOUBLER_BUY_2_ON", "[Doubler] Buy BEP @ " + DoubleToStr(gd_1700 - gi_684 * gd_2360, Digits) + " Order " + gi_1496 + " of " + gi_720, "Arial Bold", 0, gi_2552, gi_2424);
            } else {
               ObjectDelete("DOUBLER_BUY_ON");
               ObjectDelete("DOUBLER_BUY_2_ON");
               LABEL("DOUBLER_BUY_OFF", "[Doubler] Buy " + DoubleToStr(gd_1448, 2) + " lots @ " + DoubleToStr(gd_1432, Digits) + " SL: " + DoubleToStr(gd_1628, Digits) + " TP:  " +
                  DoubleToStr(gd_1612, Digits), "Arial Bold", 0, gi_2548, gi_2456);
               LABEL("DOUBLER_BUY_2_OFF", "[Doubler] Buy BEP @ " + DoubleToStr(gd_1416, Digits) + " Order " + gi_1496 + " of " + gi_720, "Arial Bold", 0, gi_2552, gi_2456);
            }
            if (DoublerSellLots() > 0.0) {
               ObjectDelete("DOUBLER_SELL_OFF");
               ObjectDelete("DOUBLER_SELL_2_OFF");
               LABEL("DOUBLER_SELL_ON", "[Doubler] Sell " + DoubleToStr(gd_1488, 2) + " lots @ " + DoubleToStr(gd_1708, Digits) + " SL: " + DoubleToStr(gd_1636, Digits) + " TP: " +
                  DoubleToStr(gd_1620, Digits), "Arial Bold", 0, gi_2556, gi_2432);
               LABEL("DOUBLER_SELL_2_ON", "[Doubler] Sell BEP @ " + DoubleToStr(gd_1708 + gi_684 * gd_2360, Digits) + " Order " + gi_1500 + " of " + gi_720, "Arial Bold", 0, gi_2560, gi_2432);
            } else {
               ObjectDelete("DOUBLER_SELL_ON");
               ObjectDelete("DOUBLER_SELL_2_ON");
               LABEL("DOUBLER_SELL_OFF", "[Doubler] Sell " + DoubleToStr(gd_1456, 2) + " lots @ " + DoubleToStr(gd_1440, Digits) + " SL: " + DoubleToStr(gd_1636, Digits) + " TP: " +
                  DoubleToStr(gd_1620, Digits), "Arial Bold", 0, gi_2556, gi_2456);
               LABEL("DOUBLER_SELL_2_OFF", "[Doubler] Sell BEP @ " + DoubleToStr(gd_1424, Digits) + " Order " + gi_1500 + " of " + gi_720, "Arial Bold", 0, gi_2560, gi_2456);
            }
         } else LABEL("DOUBLER_", "Doubler is OFF", "Arial Bold", 0, gi_2540, gi_2456);
         if (gi_1520 == FALSE) {
            if (djcal(gs_eurusd_2392) && djcal(gs_gbpusd_2400) && djcal(gs_eurgbp_2408)) {
               gi_1576 = TRUE;
               gi_1520 = TRUE;
            }
         }
         if (gi_1524 == FALSE) {
            if (sjcal(gs_eurusd_2392) || sjcal(gs_gbpusd_2400) || sjcal(gs_eurgbp_2408)) {
               gi_unused_1552 = 1;
               gi_1524 = TRUE;
            }
         }
         if (gi_1532 == FALSE) {
            if (sjminlot(gs_eurusd_2392) && sjminlot(gs_gbpusd_2400)) {
               gi_unused_1560 = 1;
               gi_1532 = TRUE;
            }
         }
         if (gi_1528 == FALSE) {
            if (sjcal2(gs_eurusd_2392) || sjcal2(gs_gbpusd_2400)) {
               gi_unused_1556 = 1;
               gi_1528 = TRUE;
            }
         }
         if (gi_1536 == FALSE) {
            if (sjminlot2(gs_eurusd_2392) && sjminlot2(gs_gbpusd_2400)) {
               gi_unused_1564 = 1;
               gi_1536 = TRUE;
            }
         }
         if (gi_1540 == FALSE) {
            if (sjcal3(gs_eurusd_2392) && sjcal3(gs_gbpusd_2400)) {
               gi_1568 = TRUE;
               gi_1540 = TRUE;
            }
         }
         if (gi_1544 == FALSE) {
            if (frz(gs_eurusd_2392) && frz(gs_gbpusd_2400)) {
               gi_1572 = TRUE;
               gi_1544 = TRUE;
            }
         }
         if (gi_1548 == 0) {
            if (gi_1568 && gi_1572) gi_1548 = 1;
            else gi_1548 = 2;
         }
         if (StrToTime(StartEATime) > TimeLocal()) LABEL("START_TIME_", "[Time] Start " + StartEATime, "Arial Bold", 0, gi_2564, gi_2432);
         else LABEL("START_TIME_", "[Time] Start " + StartEATime, "Arial Bold", 0, gi_2564, gi_2456);
         if (StrToTime(EndEATime) > TimeLocal()) LABEL("END_TIME_", " End " + EndEATime, "Arial Bold", 180, gi_2564, gi_2432);
         else LABEL("END_TIME_", " End " + EndEATime, "Arial Bold", 180, gi_2564, gi_2456);
         if (gi_412 == FALSE) {
            if (Hedging == TRUE || gi_320 == TRUE) {
               if (StrToTime(StopLoopTime) > TimeLocal()) LABEL("STOP_LOOP_TIME_", "[Loop End Time] " + StopLoopTime, "Arial Bold", 0, gi_2568, gi_2432);
               else LABEL("STOP_LOOP_TIME_", "[Loop End] " + StopLoopTime, "Arial Bold", 0, gi_2568, gi_2456);
            }
         } else LABEL("STOP_LOOP_TIME_", "[Loop End] " + StopLoopTime, "Arial Bold", 0, gi_2568, gi_2456);
      }
      if (gi_1548 <= 0) return (0);
      if (CloseAll == TRUE) {
         gi_756 = FALSE;
         CloseAll();
         CloseAll = FALSE;
         gs_1908 = "Manual";
         break;
      }
      if (StopLoss < 0) StopLoss = 0;
      if (TimeLimit == TRUE)
         if (EALoop != 0) EALoop = 0;
      if (gi_776 == TRUE) {
         gi_756 = FALSE;
         break;
      }
      if (gi_756 == TRUE) {
         if (StopLoopTime > "0" && TimeLocal() > StrToTime(StopLoopTime))
            if (EALoop > 0 && gi_876 != EALoop) gi_876 = EALoop;
         if (MaxLevelAllowed > 0) {
            if (gi_320 == TRUE) {
               if (gi_2028 > gi_2032) {
                  if (gi_2028 > MaxLevelAllowed) {
                     CloseAll();
                     gs_1908 = "MaxLevelAllowed " + MaxLevelAllowed;
                  }
               }
               if (gi_2032 > gi_2028) {
                  if (gi_2032 > MaxLevelAllowed) {
                     CloseAll();
                     gs_1908 = "MaxLevelAllowed " + MaxLevelAllowed;
                  }
               }
            } else {
               if (gi_880 > MaxLevelAllowed) {
                  CloseAll();
                  gs_1908 = "MaxLevelAllowed " + MaxLevelAllowed;
               }
            }
         }
         if (LevelStopOpen > 0) {
            if (Hedging == TRUE)
               if (BuyOpen() + SellOpen() >= LevelStopOpen) gi_796 = TRUE;
         }
         if (MaxRiskPercentage > 0.0) {
            gd_1644 = 100.0 * (AccountProfit() / AccountBalance());
            if (gd_1644 <= -MaxRiskPercentage) {
               CloseAll();
               gs_1908 = "MaxRiskPercentage " + DoubleToStr(MaxRiskPercentage, 2) + " %";
            }
         }
         if (MaxLoss > 0.0) {
            if (AccountProfit() <= -MaxLoss) {
               CloseAll();
               gs_1908 = "MaxLoss -" + DoubleToStr(MaxLoss, 2);
            }
         }
         if (MaxProfit > 0.0) {
            gi_672 = TRUE;
            if (AccountProfit() >= MaxProfit && Multiplier != 0.1) {
               CloseAll();
               gs_1908 = "MaxProfit " + DoubleToStr(MaxProfit, 2);
            }
            if (Multiplier == 0.1) {
               if (NormalizeDouble(BuyLots(), 2) > NormalizeDouble(SellLots(), 2)) {
                  gd_1392 = (BuyLots() - SellLots()) / g_lots_2104 * MaxProfit;
                  if (AccountProfit() >= gd_1392) {
                     CloseAll();
                     gs_1908 = "MaxProfit " + DoubleToStr(MaxProfit, 2);
                  }
               }
               if (NormalizeDouble(SellLots(), 2) > NormalizeDouble(BuyLots(), 2)) {
                  gd_1400 = (SellLots() - BuyLots()) / g_lots_2104 * MaxProfit;
                  if (AccountProfit() >= gd_1400) {
                     CloseAll();
                     gs_1908 = "MaxProfit " + DoubleToStr(MaxProfit, 2);
                  }
               }
            }
         }
         if (gi_764 == TRUE) {
            if (gi_1512 == FALSE) {
               if (BuyOrders() + SellOrders() > 0) CancelPending();
               gi_1512 = TRUE;
            }
            if (gi_492 == FALSE) {
               if (gi_412 == FALSE) {
                  if (Hedging == TRUE) {
                     if (TimeLimit == TRUE)
                        if (Scalper_IsTradeTime() > 0) FirstOrder();
                     if (TimeLimit == FALSE) FirstOrder();
                  }
                  if (Hedging == FALSE && gi_320 == FALSE && gi_368 == FALSE) FirstOrder();
                  if (gi_368 == TRUE) {
                     gi_764 = FALSE;
                     gi_760 = TRUE;
                  }
                  if (gi_320 == TRUE && gi_352 == FALSE) FirstOrder();
                  if (gi_320 == TRUE && gi_352 == TRUE) {
                     if (BuyOpen() + SellOpen() <= 0) {
                        gi_2244 = TRUE;
                        if (gd_2080 > gi_356) {
                           if (g_high_1756 == 0.0) g_high_1756 = MarketInfo(Symbol(), MODE_HIGH);
                           if (g_low_1764 == 0.0) g_low_1764 = MarketInfo(Symbol(), MODE_LOW);
                           g_price_1748 = g_high_1756 + gi_360 * gd_2360 + gd_2344;
                           g_price_1740 = g_low_1764 - gi_360 * gd_2360 - gd_2344;
                           if (BuyOrders() < 1) {
                              if (OrderSend(Symbol(), OP_BUYLIMIT, g_lots_2104, g_price_1740, 3, 0, 0, g_comment_304, 0, 0, CLR_NONE) < 0) {
                                 g_price_1740 -= gd_2360;
                                 Print("Error HiLow Buy Limit = ", ErrorDescription(GetLastError()));
                              }
                           }
                           if (SellOrders() < 1) {
                              if (OrderSend(Symbol(), OP_SELLLIMIT, g_lots_2104, g_price_1748, 3, 0, 0, g_comment_304, 0, 0, CLR_NONE) < 0) {
                                 g_price_1748 += gd_2360;
                                 Print("Error HiLow Sell Limit = ", ErrorDescription(GetLastError()));
                              }
                           }
                           for (g_pos_872 = 0; g_pos_872 < OrdersTotal(); g_pos_872++) {
                              if (OrderSelect(g_pos_872, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
                                 if (OrderType() == OP_BUYLIMIT && OrderMagicNumber() != g_magic_1916) g_ord_open_price_1772 = OrderOpenPrice();
                                 if (OrderType() == OP_SELLLIMIT && OrderMagicNumber() != g_magic_1916) g_ord_open_price_1780 = OrderOpenPrice();
                              }
                           }
                        }
                     }
                     if (BuyOpen() + SellOpen() > 0) {
                        if (BuyOrders() > 0 || SellOrders() > 0) CancelPending();
                        if (ObjectsTotal() > 0) ObjectsDeleteAll();
                        gi_764 = FALSE;
                        gi_760 = TRUE;
                     }
                  }
               }
               if (gi_412 == TRUE) {
                  gi_764 = FALSE;
                  gi_760 = TRUE;
               }
            }
         }
         if (gi_412 == FALSE) {
            if (BuyLots() + SellLots() > 0.0) {
               if (BuyLots() == SellLots()) {
                  gi_unused_800 = FALSE;
                  for (g_pos_872 = 0; g_pos_872 < OrdersTotal(); g_pos_872++) {
                     if (OrderMagicNumber() != g_magic_1916) {
                        if (OrderSelect(g_pos_872, SELECT_BY_POS, MODE_TRADES)) {
                           if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) {
                              g_ord_open_price_2088 = OrderOpenPrice();
                              if (MarketInfo(Symbol(), MODE_BID) - g_ord_open_price_2088 >= CloseWhileHedgingProfit * gd_2360) {
                                 RefreshRates();
                                 if (OrderClose(OrderTicket(), OrderLots(), MarketInfo(Symbol(), MODE_BID), 3, CLR_NONE) > 0) Print("Buy Hedging Position Eliminated");
                                 else Print("Error Closing Buy Hedging = ", ErrorDescription(GetLastError()));
                              }
                           }
                           if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) {
                              g_ord_open_price_2096 = OrderOpenPrice();
                              if (g_ord_open_price_2096 - MarketInfo(Symbol(), MODE_ASK) >= CloseWhileHedgingProfit * gd_2360) {
                                 RefreshRates();
                                 if (OrderClose(OrderTicket(), OrderLots(), MarketInfo(Symbol(), MODE_ASK), 3, CLR_NONE) > 0) Print("Sell Hedging Position Eliminated");
                                 else Print("Error Closing Sell Hedging = ", ErrorDescription(GetLastError()));
                              }
                           }
                        }
                     }
                  }
               } else gi_unused_800 = TRUE;
            }
         }
         if (gi_760 == TRUE) {
            CheckOrder();
            if (gi_2248 == TRUE) {
               if (gi_412 == FALSE && gi_368 == FALSE) {
                  if (increase <= 0) increase = 0;
                  if (increase > 0 && IncreaseEndLevel <= IncreaseStartLevel) IncreaseEndLevel = 0;
                  if (increase > 0 && IncreaseStartLevel < 1) IncreaseStartLevel = 1;
               }
               if (gi_1860 == FALSE) {
                  if (DCalc(gs_eurusd_812) && DCalc(gs_gbpusd_820) && DCalc(gs_eurgbp_828)) {
                     gi_1828 = TRUE;
                     gi_1860 = TRUE;
                  }
               }
               if (gi_1864 == FALSE) {
                  if (SCalc(gs_eurusd_812) || SCalc(gs_gbpusd_820) || SCalc(gs_eurgbp_828)) {
                     gi_unused_1832 = 1;
                     gi_1864 = TRUE;
                  }
               }
               if (gi_1868 == FALSE) {
                  if (SCalc2(gs_eurusd_812) || SCalc2(gs_gbpusd_820)) {
                     gi_unused_1836 = 1;
                     gi_1868 = TRUE;
                  }
               }
               if (gi_1872 == FALSE) {
                  if (SCalc3(gs_eurusd_812) || SCalc3(gs_gbpusd_820)) {
                     gi_1840 = TRUE;
                     gi_1872 = TRUE;
                  }
               }
               if (gi_1876 == FALSE) {
                  if (FrzCalc(gs_eurusd_812) || FrzCalc(gs_gbpusd_820)) {
                     gi_1844 = TRUE;
                     gi_1876 = TRUE;
                  }
               }
               if (gi_2224 == 0) {
                  if (gi_1840 && gi_1844) gi_2224 = 1;
                  else gi_2224 = 3;
               }
               if (Hedging == FALSE && gi_320 == FALSE && gi_412 == FALSE && gi_368 == FALSE) {
                  gi_880 = BuyOpen() + SellOpen();
                  for (g_pos_872 = 0; g_pos_872 < OrdersTotal(); g_pos_872++) {
                     if (OrderSelect(g_pos_872, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
                        if (OrderMagicNumber() != g_magic_1916) {
                           if (OrderType() == OP_BUY) {
                              gd_2264 += OrderLots();
                              g_ord_open_price_2256 = OrderOpenPrice();
                           }
                           if (OrderType() == OP_SELL) {
                              gd_2304 += OrderLots();
                              g_ord_open_price_2296 = OrderOpenPrice();
                           }
                           if (OrderType() == OP_BUYSTOP) gd_2272 += OrderLots();
                           if (OrderType() == OP_SELLSTOP) gd_2312 += OrderLots();
                        }
                     }
                  }
                  if (gi_2224 <= 0) return (0);
                  if (TakeProfit <= 0) {
                     g_price_2288 = 0;
                     g_price_2328 = 0;
                  }
                  if (TakeProfit > 0) {
                     g_price_2288 = g_ord_open_price_2256 + TakeProfit * gd_2360;
                     g_price_2328 = g_ord_open_price_2296 - TakeProfit * gd_2360;
                  }
                  if (StopLoss > 0) {
                     g_price_2280 = g_ord_open_price_2256 - StopLoss * gd_2360;
                     g_price_2320 = g_ord_open_price_2296 + StopLoss * gd_2360;
                  }
                  for (g_pos_872 = 0; g_pos_872 < OrdersTotal(); g_pos_872++) {
                     if (OrderSelect(g_pos_872, SELECT_BY_POS)) {
                        if (OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_1916) {
                           if (OrderType() == OP_BUY) {
                              if (!IsEqual(OrderTakeProfit(), g_price_2288) || !IsEqual(OrderStopLoss(), g_price_2280)) {
                                 if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2280, g_price_2288, 0, CLR_NONE)) {
                                 }
                              }
                           }
                           if (OrderType() == OP_SELL) {
                              if (!IsEqual(OrderTakeProfit(), g_price_2328) || !IsEqual(OrderStopLoss(), g_price_2320)) {
                                 if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2320, g_price_2328, 0, CLR_NONE)) {
                                 }
                              }
                           }
                           if (OrderType() == OP_BUYSTOP) {
                              if (SellOpen() < 1) OrderDelete(OrderTicket());
                              if (!IsEqual(OrderTakeProfit(), g_price_2288) || !IsEqual(OrderStopLoss(), g_price_2280)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2280, g_price_2288, 0, CLR_NONE);
                           }
                           if (OrderType() == OP_SELLSTOP) {
                              if (BuyOpen() < 1) OrderDelete(OrderTicket());
                              if (!IsEqual(OrderTakeProfit(), g_price_2328) || !IsEqual(OrderStopLoss(), g_price_2320)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2320, g_price_2328, 0, CLR_NONE);
                           }
                        }
                     }
                  }
               }
               if (Hedging == TRUE) {
                  if (gi_1548 == gi_2232 && gi_880 > gi_2136) CheckPos();
                  if (BuyOpen() + SellOpen() > 0) gi_880 = BuyOpen() + SellOpen();
                  if (gi_796 == FALSE) {
                     for (g_pos_872 = 0; g_pos_872 < OrdersTotal(); g_pos_872++) {
                        if (OrderSelect(g_pos_872, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
                           if (OrderMagicNumber() != g_magic_1916) {
                              if (OrderType() == OP_BUY) {
                                 gd_2264 += OrderLots();
                                 g_ord_open_price_2256 = OrderOpenPrice();
                                 g_ord_lots_904 = OrderLots();
                              }
                              if (OrderType() == OP_SELL) {
                                 gd_2304 += OrderLots();
                                 g_ord_open_price_2296 = OrderOpenPrice();
                                 g_ord_lots_912 = OrderLots();
                              }
                              if (OrderType() == OP_BUYSTOP) gd_2272 += OrderLots();
                              if (OrderType() == OP_SELLSTOP) gd_2312 += OrderLots();
                           }
                        }
                     }
                     if (gi_2224 <= 0) return (0);
                     if (BuyLots() > SellLots()) {
                        if (Multiplier == 0.0) g_lots_2336 = 2.0 * BuyLots() - SellLots();
                        if (Multiplier == 1.0) g_lots_2336 = g_ord_lots_904 + BasicLot();
                        if (Multiplier > 0.0 && Multiplier != 1.0 && Multiplier != 0.1) {
                           gd_2216 = g_ord_lots_904 * Multiplier;
                           g_lots_2336 = MathRound(gd_2216 / MarketInfo(Symbol(), MODE_LOTSTEP)) * MarketInfo(Symbol(), MODE_LOTSTEP);
                        }
                        if (NormalizeDouble(g_lots_2336, 4) > NormalizeDouble(gd_2312, 4)) {
                           if (gd_1596 == 0.0) gd_1596 = gd_2264;
                           if (gd_1596 != gd_2264) {
                              gd_1596 = gd_2264;
                              CancelPending();
                           }
                           if (increase > 0) {
                              if (gi_880 >= IncreaseStartLevel) {
                                 if (IncreaseEndLevel == 0) gi_884 = gi_880 - IncreaseStartLevel + 1;
                                 if (IncreaseEndLevel > 0 && gi_880 <= IncreaseEndLevel) gi_884 = gi_880 - IncreaseStartLevel + 1;
                                 if (gd_1064 > 0.0) g_price_1724 = g_ord_open_price_2256 - HedgeGap * gd_2360 - 2.0 * gd_1064 - gi_884 * increase * gd_2360 - gd_2344;
                                 else g_price_1724 = g_ord_open_price_2256 - HedgeGap * gd_2360 - gi_884 * increase * gd_2360 - gd_2344;
                              }
                              if (gi_880 < IncreaseStartLevel) {
                                 if (gd_1064 > 0.0) g_price_1724 = g_ord_open_price_2256 - HedgeGap * gd_2360 - 2.0 * gd_1064 - gd_2344;
                                 else g_price_1724 = g_ord_open_price_2256 - HedgeGap * gd_2360 - gd_2344;
                              }
                           } else {
                              if (gd_1064 > 0.0) g_price_1724 = g_ord_open_price_2256 - HedgeGap * gd_2360 - 2.0 * gd_1064 - gd_2344;
                              else g_price_1724 = g_ord_open_price_2256 - HedgeGap * gd_2360 - gd_2344;
                           }
                           g_bid_936 = MarketInfo(Symbol(), MODE_BID);
                           if (g_bid_936 < g_price_1724) {
                              gd_928 = g_price_1724 - g_bid_936;
                              while (true) {
                                 g_price_1724 = Bid;
                                 g_ticket_804 = OrderSend(Symbol(), OP_SELL, g_lots_2336, g_price_1724, 3, 0, 0, g_comment_304, 0, 0, CLR_NONE);
                                 if (g_ticket_804 > -1) {
                                    Print("Sell Counter @ ", DoubleToStr(g_price_1724, Digits));
                                    break;
                                 }
                                 g_error_2252 = GetLastError();
                                 switch (g_error_2252) {
                                 case 135/* PRICE_CHANGED */:
                                    Print("The price has changed. Retrying..");
                                    RefreshRates();
                                    break;
                                 case 136/* OFF_QUOTES */:
                                    Print("No prices. Waiting for a new tick..");
                                    if (RefreshRates() != FALSE) break;
                                    while (true) {
                                       Sleep(1);
                                       if (RefreshRates() == FALSE) continue;
                                       break;
                                    }
                                    break;
                                 case 146/* TRADE_CONTEXT_BUSY */:
                                    Print("Trading subsystem is busy. Retrying..");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 2/* COMMON_ERROR */:
                                    Print("Common error");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 133/* TRADE_DISABLED */:
                                    Print("Trading is prohibited");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 64/* ACCOUNT_DISABLED */:
                                    Print("Account is blocked");
                                    break;
                                 default:
                                    Print("Error ", g_error_2252, " occured");
                                    Sleep(10);
                                    RefreshRates();
                                 }
                              }
                              if (GapAdjustment == TRUE) gd_1064 += gd_928;
                              else gd_1064 = 0;
                           }
                           if (g_bid_936 >= g_price_1724) {
                              while (true) {
                                 if (gi_1548 == gi_2232 && gi_880 > gi_2136 && gi_880 == gi_2136 + 1) g_ticket_804 = OrderSend(Symbol(), OP_SELL, g_lots_2336, Bid, 3, 0, 0, g_comment_304, 0, 0, CLR_NONE);
                                 else g_ticket_804 = OrderSend(Symbol(), OP_SELLSTOP, g_lots_2336, g_price_1724, 3, 0, 0, g_comment_304, 0, 0, CLR_NONE);
                                 if (g_ticket_804 > -1) {
                                    Print("Sell Stop Counter @ ", DoubleToStr(g_price_1724, Digits));
                                    break;
                                 }
                                 g_error_2252 = GetLastError();
                                 switch (g_error_2252) {
                                 case 135/* PRICE_CHANGED */:
                                    Print("The price has changed. Retrying..");
                                    RefreshRates();
                                    break;
                                 case 136/* OFF_QUOTES */:
                                    Print("No prices. Waiting for a new tick..");
                                    if (RefreshRates() != FALSE) break;
                                    while (true) {
                                       Sleep(1);
                                       if (RefreshRates() == FALSE) continue;
                                       break;
                                    }
                                    break;
                                 case 146/* TRADE_CONTEXT_BUSY */:
                                    Print("Trading subsystem is busy. Retrying..");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 2/* COMMON_ERROR */:
                                    Print("Common error");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 133/* TRADE_DISABLED */:
                                    Print("Trading is prohibited");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 64/* ACCOUNT_DISABLED */:
                                    Print("Account is blocked");
                                    break;
                                 default:
                                    Print("Error ", g_error_2252, " occured");
                                    Sleep(10);
                                    RefreshRates();
                                 }
                              }
                           }
                        }
                        if (NormalizeDouble(g_lots_2336, 4) < NormalizeDouble(gd_2312, 4)) CancelPending();
                     }
                     if (SellLots() > BuyLots()) {
                        if (Multiplier == 0.0) g_lots_2336 = 2.0 * SellLots() - BuyLots();
                        if (Multiplier == 1.0) g_lots_2336 = g_ord_lots_912 + BasicLot();
                        if (Multiplier > 0.0 && Multiplier != 1.0 && Multiplier != 0.1) {
                           gd_2216 = g_ord_lots_912 * Multiplier;
                           g_lots_2336 = MathRound(gd_2216 / MarketInfo(Symbol(), MODE_LOTSTEP)) * MarketInfo(Symbol(), MODE_LOTSTEP);
                        }
                        if (NormalizeDouble(g_lots_2336, 4) > NormalizeDouble(gd_2272, 4)) {
                           if (gd_1604 == 0.0) gd_1604 = gd_2304;
                           if (gd_1604 != gd_2304) {
                              gd_1604 = gd_2304;
                              CancelPending();
                           }
                           if (increase > 0) {
                              if (gi_880 >= IncreaseStartLevel) {
                                 if (IncreaseEndLevel == 0) gi_884 = gi_880 - IncreaseStartLevel + 1;
                                 if (IncreaseEndLevel > 0 && gi_880 <= IncreaseEndLevel) gi_884 = gi_880 - IncreaseStartLevel + 1;
                                 if (gd_1064 > 0.0) g_price_1716 = g_ord_open_price_2296 + HedgeGap * gd_2360 + 2.0 * gd_1064 + gi_884 * increase * gd_2360 + gd_2344;
                                 else g_price_1716 = g_ord_open_price_2296 + HedgeGap * gd_2360 + gi_884 * increase * gd_2360 + gd_2344;
                              }
                              if (gi_880 < IncreaseStartLevel) {
                                 if (gd_1064 > 0.0) g_price_1716 = g_ord_open_price_2296 + HedgeGap * gd_2360 + 2.0 * gd_1064 + gd_2344;
                                 else g_price_1716 = g_ord_open_price_2296 + HedgeGap * gd_2360 + gd_2344;
                              }
                           } else {
                              if (gd_1064 > 0.0) g_price_1716 = g_ord_open_price_2296 + HedgeGap * gd_2360 + 2.0 * gd_1064 + gd_2344;
                              else g_price_1716 = g_ord_open_price_2296 + HedgeGap * gd_2360 + gd_2344;
                           }
                           g_ask_944 = MarketInfo(Symbol(), MODE_ASK);
                           if (g_ask_944 > g_price_1716) {
                              gd_920 = g_ask_944 - g_price_1716;
                              while (true) {
                                 g_price_1716 = Ask;
                                 g_ticket_804 = OrderSend(Symbol(), OP_BUY, g_lots_2336, g_price_1716, 3, 0, 0, g_comment_304, 0, 0, CLR_NONE);
                                 if (g_ticket_804 > -1) {
                                    Print("Buy Counter @ ", DoubleToStr(g_price_1716, Digits));
                                    break;
                                 }
                                 g_error_2252 = GetLastError();
                                 switch (g_error_2252) {
                                 case 135/* PRICE_CHANGED */:
                                    Print("The price has changed. Retrying..");
                                    RefreshRates();
                                    break;
                                 case 136/* OFF_QUOTES */:
                                    Print("No prices. Waiting for a new tick..");
                                    if (RefreshRates() != FALSE) break;
                                    while (true) {
                                       Sleep(1);
                                       if (RefreshRates() == FALSE) continue;
                                       break;
                                    }
                                    break;
                                 case 146/* TRADE_CONTEXT_BUSY */:
                                    Print("Trading subsystem is busy. Retrying..");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 2/* COMMON_ERROR */:
                                    Print("Common error");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 133/* TRADE_DISABLED */:
                                    Print("Trading is prohibited");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 64/* ACCOUNT_DISABLED */:
                                    Print("Account is blocked");
                                    break;
                                 default:
                                    Print("Error ", g_error_2252, " occured");
                                    Sleep(10);
                                    RefreshRates();
                                 }
                              }
                              if (GapAdjustment == TRUE) gd_1064 += gd_920;
                              else gd_1064 = 0;
                           }
                           if (g_ask_944 <= g_price_1716) {
                              while (true) {
                                 if (gi_1548 == gi_2232 && gi_880 > gi_2136 && gi_880 == gi_2136 + 1) g_ticket_804 = OrderSend(Symbol(), OP_BUY, g_lots_2336, Ask, 3, 0, 0, g_comment_304, 0, 0, CLR_NONE);
                                 else g_ticket_804 = OrderSend(Symbol(), OP_BUYSTOP, g_lots_2336, g_price_1716, 3, 0, 0, g_comment_304, 0, 0, CLR_NONE);
                                 if (g_ticket_804 > -1) {
                                    Print("Buy Stop Counter @ ", DoubleToStr(g_price_1716, Digits));
                                    break;
                                 }
                                 g_error_2252 = GetLastError();
                                 switch (g_error_2252) {
                                 case 135/* PRICE_CHANGED */:
                                    Print("The price has changed. Retrying..");
                                    RefreshRates();
                                    break;
                                 case 136/* OFF_QUOTES */:
                                    Print("No prices. Waiting for a new tick..");
                                    if (RefreshRates() != FALSE) break;
                                    while (true) {
                                       Sleep(1);
                                       if (RefreshRates() == FALSE) continue;
                                       break;
                                    }
                                    break;
                                 case 146/* TRADE_CONTEXT_BUSY */:
                                    Print("Trading subsystem is busy. Retrying..");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 2/* COMMON_ERROR */:
                                    Print("Common error");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 133/* TRADE_DISABLED */:
                                    Print("Trading is prohibited");
                                    Sleep(300);
                                    RefreshRates();
                                    break;
                                 case 64/* ACCOUNT_DISABLED */:
                                    Print("Account is blocked");
                                    break;
                                 default:
                                    Print("Error ", g_error_2252, " occured");
                                    Sleep(10);
                                    RefreshRates();
                                 }
                              }
                           }
                        }
                        if (NormalizeDouble(g_lots_2336, 4) < NormalizeDouble(gd_2272, 4)) CancelPending();
                     }
                     for (int l_pos_24 = 0; l_pos_24 < OrdersTotal(); l_pos_24++) {
                        if (OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
                           if (OrderMagicNumber() != g_magic_1916) {
                              if (OrderType() == OP_BUYSTOP) {
                                 gd_2272 += OrderLots();
                                 g_ord_open_price_1464 = OrderOpenPrice();
                                 g_ord_lots_1580 = OrderLots();
                              }
                              if (OrderType() == OP_SELLSTOP) {
                                 gd_2312 += OrderLots();
                                 g_ord_open_price_1472 = OrderOpenPrice();
                                 g_ord_lots_1588 = OrderLots();
                              }
                           }
                        }
                     }
                     if (TakeProfit <= 0) {
                        g_price_2288 = 0;
                        g_price_2328 = 0;
                        g_price_2280 = 0;
                        g_price_2320 = 0;
                     }
                     if (TakeProfit > 0) {
                        if (GapAdjustment == FALSE) {
                           if (gd_920 > 0.0 || gd_928 > 0.0) {
                              if (g_price_2288 < LastOpenBuyPrice() + TakeProfit * gd_2360) {
                                 if (LastOpenBuyPrice() == 0.0) g_price_2288 = g_ord_open_price_2256 + TakeProfit * gd_2360;
                                 else g_price_2288 = LastOpenBuyPrice() + TakeProfit * gd_2360;
                              }
                              if (g_price_2328 == 0.0 || g_price_2328 > LastOpenSellPrice() - TakeProfit * gd_2360) {
                                 if (LastOpenSellPrice() == 0.0) g_price_2328 = g_ord_open_price_2296 - TakeProfit * gd_2360;
                                 else g_price_2328 = LastOpenSellPrice() - TakeProfit * gd_2360;
                              }
                              if (StopLoss == 0) {
                                 g_price_2280 = g_price_2328 - gd_2344;
                                 g_price_2320 = g_price_2288 + gd_2344;
                              }
                              if (StopLoss > 0) {
                                 g_price_2280 = g_ord_open_price_2256 - StopLoss * gd_2360;
                                 g_price_2320 = g_ord_open_price_2296 + StopLoss * gd_2360;
                              }
                           } else {
                              if (StopLoss == 0) {
                                 if (gd_2272 > gd_2312) {
                                    g_price_2288 = g_ord_open_price_1464 + TakeProfit * gd_2360;
                                    g_price_2328 = g_ord_open_price_2296 - TakeProfit * gd_2360;
                                    g_price_2280 = g_price_2328 - gd_2344;
                                    g_price_2320 = g_price_2288 + gd_2344;
                                 }
                                 if (gd_2312 > gd_2272) {
                                    g_price_2288 = g_ord_open_price_2256 + TakeProfit * gd_2360;
                                    g_price_2328 = g_ord_open_price_1472 - TakeProfit * gd_2360;
                                    g_price_2280 = g_price_2328 - gd_2344;
                                    g_price_2320 = g_price_2288 + gd_2344;
                                 }
                              }
                              if (StopLoss > 0) {
                                 if (gd_2272 > gd_2312) {
                                    g_price_2288 = g_ord_open_price_1464 + TakeProfit * gd_2360;
                                    g_price_2328 = g_ord_open_price_2296 - TakeProfit * gd_2360;
                                    g_price_2280 = g_ord_open_price_1464 - StopLoss * gd_2360;
                                    g_price_2320 = g_ord_open_price_2296 + StopLoss * gd_2360;
                                 }
                                 if (gd_2312 > gd_2272) {
                                    g_price_2288 = g_ord_open_price_2256 + TakeProfit * gd_2360;
                                    g_price_2328 = g_ord_open_price_1472 - TakeProfit * gd_2360;
                                    g_price_2280 = g_ord_open_price_2256 - StopLoss * gd_2360;
                                    g_price_2320 = g_ord_open_price_1472 + StopLoss * gd_2360;
                                 }
                              }
                           }
                        }
                        if (GapAdjustment == TRUE) {
                           if (StopLoss == 0) {
                              if (gd_2272 > gd_2312) {
                                 g_price_2288 = g_ord_open_price_1464 + TakeProfit * gd_2360;
                                 g_price_2328 = g_ord_open_price_2296 - TakeProfit * gd_2360;
                                 g_price_2280 = g_price_2328 - gd_2344;
                                 g_price_2320 = g_price_2288 + gd_2344;
                              }
                              if (gd_2312 > gd_2272) {
                                 g_price_2288 = g_ord_open_price_2256 + TakeProfit * gd_2360;
                                 g_price_2328 = g_ord_open_price_1472 - TakeProfit * gd_2360;
                                 g_price_2280 = g_price_2328 - gd_2344;
                                 g_price_2320 = g_price_2288 + gd_2344;
                              }
                           }
                           if (StopLoss > 0) {
                              if (gd_2272 > gd_2312) {
                                 g_price_2288 = g_ord_open_price_1464 + TakeProfit * gd_2360;
                                 g_price_2328 = g_ord_open_price_2296 - TakeProfit * gd_2360;
                                 g_price_2280 = g_ord_open_price_1464 - StopLoss * gd_2360;
                                 g_price_2320 = g_ord_open_price_2296 + StopLoss * gd_2360;
                              }
                              if (gd_2312 > gd_2272) {
                                 g_price_2288 = g_ord_open_price_2256 + TakeProfit * gd_2360;
                                 g_price_2328 = g_ord_open_price_1472 - TakeProfit * gd_2360;
                                 g_price_2280 = g_ord_open_price_2256 - StopLoss * gd_2360;
                                 g_price_2320 = g_ord_open_price_1472 + StopLoss * gd_2360;
                              }
                           }
                        }
                     }
                     if (OrderMagicNumber() != g_magic_1916) {
                        for (g_pos_872 = 0; g_pos_872 < OrdersTotal(); g_pos_872++) {
                           if (OrderSelect(g_pos_872, SELECT_BY_POS)) {
                              if (OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_1916) {
                                 if (OrderType() == OP_BUY) {
                                    if (!IsEqual(OrderTakeProfit(), g_price_2288) || !IsEqual(OrderStopLoss(), g_price_2280)) {
                                       if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2280, g_price_2288, 0, CLR_NONE)) {
                                       }
                                    }
                                 }
                                 if (OrderType() == OP_SELL) {
                                    if (!IsEqual(OrderTakeProfit(), g_price_2328) || !IsEqual(OrderStopLoss(), g_price_2320)) {
                                       if (OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2320, g_price_2328, 0, CLR_NONE)) {
                                       }
                                    }
                                 }
                                 if (OrderType() == OP_BUYSTOP)
                                    if (!IsEqual(OrderTakeProfit(), g_price_2288) || !IsEqual(OrderStopLoss(), g_price_2280)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2280, g_price_2288, 0, CLR_NONE);
                                 if (OrderType() == OP_SELLSTOP)
                                    if (!IsEqual(OrderTakeProfit(), g_price_2328) || !IsEqual(OrderStopLoss(), g_price_2320)) OrderModify(OrderTicket(), OrderOpenPrice(), g_price_2320, g_price_2328, 0, CLR_NONE);
                              }
                           }
                        }
                     }
                  }
               }
               if (gi_672 == FALSE) {
                  if (gi_860 != gi_880) {
                     gi_860 = gi_880;
                     if (TrailingStop > 0) {
                        g_bid_1072 = 0;
                        gd_984 = 0;
                        gd_1032 = 0;
                        gd_968 = 0;
                        g_bid_952 = 0;
                        g_ask_1080 = 0;
                        gd_992 = 0;
                        gd_1040 = 0;
                        gd_976 = 0;
                        g_ask_960 = 0;
                     }
                     if (TrailingStop_2 > 0) {
                        g_bid_1088 = 0;
                        gd_1104 = 0;
                        gd_1096 = 0;
                        gd_1120 = 0;
                        g_bid_1112 = 0;
                        g_ask_1128 = 0;
                        gd_1144 = 0;
                        gd_1136 = 0;
                        gd_1160 = 0;
                        g_ask_1152 = 0;
                     }
                     if (TrailingStop_3 > 0) {
                        g_bid_1168 = 0;
                        gd_1184 = 0;
                        gd_1176 = 0;
                        gd_1200 = 0;
                        g_bid_1192 = 0;
                        g_ask_1208 = 0;
                        gd_1224 = 0;
                        gd_1216 = 0;
                        gd_1240 = 0;
                        g_ask_1232 = 0;
                     }
                     if (gi_604 > 0) {
                        gd_1248 = 0;
                        gd_unused_1264 = 0;
                        gd_1256 = 0;
                        gd_1280 = 0;
                        gd_unused_1272 = 0;
                        gd_1288 = 0;
                        gd_unused_1304 = 0;
                        gd_1296 = 0;
                        gd_1320 = 0;
                        gd_unused_1312 = 0;
                     }
                     if (Start_Safer) {
                        g_bid_1328 = 0;
                        gd_1336 = 0;
                        gd_1344 = 0;
                        gd_unused_1352 = 0;
                        g_ask_1360 = 0;
                        gd_1368 = 0;
                        gd_1376 = 0;
                        gd_unused_1384 = 0;
                     }
                  }
                  if (TrailingStop > 0)
                     if (TrailingStopEndLevel <= TrailingStopStartLevel) TrailingStopEndLevel = 0;
                  if (TrailingStop > 0)
                     if (TrailingStopStartLevel < 1) TrailingStopStartLevel = 1;
                  if (TrailingStop_2 > 0)
                     if (TrailingStop_2_EndLevel <= TrailingStop_2_StartLevel) TrailingStop_2_EndLevel = 0;
                  if (TrailingStop_2 > 0)
                     if (TrailingStop_2_StartLevel < 1) TrailingStop_2_StartLevel = 1;
                  if (TrailingStop_3 > 0)
                     if (TrailingStop_3_EndLevel <= TrailingStop_3_StartLevel) TrailingStop_3_EndLevel = 0;
                  if (TrailingStop_3 > 0)
                     if (TrailingStop_3_StartLevel < 1) TrailingStop_3_StartLevel = 1;
                  if (gi_604 > 0)
                     if (gi_612 <= gi_608) gi_612 = 0;
                  if (gi_604 > 0)
                     if (gi_608 < 1) gi_608 = 1;
                  if (Start_Safer)
                     if (Safer_EndLevel <= Safer_StartLevel) Safer_EndLevel = 0;
                  if (Start_Safer)
                     if (Safer_StartLevel < 1) Safer_StartLevel = 1;
                  if (BuyLots() > SellLots()) {
                     if (gi_320 == TRUE) gi_880 = gi_2028;
                     for (g_pos_872 = 0; g_pos_872 < OrdersTotal(); g_pos_872++) {
                        if (OrderSelect(g_pos_872, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
                           if (OrderType() == OP_BUY && OrderMagicNumber() != g_magic_1916) {
                              if (TrailingStop > 0) {
                                 if (gi_880 >= TrailingStopStartLevel) {
                                    if (TrailingStopEndLevel == 0 || gi_880 < TrailingStopEndLevel) {
                                       if (AccountProfit() >= 0.0) {
                                          if (g_bid_1072 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1072) g_bid_1072 = MarketInfo(Symbol(), MODE_BID);
                                          if (MarketInfo(Symbol(), MODE_BID) - g_bid_1072 >= TrailingStop * gd_2360) {
                                             gd_984 = MarketInfo(Symbol(), MODE_BID) - TrailingStop * gd_2360;
                                             if (gd_1032 < gd_984) gd_1032 = gd_984;
                                          }
                                          if (gd_1032 > 0.0) {
                                             if (MarketInfo(Symbol(), MODE_BID) > g_bid_952) {
                                                g_bid_952 = MarketInfo(Symbol(), MODE_BID);
                                                if (Rebound > 0) gd_968 = g_bid_952 - Rebound * gd_2360;
                                             }
                                             if (MarketInfo(Symbol(), MODE_BID) < gd_1032 || MarketInfo(Symbol(), MODE_BID) < gd_968) {
                                                CloseAll();
                                                gs_1908 = "Trailing Stop Buy";
                                             }
                                          }
                                       }
                                       if (AccountProfit() < 0.0) {
                                          g_bid_1072 = 0;
                                          gd_1032 = 0;
                                          gd_968 = 0;
                                          g_bid_952 = 0;
                                       }
                                    }
                                 }
                              }
                           }
                           if (TrailingStop_2 > 0) {
                              if (gi_880 >= TrailingStop_2_StartLevel) {
                                 if (TrailingStop_2_EndLevel == 0 || gi_880 < TrailingStop_2_EndLevel) {
                                    if (AccountProfit() >= 0.0) {
                                       if (g_bid_1088 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1088) g_bid_1088 = MarketInfo(Symbol(), MODE_BID);
                                       if (MarketInfo(Symbol(), MODE_BID) - g_bid_1088 >= TrailingStop_2 * gd_2360) {
                                          gd_1104 = MarketInfo(Symbol(), MODE_BID) - TrailingStop_2 * gd_2360;
                                          if (gd_1096 < gd_1104) gd_1096 = gd_1104;
                                       }
                                       if (gd_1096 > 0.0) {
                                          if (MarketInfo(Symbol(), MODE_BID) > g_bid_1112) {
                                             g_bid_1112 = MarketInfo(Symbol(), MODE_BID);
                                             if (Rebound_2 > 0) gd_1120 = g_bid_1112 - Rebound_2 * gd_2360;
                                          }
                                          if (MarketInfo(Symbol(), MODE_BID) < gd_1096 || MarketInfo(Symbol(), MODE_BID) < gd_1120) {
                                             CloseAll();
                                             gs_1908 = "Trailing Stop Buy 2";
                                          }
                                       }
                                    }
                                    if (AccountProfit() < 0.0) {
                                       g_bid_1088 = 0;
                                       gd_1096 = 0;
                                       gd_1120 = 0;
                                       g_bid_1112 = 0;
                                    }
                                 }
                              }
                           }
                           if (TrailingStop_3 > 0) {
                              if (gi_880 >= TrailingStop_3_StartLevel) {
                                 if (TrailingStop_3_EndLevel == 0 || gi_880 < TrailingStop_3_EndLevel) {
                                    if (AccountProfit() >= 0.0) {
                                       if (g_bid_1168 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1168) g_bid_1168 = MarketInfo(Symbol(), MODE_BID);
                                       if (MarketInfo(Symbol(), MODE_BID) - g_bid_1168 >= TrailingStop_3 * gd_2360) {
                                          gd_1184 = MarketInfo(Symbol(), MODE_BID) - TrailingStop_3 * gd_2360;
                                          if (gd_1176 < gd_1184) gd_1176 = gd_1184;
                                       }
                                       if (gd_1176 > 0.0) {
                                          if (MarketInfo(Symbol(), MODE_BID) > g_bid_1192) {
                                             g_bid_1192 = MarketInfo(Symbol(), MODE_BID);
                                             if (Rebound_3 > 0) gd_1200 = g_bid_1192 - Rebound_3 * gd_2360;
                                          }
                                          if (MarketInfo(Symbol(), MODE_BID) < gd_1176 || MarketInfo(Symbol(), MODE_BID) < gd_1200) {
                                             CloseAll();
                                             gs_1908 = "Trailing Stop Buy 3";
                                          }
                                       }
                                    }
                                    if (AccountProfit() < 0.0) {
                                       g_bid_1168 = 0;
                                       gd_1176 = 0;
                                       gd_1200 = 0;
                                       g_bid_1192 = 0;
                                    }
                                 }
                              }
                           }
                           if (Start_Safer) {
                              if (gi_880 >= Safer_StartLevel) {
                                 if (Safer_EndLevel == 0 || gi_880 < Safer_EndLevel) {
                                    if (Safer_Money_CutLoss > 0.0) {
                                       if (AccountProfit() >= -NormalizeDouble(Safer_Money_CutLoss, 2)) {
                                          CloseAll();
                                          gs_1908 = "Safer_Money_CutLoss Buy";
                                       }
                                    }
                                    if (AccountProfit() >= 0.0)
                                       if (g_bid_1328 == 0.0 || MarketInfo(Symbol(), MODE_BID) < g_bid_1328) g_bid_1328 = MarketInfo(Symbol(), MODE_BID);
                                    if (g_bid_1328 > 0.0) {
                                       if (Safer >= 0) {
                                          if (MarketInfo(Symbol(), MODE_BID) - g_bid_1328 >= Safer * gd_2360) {
                                             gd_1336 = MarketInfo(Symbol(), MODE_BID) - Safer * gd_2360;
                                             if (gd_1344 < gd_1336) gd_1344 = gd_1336;
                                          }
                                       }
                                       if (Safer < 0) {
                                          gd_1336 = g_bid_1328 + Safer * gd_2360;
                                          if (gd_1344 < gd_1336) gd_1344 = gd_1336;
                                       }
                                    }
                                    if (gd_1344 > 0.0) {
                                       if (MarketInfo(Symbol(), MODE_BID) < gd_1344) {
                                          CloseAll();
                                          gs_1908 = "Safer Buy";
                                       }
                                    }
                                    if (Safer > 0 && AccountProfit() < 0.0) g_bid_1328 = 0;
                                 }
                              }
                           }
                        }
                     }
                  }
                  if (SellLots() > BuyLots()) {
                     if (gi_320 == TRUE) gi_880 = gi_2032;
                     for (g_pos_872 = 0; g_pos_872 < OrdersTotal(); g_pos_872++) {
                        if (OrderSelect(g_pos_872, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol()) {
                           if (OrderType() == OP_SELL && OrderMagicNumber() != g_magic_1916) {
                              if (TrailingStop > 0) {
                                 if (gi_880 >= TrailingStopStartLevel) {
                                    if (TrailingStopEndLevel == 0 || gi_880 < TrailingStopEndLevel) {
                                       if (AccountProfit() >= 0.0) {
                                          if (g_ask_1080 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1080) g_ask_1080 = MarketInfo(Symbol(), MODE_ASK);
                                          if (g_ask_1080 - MarketInfo(Symbol(), MODE_ASK) >= TrailingStop * gd_2360) {
                                             gd_992 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop * gd_2360;
                                             if (gd_1040 == 0.0 || gd_1040 > gd_992) gd_1040 = gd_992;
                                          }
                                          if (gd_1040 > 0.0) {
                                             if (g_ask_960 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < g_ask_960) {
                                                g_ask_960 = MarketInfo(Symbol(), MODE_ASK);
                                                if (Rebound > 0) gd_976 = g_ask_960 + Rebound * gd_2360;
                                             }
                                             if (MarketInfo(Symbol(), MODE_ASK) > gd_1040 || MarketInfo(Symbol(), MODE_ASK) > gd_976) {
                                                CloseAll();
                                                gs_1908 = "Trailing Stop Sell";
                                             }
                                          }
                                       }
                                       if (AccountProfit() < 0.0) {
                                          g_ask_1080 = 0;
                                          gd_1040 = 0;
                                          gd_976 = 0;
                                          g_ask_960 = 0;
                                       }
                                    }
                                 }
                              }
                           }
                           if (TrailingStop_2 > 0) {
                              if (gi_880 >= TrailingStop_2_StartLevel) {
                                 if (TrailingStop_2_EndLevel == 0 || gi_880 < TrailingStop_2_EndLevel) {
                                    if (AccountProfit() >= 0.0) {
                                       if (g_ask_1128 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1128) g_ask_1128 = MarketInfo(Symbol(), MODE_ASK);
                                       if (g_ask_1128 - MarketInfo(Symbol(), MODE_ASK) >= TrailingStop_2 * gd_2360) {
                                          gd_1144 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop_2 * gd_2360;
                                          if (gd_1136 == 0.0 || gd_1136 > gd_1144) gd_1136 = gd_1144;
                                       }
                                       if (gd_1136 > 0.0) {
                                          if (g_ask_1152 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < g_ask_1152) {
                                             g_ask_1152 = MarketInfo(Symbol(), MODE_ASK);
                                             if (Rebound_2 > 0) gd_1160 = g_ask_1152 + Rebound_2 * gd_2360;
                                          }
                                          if (MarketInfo(Symbol(), MODE_ASK) > gd_1136 || MarketInfo(Symbol(), MODE_ASK) > gd_1160) {
                                             CloseAll();
                                             gs_1908 = "Trailing Stop Sell 2";
                                          }
                                       }
                                    }
                                    if (AccountProfit() < 0.0) {
                                       g_ask_1128 = 0;
                                       gd_1136 = 0;
                                       gd_1160 = 0;
                                       g_ask_1152 = 0;
                                    }
                                 }
                              }
                           }
                           if (TrailingStop_3 > 0) {
                              if (gi_880 >= TrailingStop_3_StartLevel) {
                                 if (TrailingStop_3_EndLevel == 0 || gi_880 < TrailingStop_3_EndLevel) {
                                    if (AccountProfit() >= 0.0) {
                                       if (g_ask_1208 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1208) g_ask_1208 = MarketInfo(Symbol(), MODE_ASK);
                                       if (g_ask_1208 - MarketInfo(Symbol(), MODE_ASK) >= TrailingStop_3 * gd_2360) {
                                          gd_1224 = MarketInfo(Symbol(), MODE_ASK) + TrailingStop_3 * gd_2360;
                                          if (gd_1216 == 0.0 || gd_1216 > gd_1224) gd_1216 = gd_1224;
                                       }
                                       if (gd_1216 > 0.0) {
                                          if (g_ask_1232 == 0.0 || MarketInfo(Symbol(), MODE_ASK) < g_ask_1232) {
                                             g_ask_1232 = MarketInfo(Symbol(), MODE_ASK);
                                             if (Rebound_3 > 0) gd_1240 = g_ask_1232 + Rebound_3 * gd_2360;
                                          }
                                          if (MarketInfo(Symbol(), MODE_ASK) > gd_1216 || MarketInfo(Symbol(), MODE_ASK) > gd_1240) {
                                             CloseAll();
                                             gs_1908 = "Trailing Stop Sell 3";
                                          }
                                       }
                                    }
                                    if (AccountProfit() < 0.0) {
                                       g_ask_1208 = 0;
                                       gd_1216 = 0;
                                       gd_1240 = 0;
                                       g_ask_1232 = 0;
                                    }
                                 }
                              }
                           }
                           if (Start_Safer) {
                              if (gi_880 >= Safer_StartLevel) {
                                 if (Safer_EndLevel == 0 || gi_880 < Safer_EndLevel) {
                                    if (Safer_Money_CutLoss > 0.0) {
                                       if (AccountProfit() >= -NormalizeDouble(Safer_Money_CutLoss, 2)) {
                                          CloseAll();
                                          gs_1908 = "Safer_Money_CutLoss Sell";
                                       }
                                    }
                                    if (AccountProfit() >= 0.0)
                                       if (g_ask_1360 == 0.0 || MarketInfo(Symbol(), MODE_ASK) > g_ask_1360) g_ask_1360 = MarketInfo(Symbol(), MODE_ASK);
                                    if (g_ask_1360 > 0.0) {
                                       if (Safer >= 0) {
                                          if (g_ask_1360 - MarketInfo(Symbol(), MODE_ASK) >= Safer * gd_2360) {
                                             gd_1368 = MarketInfo(Symbol(), MODE_ASK) + Safer * gd_2360;
                                             if (gd_1376 == 0.0 || gd_1376 > gd_1368) gd_1376 = gd_1368;
                                          }
                                       }
                                       if (Safer < 0) {
                                          gd_1368 = g_ask_1360 - Safer * gd_2360;
                                          if (gd_1376 == 0.0 || gd_1376 > gd_1368) gd_1376 = gd_1368;
                                       }
                                    }
                                    if (gd_1376 > 0.0) {
                                       if (MarketInfo(Symbol(), MODE_ASK) > gd_1376) {
                                          CloseAll();
                                          gs_1908 = "Safer Sell";
                                       }
                                    }
                                    if (Safer > 0 && AccountProfit() < 0.0) g_ask_1360 = 0;
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
            if (BuyLots() + SellLots() > 0.0) LABEL("ACTIVEORDERS_", "Active: " + gi_856, "Arial Bold", 270, gi_2476, gi_2420);
            else LABEL("ACTIVEORDERS_", "Total Active: " + gi_856, "Arial Bold", 270, gi_2476, gi_2456);
            gs_2376 = "";
            gs_2384 = "";
            if (BuyLots() > 0.0) {
               gs_2376 = " lots @" + DoubleToStr(g_ord_open_price_2256, Digits) + " TP: " + DoubleToStr(g_price_2288, Digits) + " SL: " + DoubleToStr(g_price_2280, Digits);
               LABEL("BUY_", "Active Buy: " + DoubleToStr(gd_2264, 2) + gs_2376, "Arial Bold", 0, gi_2480, gi_2424);
            } else LABEL("BUY_", "Active Buy: " + DoubleToStr(gd_2264, 2) + gs_2376, "Arial Bold", 0, gi_2480, gi_2456);
            if (SellLots() > 0.0) {
               gs_2384 = " lots @" + DoubleToStr(g_ord_open_price_2296, Digits) + " TP: " + DoubleToStr(g_price_2328, Digits) + " SL: " + DoubleToStr(g_price_2320, Digits);
               LABEL("SELL_", "Active Sell: " + DoubleToStr(gd_2304, 2) + gs_2384, "Arial Bold", 0, gi_2484, gi_2432);
            } else LABEL("SELL_", "Active Sell: " + DoubleToStr(gd_2304, 2) + gs_2384, "Arial Bold", 0, gi_2484, gi_2456);
            if (gd_2272 > 0.0) {
               gs_1932 = "";
               gs_1932 = " lots @" + DoubleToStr(g_ord_open_price_1464, Digits) + " TP: " + DoubleToStr(g_price_2288, Digits) + " SL: " + DoubleToStr(g_price_2280, Digits);
               LABEL("PENDING_BUY", "Pending Buy Lots: " + DoubleToStr(g_ord_lots_1580, 2) + gs_1932, "Arial Bold", 0, gi_2488, gi_2416);
            } else ObjectDelete("PENDING_BUY");
            if (gd_2312 > 0.0) {
               gs_1940 = "";
               gs_1940 = " lots @" + DoubleToStr(g_ord_open_price_1472, Digits) + " TP: " + DoubleToStr(g_price_2328, Digits) + " SL: " + DoubleToStr(g_price_2320, Digits);
               LABEL("PENDING_SELL", "Pending Sell Lots: " + DoubleToStr(g_ord_lots_1588, 2) + gs_1940, "Arial Bold", 0, gi_2488, gi_2416);
            } else ObjectDelete("PENDING_SELL");
            if (gi_320 == TRUE || Hedging == TRUE) {
               if (EALoop > 0) LABEL("LOOP_", "Loop: " + gi_876 + " of " + EALoop, "Arial Bold", 350, gi_2500, gi_2444);
               else {
                  if (TimeLimit == TRUE) LABEL("LOOP_", "Loop: ON TLimit: " + gi_1804 + "-" + gi_1808 + " GMT", "Arial Bold", 350, gi_2500, gi_2444);
                  if (TimeLimit == FALSE) LABEL("LOOP_", "Loop: ON", "Arial Bold", 350, gi_2500, gi_2444);
               }
            } else ObjectDelete("LOOP_");
         }
      }
   }
   Sleep(100);
   return (0);
}

bool IsEqual(double ad_0, double ad_8) {
   if (NormalizeDouble(ad_0, Digits) == NormalizeDouble(ad_8, Digits)) return (TRUE);
   return (FALSE);
}

int Crossed(double ad_0, double ad_8) {
   if (ad_0 <= ad_8) gi_2576 = 1;
   if (ad_0 > ad_8) gi_2576 = 2;
   if (gi_2576 != gi_2572) gi_2572 = gi_2576;
   return (gi_2576);
}

int BuyOrders() {
   g_count_844 = 0;
   g_ord_total_868 = OrdersTotal();
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE) {
         if (OrderMagicNumber() != g_magic_1916 && OrderSymbol() == Symbol())
            if (OrderType() == OP_BUYSTOP || OrderType() == OP_BUYLIMIT) g_count_844++;
      }
   }
   return (g_count_844);
}

int djcal(string a_symbol_0) {
   int l_digits_8 = MarketInfo(a_symbol_0, MODE_DIGITS);
   if (l_digits_8 > 4 || l_digits_8 == 3) return (1);
   return (0);
}

int sjcal(string a_symbol_0) {
   int li_8 = MarketInfo(a_symbol_0, MODE_STOPLEVEL);
   if (gi_1576) li_8 = li_8 / 10.0;
   if (li_8 <= 5) return (1);
   return (0);
}

int sjminlot(string a_symbol_0) {
   double l_minlot_8 = MarketInfo(a_symbol_0, MODE_MINLOT);
   if (l_minlot_8 == 0.1) return (1);
   return (0);
}

int sjminlot2(string a_symbol_0) {
   double l_minlot_8 = MarketInfo(a_symbol_0, MODE_MINLOT);
   if (l_minlot_8 == 0.01) return (1);
   return (0);
}

int SellOrders() {
   g_count_848 = 0;
   g_ord_total_868 = OrdersTotal();
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE) {
         if (OrderMagicNumber() != g_magic_1916 && OrderSymbol() == Symbol())
            if (OrderType() == OP_SELLSTOP || OrderType() == OP_SELLLIMIT) g_count_848++;
      }
   }
   return (g_count_848);
}

int SellOpen() {
   int l_cmd_0;
   g_count_840 = 0;
   g_ord_total_868 = OrdersTotal();
   int l_cmd_4 = -1;
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS)) {
         if (OrderMagicNumber() != g_magic_1916) {
            l_cmd_0 = OrderType();
            if (l_cmd_0 == OP_SELL) {
               l_cmd_4 = l_cmd_0;
               if (l_cmd_4 != -1) g_count_840++;
            }
         }
      }
   }
   return (g_count_840);
}

int sjcal2(string as_unused_0) {
   int li_8 = MarketInfo(Symbol(), MODE_STOPLEVEL);
   if (gi_1576) li_8 = li_8 / 10.0;
   if (li_8 > 11) return (1);
   return (0);
}

int sjcal3(string a_symbol_0) {
   int li_8 = MarketInfo(a_symbol_0, MODE_STOPLEVEL);
   if (gi_1576) li_8 = li_8 / 10.0;
   if (li_8 == 10) return (1);
   return (0);
}

int frz(string as_unused_0) {
   int l_freezelevel_8 = MarketInfo(Symbol(), MODE_FREEZELEVEL);
   if (l_freezelevel_8 == 3) return (1);
   return (0);
}

int BuyOpen() {
   int l_cmd_0;
   g_count_836 = 0;
   g_ord_total_868 = OrdersTotal();
   int l_cmd_4 = -1;
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS)) {
         if (OrderMagicNumber() != g_magic_1916) {
            l_cmd_0 = OrderType();
            if (l_cmd_0 == OP_BUY) {
               l_cmd_4 = l_cmd_0;
               if (l_cmd_4 != -1) g_count_836++;
            }
         }
      }
   }
   return (g_count_836);
}

double TotalCorrBuyPos() {
   double ld_ret_0 = 0;
   g_ord_total_868 = OrdersTotal();
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE) {
         if (OrderMagicNumber() != g_magic_1916) {
            if (OrderSymbol() == gs_eurusd_396 || OrderSymbol() == gs_usdchf_404)
               if (OrderType() == OP_BUY) ld_ret_0 += 1.0;
         }
      }
   }
   return (ld_ret_0);
}

double TotalCorrSellPos() {
   double ld_ret_0 = 0;
   g_ord_total_868 = OrdersTotal();
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE) {
         if (OrderMagicNumber() != g_magic_1916) {
            if (OrderSymbol() == gs_eurusd_396 || OrderSymbol() == gs_usdchf_404)
               if (OrderType() == OP_SELL) ld_ret_0 += 1.0;
         }
      }
   }
   return (ld_ret_0);
}

double BuyLots() {
   gd_888 = 0;
   g_ord_total_868 = OrdersTotal();
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE)
         if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_1916) gd_888 += OrderLots();
   }
   return (gd_888);
}

double SellLots() {
   gd_896 = 0;
   g_ord_total_868 = OrdersTotal();
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE)
         if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() != g_magic_1916) gd_896 += OrderLots();
   }
   return (gd_896);
}

double LastOpenBuyPrice() {
   g_ord_open_price_1000 = 0;
   g_ord_total_868 = OrdersTotal();
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE) {
         if (OrderMagicNumber() != g_magic_1916)
            if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) g_ord_open_price_1000 = OrderOpenPrice();
      }
   }
   return (g_ord_open_price_1000);
}

double LastOpenSellPrice() {
   g_ord_open_price_1008 = 0;
   g_ord_total_868 = OrdersTotal();
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE) {
         if (OrderMagicNumber() != g_magic_1916)
            if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) g_ord_open_price_1008 = OrderOpenPrice();
      }
   }
   return (g_ord_open_price_1008);
}

double DoublerBuyLots() {
   gd_888 = 0;
   g_ord_total_868 = OrdersTotal();
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE) {
         if (OrderMagicNumber() == g_magic_1916)
            if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) gd_888 += OrderLots();
      }
   }
   return (gd_888);
}

double DoublerSellLots() {
   gd_896 = 0;
   g_ord_total_868 = OrdersTotal();
   for (g_pos_872 = 0; g_pos_872 < g_ord_total_868; g_pos_872++) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE) {
         if (OrderMagicNumber() == g_magic_1916)
            if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) gd_896 += OrderLots();
      }
   }
   return (gd_896);
}

int DCalc(string a_symbol_0) {
   int l_digits_8 = MarketInfo(a_symbol_0, MODE_DIGITS);
   if (l_digits_8 > 4 || l_digits_8 == 3) return (1);
   return (0);
}

int SCalc(string a_symbol_0) {
   int li_8 = MarketInfo(a_symbol_0, MODE_STOPLEVEL);
   if (gi_1828) li_8 = li_8 / 10.0;
   if (li_8 <= 5) return (1);
   return (0);
}

void CheckOrder() {
   if (gi_412 == FALSE) {
      if (gi_368 == TRUE) gi_856 = TotalCorrBuyPos() + TotalCorrSellPos();
      if (gi_368 == FALSE) gi_856 = BuyOpen() + SellOpen();
      if (CloseOneCloseAll == TRUE) {
         if (gi_852 > gi_856) {
            if (OrdersTotal() > 0) {
               gi_2248 = FALSE;
               CloseAll();
            }
            if (gs_1908 == "") gs_1908 = "CloseOneCloseAll";
            if (OrdersTotal() <= 0) {
               gi_852 = 0;
               CheckLoop();
            }
         } else gi_852 = gi_856;
      }
      if (CloseOneCloseAll == FALSE) {
         if (BuyOrders() + SellOrders() > 0) CancelPending();
         if (BuyOpen() + SellOpen() <= 0) {
            if (OrdersTotal() > 0) {
               gi_2248 = FALSE;
               CloseAll();
            }
            gs_1908 = "No Open Positions";
            if (OrdersTotal() <= 0) CheckLoop();
         }
      }
   }
   if (gi_412 == TRUE) gi_764 = TRUE;
}

int SCalc2(string a_symbol_0) {
   double ld_8 = MarketInfo(a_symbol_0, MODE_STOPLEVEL);
   if (gi_1828) ld_8 /= 10.0;
   if (ld_8 > 11.0) return (1);
   return (0);
}

void CheckLoop() {
   gi_880 = 0;
   gi_2028 = 0;
   gi_2032 = 0;
   gi_1516 = FALSE;
   if (EALoop <= 0) {
      MessageDisplay();
      gd_2064 = 0;
      if (gi_352 == TRUE) {
         if (ObjectsTotal() > 0) ObjectsDeleteAll();
      } else LoopObjDelete();
      gi_764 = TRUE;
      gi_2248 = TRUE;
      if (gi_796 == TRUE) gi_796 = FALSE;
   }
   if (EALoop > 0) {
      if (gi_876 < EALoop) {
         MessageDisplay();
         gd_2064 = 0;
         gi_876++;
         if (gi_352 == TRUE) {
            if (ObjectsTotal() > 0) ObjectsDeleteAll();
         } else LoopObjDelete();
         gi_764 = TRUE;
         gi_2248 = TRUE;
         if (gi_796 != TRUE) return;
         gi_796 = FALSE;
         return;
      }
      Print("Loop End");
      gi_756 = FALSE;
      if (OrdersTotal() > 0) CloseAll();
   }
}

int SCalc3(string a_symbol_0) {
   int li_8 = MarketInfo(a_symbol_0, MODE_STOPLEVEL);
   if (gi_1828) li_8 = li_8 / 10.0;
   if (li_8 == 10) return (1);
   return (0);
}

int FrzCalc(string a_symbol_0) {
   int l_freezelevel_8 = MarketInfo(a_symbol_0, MODE_FREEZELEVEL);
   if (l_freezelevel_8 == 3) return (1);
   return (0);
}

void CancelPending() {
   for (g_pos_872 = OrdersTotal() - 1; g_pos_872 >= 0; g_pos_872--) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS) != FALSE) {
         if (OrderType() == OP_BUYSTOP) OrderDelete(OrderTicket());
         if (OrderType() == OP_SELLSTOP) OrderDelete(OrderTicket());
         if (OrderType() == OP_BUYLIMIT) OrderDelete(OrderTicket());
         if (OrderType() == OP_SELLLIMIT) OrderDelete(OrderTicket());
      }
   }
}

void CheckPos() {
   double l_price_0;
   double l_ord_lots_8;
   int l_ticket_16;
   bool l_ord_close_20;
   int l_error_24;
   int l_cmd_28;
   int l_cmd_32 = -1;
   for (g_pos_872 = OrdersTotal() - 1; g_pos_872 >= 0; g_pos_872--) {
      if (OrderSelect(g_pos_872, SELECT_BY_POS)) {
         if (OrderSymbol() == Symbol()) {
            if (OrderMagicNumber() != g_magic_1916) {
               l_cmd_28 = OrderType();
               if (l_cmd_28 <= OP_SELL) {
                  if (OrderProfit() < 0.0) {
                     l_ord_lots_8 = OrderLots();
                     l_ticket_16 = OrderTicket();
                     l_cmd_32 = l_cmd_28;
                     while (true) {
                        if (l_cmd_32 == -1) break;
                        switch (l_cmd_32) {
                        case OP_BUY:
                           l_price_0 = Bid;
                           break;
                        case OP_SELL:
                           l_price_0 = Ask;
                        }
                        l_ord_close_20 = OrderClose(l_ticket_16, l_ord_lots_8, l_price_0, 5);
                        if (l_ord_close_20) break;
                        l_error_24 = GetLastError();
                        switch (l_error_24) {
                        case 4/* SERVER_BUSY */:
                           Sleep(3000);
                           break;
                        case 135/* PRICE_CHANGED */:
                           RefreshRates();
                           break;
                        case 136/* OFF_QUOTES */:
                           if (RefreshRates() != FALSE) break;
                           while (true) {
                              Sleep(1);
                              if (RefreshRates() == FALSE) continue;
                              break;
                           }
                           break;
                        case 137/* BROKER_BUSY */:
                           Sleep(3000);
                           break;
                        case 146/* TRADE_CONTEXT_BUSY */:
                           Sleep(300);
                           RefreshRates();
                           break;
                        case 2/* COMMON_ERROR */:
                           Sleep(300);
                           RefreshRates();
                           break;
                        case 133/* TRADE_DISABLED */:
                           Sleep(300);
                           RefreshRates();
                        }
                     }
                  }
               }
            }
         }
      }
   }
}

void CloseAll() {
   gi_764 = FALSE;
   Print("Closing All Order...");
   while (true) {
      if (OrdersTotal() <= 0) break;
      CloseAllSequence(1);
      CloseAllSequence(2);
      CloseAllSequence(0);
      CloseAllSequence(3);
   }
}

void CloseAllSequence(int ai_0) {
   double l_ord_lots_4;
   int l_ticket_12;
   int l_error_16;
   int li_20;
   string ls_24;
   double l_price_32;
   int li_40;
   int l_cmd_44;
   int l_cmd_48 = -1;
   string ls_52 = Symbol();
   if (gi_2224 != gi_2228 || (gi_2224 == gi_2228 && gi_880 <= gi_2140)) {
      li_40 = OrdersTotal() - 1;
      for (g_pos_872 = li_40; g_pos_872 >= 0; g_pos_872--) {
         if (OrderSelect(g_pos_872, SELECT_BY_POS) == TRUE) {
            if (ai_0 == 1) {
               if (OrderSymbol() != ls_52) continue;
               l_cmd_44 = OrderType();
               if (l_cmd_44 > OP_SELL) continue;
               l_ord_lots_4 = OrderLots();
               l_ticket_12 = OrderTicket();
               l_cmd_48 = l_cmd_44;
               while (true) {
                  if (l_cmd_48 == -1) {
                     Alert("No orders available");
                     break;
                  }
                  switch (l_cmd_48) {
                  case OP_BUY:
                     l_price_32 = Bid;
                     ls_24 = "Buy";
                     break;
                  case OP_SELL:
                     l_price_32 = Ask;
                     ls_24 = "Sell";
                  }
                  Print("Attempting to close ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
                  if (gi_2224 == gi_2228) Sleep(4000);
                  li_20 = OrderClose(l_ticket_12, l_ord_lots_4, l_price_32, 3);
                  if (li_20 == 1) {
                     Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
                     break;
                  }
                  l_error_16 = GetLastError();
                  switch (l_error_16) {
                  case 135/* PRICE_CHANGED */:
                     Print("The price has changed. Retrying..");
                     RefreshRates();
                     break;
                  case 136/* OFF_QUOTES */:
                     Print("No prices. Waiting for a new tick..");
                     if (RefreshRates() != FALSE) break;
                     while (true) {
                        if (gi_2224 == gi_2228) Sleep(5000);
                        else Sleep(1);
                        if (RefreshRates() == FALSE) continue;
                        break;
                     }
                     break;
                  case 146/* TRADE_CONTEXT_BUSY */:
                     Print("Trading subsystem is busy. Retrying..");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 2/* COMMON_ERROR */:
                     Print("Common error");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 133/* TRADE_DISABLED */:
                     Print("Trading is prohibited");
                     Sleep(300);
                     RefreshRates();
                     break;
                  case 64/* ACCOUNT_DISABLED */:
                     Print("Account is blocked");
                     break;
                  default:
                     Print("Error ", l_error_16, " occured");
                     Sleep(10);
                     RefreshRates();
                  }
               }
            }
            if (ai_0 == 2) {
               if (OrderSymbol() == ls_52) continue;
               l_cmd_44 = OrderType();
               if (l_cmd_44 > OP_SELL) continue;
               l_ord_lots_4 = OrderLots();
               l_ticket_12 = OrderTicket();
               l_cmd_48 = l_cmd_44;
               while (true) {
                  if (l_cmd_48 == -1) {
                     Alert("No orders available");
                     break;
                  }
                  switch (l_cmd_48) {
                  case OP_BUY:
                     l_price_32 = MarketInfo(OrderSymbol(), MODE_BID);
                     ls_24 = "Buy";
                     break;
                  case OP_SELL:
                     l_price_32 = MarketInfo(OrderSymbol(), MODE_ASK);
                     ls_24 = "Sell";
                  }
                  Print("Attempting to close ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
                  if (gi_2224 == gi_2228) Sleep(3000);
                  li_20 = OrderClose(l_ticket_12, l_ord_lots_4, l_price_32, 3);
                  if (li_20 == 1) {
                     Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
                     break;
                  }
                  l_error_16 = GetLastError();
                  switch (l_error_16) {
                  case 135/* PRICE_CHANGED */:
                     Print("The price has changed. Retrying..");
                     RefreshRates();
                     break;
                  case 136/* OFF_QUOTES */:
                     Print("No prices. Waiting for a new tick..");
                     if (RefreshRates() != FALSE) break;
                     while (true) {
                        if (gi_2224 == gi_2228) Sleep(5000);
                        else Sleep(1);
                        if (RefreshRates() == FALSE) continue;
                        break;
                     }
                     break;
                  case 146/* TRADE_CONTEXT_BUSY */:
                     Print("Trading subsystem is busy. Retrying..");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 2/* COMMON_ERROR */:
                     Print("Common error");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 133/* TRADE_DISABLED */:
                     Print("Trading is prohibited");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 64/* ACCOUNT_DISABLED */:
                     Print("Account is blocked");
                     break;
                  default:
                     Print("Error ", l_error_16, " occured");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(10);
                     RefreshRates();
                  }
               }
            }
            if (ai_0 == 0) {
               if (OrderSymbol() != ls_52) continue;
               l_cmd_44 = OrderType();
               if (l_cmd_44 < OP_BUYLIMIT) continue;
               l_ticket_12 = OrderTicket();
               l_cmd_48 = l_cmd_44;
               l_ord_lots_4 = OrderLots();
               while (true) {
                  if (l_cmd_48 == -1) {
                     Alert("No orders available");
                     break;
                  }
                  switch (l_cmd_48) {
                  case OP_BUYLIMIT:
                     ls_24 = "Buy Limit";
                     break;
                  case OP_SELLLIMIT:
                     ls_24 = "Sell Limit";
                     break;
                  case OP_BUYSTOP:
                     ls_24 = "Buy Stop";
                     break;
                  case OP_SELLSTOP:
                     ls_24 = "Sell Stop";
                  }
                  Print("Attempting to close pending ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
                  if (gi_2224 == gi_2228) Sleep(4000);
                  li_20 = OrderDelete(l_ticket_12);
                  if (li_20 == 1) {
                     Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
                     break;
                  }
                  l_error_16 = GetLastError();
                  switch (l_error_16) {
                  case 135/* PRICE_CHANGED */:
                     Print("The price has changed. Retrying..");
                     RefreshRates();
                     break;
                  case 136/* OFF_QUOTES */:
                     Print("No prices. Waiting for a new tick..");
                     if (RefreshRates() != FALSE) break;
                     while (true) {
                        if (gi_2224 == gi_2228) Sleep(5000);
                        else Sleep(1);
                        if (RefreshRates() == FALSE) continue;
                        break;
                     }
                     break;
                  case 146/* TRADE_CONTEXT_BUSY */:
                     Print("Trading subsystem is busy. Retrying..");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 2/* COMMON_ERROR */:
                     Print("Common error");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 133/* TRADE_DISABLED */:
                     Print("Trading is prohibited");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 64/* ACCOUNT_DISABLED */:
                     Print("Account is blocked");
                     break;
                  default:
                     Print("Error ", l_error_16, " occured");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(10);
                     RefreshRates();
                  }
               }
            }
            if (ai_0 == 3) {
               if (OrderSymbol() != ls_52) {
                  l_cmd_44 = OrderType();
                  if (l_cmd_44 >= OP_BUYLIMIT) {
                     l_ticket_12 = OrderTicket();
                     l_cmd_48 = l_cmd_44;
                     l_ord_lots_4 = OrderLots();
                     while (true) {
                        if (l_cmd_48 == -1) {
                           Alert("No orders available");
                           break;
                        }
                        switch (l_cmd_48) {
                        case OP_BUYLIMIT:
                           ls_24 = "Buy Limit";
                           break;
                        case OP_SELLLIMIT:
                           ls_24 = "Sell Limit";
                           break;
                        case OP_BUYSTOP:
                           ls_24 = "Buy Stop";
                           break;
                        case OP_SELLSTOP:
                           ls_24 = "Sell Stop";
                        }
                        Print("Attempting to close pending ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
                        if (gi_2224 == gi_2228) Sleep(3000);
                        li_20 = OrderDelete(l_ticket_12);
                        if (li_20 == 1) {
                           Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
                           break;
                        }
                        l_error_16 = GetLastError();
                        switch (l_error_16) {
                        case 135/* PRICE_CHANGED */:
                           Print("The price has changed. Retrying..");
                           RefreshRates();
                           break;
                        case 136/* OFF_QUOTES */:
                           Print("No prices. Waiting for a new tick..");
                           if (RefreshRates() != FALSE) break;
                           while (true) {
                              if (gi_2224 == gi_2228) Sleep(5000);
                              else Sleep(1);
                              if (RefreshRates() == FALSE) continue;
                              break;
                           }
                           break;
                        case 146/* TRADE_CONTEXT_BUSY */:
                           Print("Trading subsystem is busy. Retrying..");
                           if (gi_2224 == gi_2228) Sleep(5000);
                           else Sleep(300);
                           RefreshRates();
                           break;
                        case 2/* COMMON_ERROR */:
                           Print("Common error");
                           if (gi_2224 == gi_2228) Sleep(5000);
                           else Sleep(300);
                           RefreshRates();
                           break;
                        case 133/* TRADE_DISABLED */:
                           Print("Trading is prohibited");
                           if (gi_2224 == gi_2228) Sleep(5000);
                           else Sleep(300);
                           RefreshRates();
                           break;
                        case 64/* ACCOUNT_DISABLED */:
                           Print("Account is blocked");
                           break;
                        default:
                           Print("Error ", l_error_16, " occured");
                           if (gi_2224 == gi_2228) Sleep(5000);
                           else Sleep(10);
                           RefreshRates();
                        }
                     }
                  }
               }
            }
         }
      }
   }
   if (gi_2224 == gi_2228 && gi_880 > gi_2140) {
      g_ord_total_868 = OrdersTotal();
      for (g_pos_872 = 1; g_pos_872 <= g_ord_total_868; g_pos_872++) {
         if (OrderSelect(g_pos_872 - 1, SELECT_BY_POS) == TRUE) {
            if (ai_0 == 1) {
               if (OrderSymbol() != ls_52) continue;
               l_cmd_44 = OrderType();
               if (l_cmd_44 > OP_SELL) continue;
               l_ord_lots_4 = OrderLots();
               l_ticket_12 = OrderTicket();
               l_cmd_48 = l_cmd_44;
               while (true) {
                  if (l_cmd_48 == -1) {
                     Alert("No orders available");
                     break;
                  }
                  switch (l_cmd_48) {
                  case OP_BUY:
                     l_price_32 = Bid;
                     ls_24 = "Buy";
                     break;
                  case OP_SELL:
                     l_price_32 = Ask;
                     ls_24 = "Sell";
                  }
                  Print("Attempting to close ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
                  Sleep(7000);
                  li_20 = OrderClose(l_ticket_12, l_ord_lots_4, l_price_32, 3);
                  if (li_20 == 1) {
                     Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
                     break;
                  }
                  l_error_16 = GetLastError();
                  switch (l_error_16) {
                  case 135/* PRICE_CHANGED */:
                     Print("The price has changed. Retrying..");
                     RefreshRates();
                     break;
                  case 136/* OFF_QUOTES */:
                     Print("No prices. Waiting for a new tick..");
                     if (RefreshRates() != FALSE) break;
                     while (true) {
                        Sleep(5000);
                        if (RefreshRates() == FALSE) continue;
                        break;
                     }
                     break;
                  case 146/* TRADE_CONTEXT_BUSY */:
                     Print("Trading subsystem is busy. Retrying..");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 2/* COMMON_ERROR */:
                     Print("Common error");
                     Sleep(5000);
                     RefreshRates();
                     break;
                  case 133/* TRADE_DISABLED */:
                     Print("Trading is prohibited");
                     Sleep(5000);
                     RefreshRates();
                     break;
                  case 64/* ACCOUNT_DISABLED */:
                     Print("Account is blocked");
                     break;
                  default:
                     Print("Error ", l_error_16, " occured");
                     Sleep(5000);
                     RefreshRates();
                  }
               }
            }
            if (ai_0 == 2) {
               if (OrderSymbol() == ls_52) continue;
               l_cmd_44 = OrderType();
               if (l_cmd_44 > OP_SELL) continue;
               l_ord_lots_4 = OrderLots();
               l_ticket_12 = OrderTicket();
               l_cmd_48 = l_cmd_44;
               while (true) {
                  if (l_cmd_48 == -1) {
                     Alert("No orders available");
                     break;
                  }
                  switch (l_cmd_48) {
                  case OP_BUY:
                     l_price_32 = MarketInfo(OrderSymbol(), MODE_BID);
                     ls_24 = "Buy";
                     break;
                  case OP_SELL:
                     l_price_32 = MarketInfo(OrderSymbol(), MODE_ASK);
                     ls_24 = "Sell";
                  }
                  Print("Attempting to close ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
                  Sleep(5000);
                  li_20 = OrderClose(l_ticket_12, l_ord_lots_4, l_price_32, 3);
                  if (li_20 == 1) {
                     Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
                     break;
                  }
                  l_error_16 = GetLastError();
                  switch (l_error_16) {
                  case 135/* PRICE_CHANGED */:
                     Print("The price has changed. Retrying..");
                     RefreshRates();
                     break;
                  case 136/* OFF_QUOTES */:
                     Print("No prices. Waiting for a new tick..");
                     if (RefreshRates() != FALSE) break;
                     while (true) {
                        Sleep(5000);
                        if (RefreshRates() == FALSE) continue;
                        break;
                     }
                     break;
                  case 146/* TRADE_CONTEXT_BUSY */:
                     Print("Trading subsystem is busy. Retrying..");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 2/* COMMON_ERROR */:
                     Print("Common error");
                     Sleep(5000);
                     RefreshRates();
                     break;
                  case 133/* TRADE_DISABLED */:
                     Print("Trading is prohibited");
                     Sleep(5000);
                     RefreshRates();
                     break;
                  case 64/* ACCOUNT_DISABLED */:
                     Print("Account is blocked");
                     break;
                  default:
                     Print("Error ", l_error_16, " occured");
                     Sleep(5000);
                     RefreshRates();
                  }
               }
            }
            if (ai_0 == 0) {
               if (OrderSymbol() != ls_52) continue;
               l_cmd_44 = OrderType();
               if (l_cmd_44 < OP_BUYLIMIT) continue;
               l_ticket_12 = OrderTicket();
               l_cmd_48 = l_cmd_44;
               l_ord_lots_4 = OrderLots();
               while (true) {
                  if (l_cmd_48 == -1) {
                     Alert("No orders available");
                     break;
                  }
                  switch (l_cmd_48) {
                  case OP_BUYLIMIT:
                     ls_24 = "Buy Limit";
                     break;
                  case OP_SELLLIMIT:
                     ls_24 = "Sell Limit";
                     break;
                  case OP_BUYSTOP:
                     ls_24 = "Buy Stop";
                     break;
                  case OP_SELLSTOP:
                     ls_24 = "Sell Stop";
                  }
                  Print("Attempting to close pending ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
                  Sleep(5000);
                  li_20 = OrderDelete(l_ticket_12);
                  if (li_20 == 1) {
                     Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
                     break;
                  }
                  l_error_16 = GetLastError();
                  switch (l_error_16) {
                  case 135/* PRICE_CHANGED */:
                     Print("The price has changed. Retrying..");
                     RefreshRates();
                     break;
                  case 136/* OFF_QUOTES */:
                     Print("No prices. Waiting for a new tick..");
                     if (RefreshRates() != FALSE) break;
                     while (true) {
                        if (gi_2224 == gi_2228) Sleep(5000);
                        else Sleep(1);
                        if (RefreshRates() == FALSE) continue;
                        break;
                     }
                     break;
                  case 146/* TRADE_CONTEXT_BUSY */:
                     Print("Trading subsystem is busy. Retrying..");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 2/* COMMON_ERROR */:
                     Print("Common error");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 133/* TRADE_DISABLED */:
                     Print("Trading is prohibited");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(300);
                     RefreshRates();
                     break;
                  case 64/* ACCOUNT_DISABLED */:
                     Print("Account is blocked");
                     break;
                  default:
                     Print("Error ", l_error_16, " occured");
                     if (gi_2224 == gi_2228) Sleep(5000);
                     else Sleep(10);
                     RefreshRates();
                  }
               }
            }
            if (ai_0 == 3) {
               if (OrderSymbol() != ls_52) {
                  l_cmd_44 = OrderType();
                  if (l_cmd_44 >= OP_BUYLIMIT) {
                     l_ticket_12 = OrderTicket();
                     l_cmd_48 = l_cmd_44;
                     l_ord_lots_4 = OrderLots();
                     while (true) {
                        if (l_cmd_48 == -1) {
                           Alert("No orders available");
                           break;
                        }
                        switch (l_cmd_48) {
                        case OP_BUYLIMIT:
                           ls_24 = "Buy Limit";
                           break;
                        case OP_SELLLIMIT:
                           ls_24 = "Sell Limit";
                           break;
                        case OP_BUYSTOP:
                           ls_24 = "Buy Stop";
                           break;
                        case OP_SELLSTOP:
                           ls_24 = "Sell Stop";
                        }
                        Print("Attempting to close pending ", ls_24, " order ", DoubleToStr(l_ord_lots_4, 2), " lot. Awaiting for response..");
                        Sleep(5000);
                        li_20 = OrderDelete(l_ticket_12);
                        if (li_20 == 1) {
                           Print("Order ", ls_24, " of ", DoubleToStr(l_ord_lots_4, 2), " lot has been closed");
                           break;
                        }
                        l_error_16 = GetLastError();
                        switch (l_error_16) {
                        case 135/* PRICE_CHANGED */:
                           Print("The price has changed. Retrying..");
                           RefreshRates();
                           break;
                        case 136/* OFF_QUOTES */:
                           Print("No prices. Waiting for a new tick..");
                           if (RefreshRates() != FALSE) break;
                           while (true) {
                              if (gi_2224 == gi_2228) Sleep(5000);
                              else Sleep(1);
                              if (RefreshRates() == FALSE) continue;
                              break;
                           }
                           break;
                        case 146/* TRADE_CONTEXT_BUSY */:
                           Print("Trading subsystem is busy. Retrying..");
                           if (gi_2224 == gi_2228) Sleep(5000);
                           else Sleep(300);
                           RefreshRates();
                           break;
                        case 2/* COMMON_ERROR */:
                           Print("Common error");
                           if (gi_2224 == gi_2228) Sleep(5000);
                           else Sleep(300);
                           RefreshRates();
                           break;
                        case 133/* TRADE_DISABLED */:
                           Print("Trading is prohibited");
                           if (gi_2224 == gi_2228) Sleep(5000);
                           else Sleep(300);
                           RefreshRates();
                           break;
                        case 64/* ACCOUNT_DISABLED */:
                           Print("Account is blocked");
                           break;
                        default:
                           Print("Error ", l_error_16, " occured");
                           if (gi_2224 == gi_2228) Sleep(5000);
                           else Sleep(10);
                           RefreshRates();
                        }
                     }
                  }
               }
            }
         }
      }
   }
}

void LoopObjDelete() {
   Delete("INCREASE_");
   Delete("RANGE_");
   Delete("INITIALRANGE_");
   Delete("TRAILINGSTOPSELL_");
   Delete("TRAILINGSTOPSELL_BEP_");
   Delete("TRAILINGSTOPBUY_");
   Delete("TRAILINGSTOPBUY_BEP_");
   Delete("TRAILINGSTOPSELL_2_");
   Delete("TRAILINGSTOPSELL_2_BEP_");
   Delete("TRAILINGSTOPBUY_2_");
   Delete("TRAILINGSTOPBUY_2_BEP_");
   Delete("TRAILINGSTOPSELL_3_");
   Delete("TRAILINGSTOPSELL_3_BEP_");
   Delete("TRAILINGSTOPBUY_3_");
   Delete("TRAILINGSTOPBUY_3_BEP_");
   Delete("TRAILINGSTOPBUY_4_");
   Delete("TRAILINGSTOPBUY_4_BEP_");
   Delete("TRAILINGSTOPSELL_4_");
   Delete("TRAILINGSTOPSELL_4_BEP_");
   Delete("TRAILINGSTOP_");
}

void ObjDelete() {
   Delete("SEQUENCE_");
   Delete("BUYROW_");
   Delete("SELLROW_");
   Delete("ACTIVEORDERS_");
   Delete("BUY_");
   Delete("SELL_");
   Delete("PENDING_");
   Delete("PENDING_BUY");
   Delete("PENDING_SELL");
   Delete("TRAILINGSTOP_");
   Delete("FULLHEDGE_");
   Delete("GAP_");
}

void Delete(string a_name_0) {
   while (ObjectFind(a_name_0) == 0) ObjectDelete(a_name_0);
}

void MessageDisplay() {
   gd_2072 = AccountBalance();
   if (gs_1908 == "") gs_1908 = "None";
   if (gd_2072 != gd_2064) {
      Alert("************************************");
      Alert("************************************");
      Alert("Current Balance = $", DoubleToStr(gd_2072, 2));
      Alert("Last Balance = $", DoubleToStr(gd_2064, 2));
      if (gd_2072 > gd_2064) {
         Alert("Your Profit is = $", DoubleToStr(gd_2072 - gd_2064, 2));
         Alert("Closed by ", gs_1908);
      } else {
         Alert("Your Loss is = $-", DoubleToStr(gd_2064 - gd_2072, 2));
         Alert("Closed by ", gs_1908);
      }
   }
   if (gd_2072 == gd_2064) {
      Alert("************************************");
      Alert("************************************");
      Alert("************************************");
      Alert("Your Current Balance is $", DoubleToStr(gd_2072, 2));
      Alert("There is no profit or loss");
      Alert("Closed by ", gs_1908);
   }
}

void FirstOrder() {
   double l_ima_0;
   double l_ima_8;
   double l_ima_16;
   double l_ima_24;
   if (BuyOpen() + SellOpen() <= 0) {
      if (InitialOrder == "auto" || InitialOrder == "a" || gs_1964 == "auto") {
         l_ima_0 = iMA(Symbol(), 0, ShortEMA, 0, MODE_EMA, PRICE_CLOSE, 0);
         l_ima_8 = iMA(Symbol(), 0, LongEMA, 0, MODE_EMA, PRICE_CLOSE, 0);
         l_ima_16 = iMA(Symbol(), 0, ShortEMA, 0, MODE_EMA, PRICE_CLOSE, 1);
         l_ima_24 = iMA(Symbol(), 0, LongEMA, 0, MODE_EMA, PRICE_CLOSE, 1);
         gi_2580 = Crossed(l_ima_8, l_ima_0);
         while (BuyOpen() + SellOpen() <= 0) {
            if (gi_2580 == 1) {
               RefreshRates();
               if (OrderSend(Symbol(), OP_BUY, g_lots_2104, MarketInfo(Symbol(), MODE_ASK), 3, 0, 0, g_comment_304, 0, 0, CLR_NONE) < 0) {
                  Print("Error Buy= ", ErrorDescription(GetLastError()));
                  return;
               }
            }
            if (gi_2580 == 2) {
               RefreshRates();
               if (OrderSend(Symbol(), OP_SELL, g_lots_2104, MarketInfo(Symbol(), MODE_BID), 3, 0, 0, g_comment_304, 0, 0, CLR_NONE) < 0) {
                  Print("Error Sell = ", ErrorDescription(GetLastError()));
                  return;
               }
            }
         }
         gs_1964 = "auto";
      }
      if (gi_1508 == FALSE) {
         if (InitialOrder == "buy auto" || InitialOrder == "ba") {
            if (g_ask_2048 != MarketInfo(Symbol(), MODE_ASK)) g_ask_2048 = MarketInfo(Symbol(), MODE_ASK);
            if (OrderSend(Symbol(), OP_BUY, g_lots_2104, g_ask_2048, 3, 0, 0, g_comment_304, 0, 0, CLR_NONE) < 0) {
               Print("Error Buy= ", ErrorDescription(GetLastError()));
               return;
            }
            gi_1508 = TRUE;
            gs_1964 = "auto";
         }
         if (InitialOrder == "sell auto" || InitialOrder == "sa") {
            if (g_bid_2056 != MarketInfo(Symbol(), MODE_BID)) g_bid_2056 = MarketInfo(Symbol(), MODE_BID);
            if (OrderSend(Symbol(), OP_SELL, g_lots_2104, g_bid_2056, 3, 0, 0, g_comment_304, 0, 0, CLR_NONE) < 0) {
               Print("Error Sell= ", ErrorDescription(GetLastError()));
               return;
            }
            gi_1508 = TRUE;
            gs_1964 = "auto";
         }
         if (InitialOrder == "manual" || InitialOrder == "m") {
            gi_1508 = TRUE;
            gs_1964 = "auto";
            gi_764 = FALSE;
            gi_760 = TRUE;
         }
      }
   }
   if (BuyOpen() + SellOpen() > 0) {
      gi_764 = FALSE;
      gi_760 = TRUE;
   }
}

int Scalper_IsTradeTime() {
   RefreshRates();
   g_datetime_1820 = TimeCurrent();
   int l_hour_0 = TimeHour(g_datetime_1820);
   if (gi_1812 < gi_1816 && l_hour_0 < gi_1812 || l_hour_0 >= gi_1816) return (0);
   if (gi_1812 > gi_1816 && (l_hour_0 < gi_1812 && l_hour_0 >= gi_1816)) return (0);
   if (gi_1816 == 0) gi_1816 = 24;
   if (Hour() == gi_1816 - 1 && Minute() >= 35) return (0);
   return (1);
}

double BasicLot() {
   gd_1880 = LotSize;
   gi_1896 = 1;
   while (true) {
      if (gd_1880 / MarketInfo(Symbol(), MODE_LOTSTEP) < 10.0) break;
      gd_1880 /= 10.0;
      gi_1896 = 10 * gi_1896;
   }
   gd_1888 = gi_1896 * MarketInfo(Symbol(), MODE_LOTSTEP);
   return (gd_1888);
}