Navigation:Home > Content >

THG_Straddle_Trader_Diamond_v2.8.2.mq4

Time: 2018-05-01 | Download file:THG_Straddle_Trader_Diamond_v2.8.2.mq4

/*
   Generated by EX4-TO-MQ4 decompiler LITE V4.0.427.1 [-]
   Website: https://purebeam.biz
   E-mail : [email protected]
*/
//#include 
#import "stdlib.ex4"
   string ErrorDescription(int a0);
#import

extern bool ShutDown.NOW = FALSE;
extern string sStr00 = " 0=Everything               ";
extern string sStr01 = " 1=All Triggered Positions  ";
extern string sStr02 = " 2=Triggered Long           ";
extern string sStr03 = " 3=Triggered Short          ";
extern string sStr04 = " 4=All Pending Positions    ";
extern string sStr05 = " 5=Pending Long             ";
extern string sStr06 = " 6=Pending Short            ";
extern int ShutDown.What = 0;
extern bool ShutDown.Current.Pair.Only = FALSE;
extern string sStr1 = "=== POSITION DETAILS ===";
extern double Lot.Size = 0.3;
extern double Take.Out.Lots = 0.3;
extern int Slippage = 6;
extern string sStr2 = "=== TAKE PROFITS ===";
extern int Initial.TP1 = 40;
extern int Initial.TP2 = 0;
extern int Initial.TP3 = 0;
extern string sStr3 = "=== STOPS LOSS ===";
extern int StopLoss.Pips.Longs = 10;
extern int StopLoss.Pips.Shorts = 10;
extern int Auto.SL.Prev.Bars.to.Count = 0;
extern int Auto.SL.Prev.Bars.TimeFrame = 0;
extern string sStr4 = "=== BREAKEVEN AND TRAIL ===";
extern int Trail.Pips = 16;
extern bool Trail.Starts.After.BreakEven = TRUE;
extern int Move.To.BreakEven.at.pips = 15;
extern int Move.To.BreakEven.Lock.pips = 8;
extern string sStr5 = "=== MONEY MANAGEMENT ===";
extern bool Use.Money.Management = FALSE;
extern double Trade.Maximum.Risk = 0.14;
extern string sStr6 = "=== NEWS EVENT ===";
extern bool Enable.News.Trading = TRUE;
extern int Distance.From.Price.Longs = 8;
extern int Distance.From.Price.Shorts = 8;
extern int Event.Start.Hour = 9;
extern int Event.Start.Minutes = 30;
extern int Pre.Event.Entry.Seconds = 12;
extern int Stop.Adjusting.Sec.Before.Event = 60;
extern bool Remove.Opposite.Order = TRUE;
extern bool Adjust.Pending.Orders = FALSE;
extern int Kill.Pending.After.Seconds = 20;
extern int Kill.Triggered.After.Seconds = 0;
extern string sStr7 = "=== VARIOUS ===";
extern bool Place.Straddle.Immediately = FALSE;
extern bool Debug = FALSE;
int gi_328 = 0;
bool gi_332 = FALSE;
int gi_336;
int gi_340;
int gi_344;
int gi_348;
int gi_352;
int gi_356;
int gi_360;
int gi_364;
int gi_368;
int gi_372;
int gi_376;
int gi_380;
int gi_384;
int gi_388;
int gi_392;
int gi_396;
int gi_400;
int gi_404;
string gs_408 = " THG Straddle Trader";
string gs_416 = "THG Straddle Trader-DIAMOND";
string gs_424 = "";
string gs_432;
string gs_440;
string gs_448;
bool gi_456 = TRUE;
bool gi_460 = FALSE;
bool gi_464;
double gd_468;
double gd_476;
double gd_484;
double gd_492;
double gd_500;
double gd_508;
int gi_516;
int gi_520;
bool gi_524;
int gi_528;
int gi_532;
int gi_536;
int gi_540;
int gi_544 = 0;
int gi_548 = 0;
int gi_552 = -1;
int gi_556 = -1;
int gi_560 = -1;
int gi_564 = -1;
double gd_568 = 0.0;
double gd_576 = 0.0;
double gd_584 = 0.0;
double gd_592;
double gd_600;
double gd_608 = 0.0;
double gd_616;
double gd_624 = 0.0;
double gd_632 = 0.0;
double gd_640 = 0.0;
double gd_648 = 0.0;
bool gi_656 = FALSE;
bool gi_660 = FALSE;
double gd_664 = 0.0;
double gd_672 = 0.0;
double vPoint;

int init() {
   f0_13();
   f0_4();
   gi_464 = FALSE;
   f0_19();
   if (Digits > 3) vPoint = 0.0001;
   else vPoint = 0.01;
   return (0);
}

int deinit() {
   f0_4();
   return (0);
}

void f0_8() {
   bool li_0;
   int li_4 = 8;
   int li_8 = 16;
   int li_12 = 13;
   int li_16 = 21;
   bool li_20 = FALSE;
   int li_24 = 7;
   int li_28 = 20;
   int li_32 = 3;
   bool li_36 = FALSE;
   bool li_40 = FALSE;
   bool li_44 = FALSE;
   bool li_48 = FALSE;
   for (int li_52 = 500; li_52 >= 0; li_52--) {
      li_0 = TimeDayOfWeek(iTime(NULL, 0, li_52)) == 0;
      if (!li_0) {
         if (TimeHour(Time[li_52 + 1]) - gi_328 == li_28 && li_36 == FALSE) {
            li_36 = TRUE;
            ObjectCreate("Sydney Open  " + TimeToStr(Time[li_52 + 1]), OBJ_ARROW, 0, Time[li_52 + 1], High[li_52 + 1] + 15.0 * vPoint);
            ObjectSet("Sydney Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_ARROWCODE, 191);
            ObjectSet("Sydney Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_WIDTH, 3);
            ObjectSet("Sydney Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_COLOR, CornflowerBlue);
            gi_528 = 1;
         } else {
            if (TimeHour(Time[li_52 + 1]) - gi_328 == li_20 && li_40 == FALSE) {
               li_40 = TRUE;
               ObjectCreate("Tokyo Open  " + TimeToStr(Time[li_52 + 1]), OBJ_ARROW, 0, Time[li_52 + 1], High[li_52 + 1] + 15.0 * vPoint);
               ObjectSet("Tokyo Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_ARROWCODE, 194);
               ObjectSet("Tokyo Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_WIDTH, 3);
               ObjectSet("Tokyo Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_COLOR, Yellow);
            } else {
               if (TimeHour(Time[li_52 + 1]) - gi_328 == li_4 && li_44 == FALSE) {
                  li_44 = TRUE;
                  ObjectCreate("London Open  " + TimeToStr(Time[li_52 + 1]), OBJ_ARROW, 0, Time[li_52 + 1], High[li_52 + 1] + 15.0 * vPoint);
                  ObjectSet("London Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_ARROWCODE, 189);
                  ObjectSet("London Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_WIDTH, 3);
                  ObjectSet("London Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_COLOR, Aqua);
                  li_40 = FALSE;
                  gi_532 = 1;
               } else {
                  if (TimeHour(Time[li_52 + 1]) - gi_328 == li_12 && li_48 == FALSE) {
                     li_48 = TRUE;
                     ObjectCreate("NewYork Open  " + TimeToStr(Time[li_52 + 1]), OBJ_ARROW, 0, Time[li_52 + 1], High[li_52 + 1] + 15.0 * vPoint);
                     ObjectSet("NewYork Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_ARROWCODE, 194);
                     ObjectSet("NewYork Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_WIDTH, 3);
                     ObjectSet("NewYork Open  " + TimeToStr(Time[li_52 + 1]), OBJPROP_COLOR, Lime);
                     gi_536 = 1;
                  }
               }
            }
         }
      }
      if (TimeHour(Time[li_52 + 1]) == 0) {
         li_36 = FALSE;
         li_44 = FALSE;
         li_48 = FALSE;
      }
   }
}

void f0_4() {
   ObjectDelete("TradeHouseGlobal");
   ObjectDelete("TradeHouseGlobal.com");
   ObjectDelete("Artemis");
   ObjectDelete("NewsLabel");
   ObjectDelete("Bar");
   ObjectDelete("Broker");
   ObjectDelete("Broker1");
   ObjectDelete("Sydney");
   ObjectDelete("Tokyo");
   ObjectDelete("London");
   ObjectDelete("NewYork");
}

int start() {
   double ld_0;
   double ld_8;
   double ld_16;
   gi_336 = MarketInfo(Symbol(), MODE_STOPLEVEL);
   gi_548 = AccountLeverage();
   gi_544 = MarketInfo(Symbol(), MODE_LOTSIZE);
   gd_576 = MarketInfo(Symbol(), MODE_MINLOT);
   gd_584 = MarketInfo(Symbol(), MODE_MAXLOT);
   gd_608 = MarketInfo(Symbol(), MODE_LOTSTEP);
   gd_616 = MarketInfo(Symbol(), MODE_TICKVALUE);
   if (gd_608 == 0.1) gd_568 = 1;
   if (gd_608 == 0.01) gd_568 = 2;
   int li_24 = f0_15();
   if (li_24 == 1) {
      Alert("Error 9000 - Contact Support at [email protected]");
      return (0);
   }
   if (StopLoss.Pips.Longs == 0) StopLoss.Pips.Longs = 999;
   if (StopLoss.Pips.Shorts == 0) StopLoss.Pips.Shorts = 999;
   if (Initial.TP1 == 0) Initial.TP1 = 999;
   if (StopLoss.Pips.Longs < gi_336) StopLoss.Pips.Longs = gi_336;
   if (StopLoss.Pips.Shorts < gi_336) StopLoss.Pips.Shorts = gi_336;
   if (Trail.Pips < gi_336) Trail.Pips = gi_336;
   RefreshRates();
   if (Auto.SL.Prev.Bars.to.Count > WHOLE_ARRAY) {
      gd_500 = High[iHighest(NULL, Auto.SL.Prev.Bars.TimeFrame, MODE_HIGH, Auto.SL.Prev.Bars.to.Count, 1)] + Slippage * vPoint;
      gd_508 = Low[iLowest(NULL, Auto.SL.Prev.Bars.TimeFrame, MODE_LOW, Auto.SL.Prev.Bars.to.Count, 1)] - Slippage * vPoint;
   } else {
      gd_500 = Bid + StopLoss.Pips.Shorts * vPoint;
      gd_508 = Ask - StopLoss.Pips.Longs * vPoint;
   }
   f0_19();
   gi_368 = f0_9(Symbol(), Period());
   if (TimeHour(iTime(NULL, PERIOD_D1, 0)) == 0 && TimeMinute(iTime(NULL, PERIOD_D1, 0)) <= 1 && gi_464) gi_464 = FALSE;
   int li_28 = 0;
   if (Initial.TP3 > 0) {
      gi_540 = Initial.TP3 * 2;
      li_28 = 3;
   } else {
      if (Initial.TP2 > 0) {
         gi_540 = Initial.TP2 * 2;
         li_28 = 2;
      } else {
         if (Initial.TP1 > 0) {
            gi_540 = Initial.TP1 * 2;
            li_28 = 1;
         } else {
            Alert("Error 3001 - INITIAL.TP1 CANNOT BE 0\nThe expert is DISABLED");
            return (0);
         }
      }
   }
   if (Use.Money.Management) {
      Initial.TP2 = 0;
      Initial.TP3 = 0;
      gd_664 = f0_18(1);
      gd_672 = f0_18(2);
      Take.Out.Lots = Lot.Size;
   } else {
      gd_664 = 0;
      gd_672 = 0;
      if (Lot.Size < Take.Out.Lots) Take.Out.Lots = Lot.Size;
      ld_0 = 100.0 * Lot.Size;
      ld_8 = 100.0 * Take.Out.Lots;
      if (MathMod(ld_0, ld_8) != 0.0) {
         Alert("Error 3002 - Lots size=", Lot.Size, "  Take Out=", Take.Out.Lots, "   Remainder=", MathMod(Lot.Size, Take.Out.Lots), "   Lot.Size is not an exact multiple of Take.Out.Lots.\nLot.Size Divided by Take.Out.Lots leaves a remainder\nThe expert is DISABLED");
         return (0);
      }
      ld_16 = NormalizeDouble(Lot.Size / Take.Out.Lots, 0);
      if (ld_16 != li_28) {
         if (ld_16 <= li_28) return (0);
         Alert("Error 3003 - You have set more lots to take out (", ld_16, ") than take profit levels (", li_28, ")\nThe expert is DISABLED");
         return (0);
      }
   }
   f0_6();
   if (ShutDown.NOW && gi_372 > 0) {
      f0_7(ShutDown.What);
      return (0);
   }
   if (ShutDown.NOW) {
      Alert("Caution - ShutDown.NOW parameter enabled. You dont have any open/pending trade, the EA is disabled, you must set it to False NOW");
      return (0);
   }
   f0_6();
   f0_12();
   li_24 = f0_15();
   if (li_24 == 1) {
      Alert("Error 9001 - Contact Support at [email protected]");
      return (0);
   }
   if ((f0_5(1) == 1 && Enable.News.Trading && (!gi_464)) || Place.Straddle.Immediately) {
      if (gi_356 == 0 && gi_352 == 0 && gi_348 == 0 && gi_344 == 0) {
         f0_3();
         return (0);
      }
   }
   if (Debug) Print(f0_5(1), "   ", f0_5(2), "  ", gi_516, "   ", gi_520);
   f0_6();
   if (f0_5(2) == 1 && gi_356 > 0 && gi_352 > 0 && gi_348 == 0 && gi_344 == 0 && gi_392 != gi_400 && Adjust.Pending.Orders && Enable.News.Trading && (!Place.Straddle.Immediately)) {
      f0_0();
      return (0);
   }
   f0_6();
   if (Remove.Opposite.Order) {
      if ((gi_348 > 0 && gi_352 > 0) || (gi_344 > 0 && gi_356 > 0)) {
         f0_11();
         return (0);
      }
   }
   if (Enable.News.Trading) f0_17();
   f0_6();
   if (gi_348 > 0 || gi_344 > 0 || gi_360 > 0 || gi_364 > 0) {
      if (Move.To.BreakEven.at.pips != 0) f0_1();
      Sleep(2000);
      if (!Use.Money.Management) f0_20();
      Sleep(2000);
      f0_21();
   }
   f0_13();
   return (0);
}

double f0_18(int ai_0) {
   if (ai_0 == 1) {
      gd_592 = AccountBalance() * Trade.Maximum.Risk / (gd_616 * StopLoss.Pips.Longs);
      gd_592 = StrToDouble(DoubleToStr(gd_592, gd_568));
      if (gd_592 < gd_576) gd_592 = gd_576;
      if (gd_592 <= gd_584) return (gd_592);
      gd_592 = gd_584;
      return (gd_592);
   }
   gd_600 = AccountBalance() * Trade.Maximum.Risk / (gd_616 * StopLoss.Pips.Shorts);
   gd_600 = StrToDouble(DoubleToStr(gd_600, gd_568));
   if (gd_600 < gd_576) gd_600 = gd_576;
   if (gd_600 > gd_584) gd_600 = gd_584;
   return (gd_600);
}

void f0_17() {
   int li_0;
   int li_4 = f0_15();
   if (li_4 == 1) {
      Alert("Error 9002 - Contact Support at [email protected]");
      return;
   }
   f0_2();
   if (Kill.Pending.After.Seconds > 0 && gi_352 > 0 || gi_356 > 0 && Enable.News.Trading && gi_516 >= gi_520 + Kill.Pending.After.Seconds) {
      if (gi_352 > 0) {
         OrderSelect(gi_352, SELECT_BY_TICKET);
         gi_384 = 0;
         while (gi_384 < 5 && !IsTradeAllowed()) {
            gi_384++;
            Sleep(2000);
         }
         OrderDelete(gi_352);
         li_0 = GetLastError();
         if (li_0 > 0/* NO_ERROR */) Print("Error 5001 - Error Removing Long Pending Order after time expiration ticket=", gi_352, "  ", ErrorDescription(GetLastError()));
         Sleep(2000);
      }
      if (gi_356 > 0) {
         OrderSelect(gi_356, SELECT_BY_TICKET);
         gi_384 = 0;
         while (gi_384 < 5 && !IsTradeAllowed()) {
            gi_384++;
            Sleep(2000);
         }
         OrderDelete(gi_356);
         li_0 = GetLastError();
         if (li_0 > 0/* NO_ERROR */) Print("Error 5002 - Error Removing Short Pending Order after time expiration ticket=", gi_356, "  ", ErrorDescription(GetLastError()));
         Sleep(2000);
      }
   }
   if (Kill.Triggered.After.Seconds > 0 && gi_344 > 0 || gi_348 > 0 && Enable.News.Trading && gi_516 >= gi_520 + Kill.Triggered.After.Seconds) {
      if (gi_344 > 0) {
         OrderSelect(gi_344, SELECT_BY_TICKET);
         gi_384 = 0;
         while (gi_384 < 5 && !IsTradeAllowed()) {
            gi_384++;
            Sleep(2000);
         }
         RefreshRates();
         OrderClose(gi_344, OrderLots(), Bid, Slippage, Red);
         li_0 = GetLastError();
         if (li_0 > 0/* NO_ERROR */) Print("Error 5003 - Error Closing Long Order after time expiration ticket=", gi_344, "  ", ErrorDescription(GetLastError()));
         Sleep(2000);
      }
      if (gi_348 > 0) {
         OrderSelect(gi_348, SELECT_BY_TICKET);
         gi_384 = 0;
         while (gi_384 < 5 && !IsTradeAllowed()) {
            gi_384++;
            Sleep(2000);
         }
         RefreshRates();
         OrderClose(gi_348, OrderLots(), Ask, Slippage, Blue);
         li_0 = GetLastError();
         if (li_0 > 0/* NO_ERROR */) Print("Error 5004 - Error Closing Short Order after time expiration ticket=", gi_348, "  ", ErrorDescription(GetLastError()));
         Sleep(2000);
      }
   }
}

void f0_2() {
   int li_0 = f0_15();
   if (li_0 == 1) {
      Alert("Error 9003 - Contact Support at [email protected]");
      return;
   }
   gi_388 = TimeHour(TimeCurrent());
   gi_392 = TimeMinute(TimeCurrent());
   gi_396 = TimeSeconds(TimeCurrent());
   if (Event.Start.Hour == 0) Event.Start.Hour = 24;
   if (gi_388 == 0) gi_388 = 24;
   if (Pre.Event.Entry.Seconds == 0) Pre.Event.Entry.Seconds = 60;
   gi_516 = 60 * (60 * gi_388) + 60 * gi_392 + gi_396;
   gi_520 = 60 * (60 * Event.Start.Hour) + 60 * Event.Start.Minutes;
}

int f0_5(int ai_0) {
   int li_4 = f0_15();
   if (li_4 == 1) {
      Alert("Error 9004 - Contact Support at [email protected]");
      return (0);
   }
   f0_2();
   if (gi_516 >= gi_520) return (-1);
   if (gi_520 - Pre.Event.Entry.Seconds > gi_516) return (-2);
   if (ai_0 == 1) {
      if (gi_520 - Pre.Event.Entry.Seconds > gi_516) return (-3);
      return (1);
   }
   if (ai_0 == 2) {
      if (gi_520 - Pre.Event.Entry.Seconds > gi_516) return (-5);
      if (gi_520 - Stop.Adjusting.Sec.Before.Event <= gi_516) return (-4);
      return (1);
      return (-5);
   }
   Alert("Error 7001 - PROBLEM WITH TIME EVENT - Procedure --> IsTimeToPlaceAndAdjustEntries");
   return (0);
}

void f0_3() {
   double ld_0;
   double ld_8;
   double ld_16;
   double ld_24;
   double ld_32;
   double ld_40;
   int li_52;
   int li_48 = 0;
   if ((Place.Straddle.Immediately || (Enable.News.Trading && (!gi_464)))) {
      if (Use.Money.Management) {
         ld_40 = gd_664;
         ld_32 = gd_672;
      } else {
         ld_40 = Lot.Size;
         ld_32 = Lot.Size;
      }
      li_52 = f0_15();
      if (li_52 == 1) Alert("Error 9005 - Contact Support at [email protected]");
      else {
         while (gi_356 == 0) {
            while (li_48 < 5 && !IsTradeAllowed()) {
               li_48++;
               Sleep(2000);
            }
            RefreshRates();
            ld_0 = NormalizeDouble(Bid - Distance.From.Price.Shorts * vPoint, Digits);
            if (Auto.SL.Prev.Bars.to.Count > WHOLE_ARRAY) ld_24 = gd_500;
            else ld_24 = ld_0 + StopLoss.Pips.Shorts * vPoint;
            if (Initial.TP3 > 0) ld_16 = NormalizeDouble(ld_0 - Initial.TP3 * vPoint, Digits);
            else {
               if (Initial.TP2 > 0) ld_16 = NormalizeDouble(ld_0 - Initial.TP2 * vPoint, Digits);
               else ld_16 = NormalizeDouble(ld_0 - Initial.TP1 * vPoint, Digits);
            }
            gi_340 = OrderSend(Symbol(), OP_SELLSTOP, ld_32, ld_0, Slippage, ld_24, ld_16, "Straddle&Trail " + DoubleToStr(Period(), 0) + "min ", gi_368, 0, OrangeRed);
            if (gi_340 <= 0) Print("Error 8001 - Error opening SellStop  ", ErrorDescription(GetLastError()), "  Ask=", Ask, "   Bid=", Bid, "   Entry @ ", ld_0, "   SL=", ld_24, "    TP=", ld_16);
            else gi_524 = TRUE;
            f0_6();
         }
         while (gi_352 == 0) {
            li_48 = 0;
            while (li_48 < 5 && !IsTradeAllowed()) {
               li_48++;
               Sleep(2000);
            }
            RefreshRates();
            ld_8 = NormalizeDouble(Ask + Distance.From.Price.Longs * vPoint, Digits);
            if (Auto.SL.Prev.Bars.to.Count > WHOLE_ARRAY) ld_24 = gd_508;
            else ld_24 = ld_8 - StopLoss.Pips.Longs * vPoint;
            if (Initial.TP3 > 0) ld_16 = NormalizeDouble(ld_8 + Initial.TP3 * vPoint, Digits);
            else {
               if (Initial.TP2 > 0) ld_16 = NormalizeDouble(ld_8 + Initial.TP2 * vPoint, Digits);
               else ld_16 = NormalizeDouble(ld_8 + Initial.TP1 * vPoint, Digits);
            }
            gi_340 = OrderSend(Symbol(), OP_BUYSTOP, ld_40, ld_8, Slippage, ld_24, ld_16, "Straddle&Trail " + DoubleToStr(Period(), 0) + "min ", gi_368, 0, RoyalBlue);
            if (gi_340 <= 0) Print("Error 8002 - Error opening BuyStop  ", ErrorDescription(GetLastError()), "  Ask=", Ask, "   Bid=", Bid, "   Entry @ ", ld_8, "   SL=", ld_24, "    TP=", ld_16);
            else gi_524 = TRUE;
            f0_6();
         }
      }
   }
}

void f0_11() {
   int li_0;
   if (gi_352 > 0) {
      OrderSelect(gi_352, SELECT_BY_TICKET);
      gi_384 = 0;
      while (gi_384 < 5 && !IsTradeAllowed()) {
         gi_384++;
         Sleep(2000);
      }
      OrderDelete(gi_352);
      li_0 = GetLastError();
      if (li_0 > 0/* NO_ERROR */) Print("Error 8101 - Error Removing Long Pending Order ticket=", gi_352, "  ", ErrorDescription(GetLastError()));
   }
   if (gi_356 > 0) {
      OrderSelect(gi_356, SELECT_BY_TICKET);
      gi_384 = 0;
      while (gi_384 < 5 && !IsTradeAllowed()) {
         gi_384++;
         Sleep(2000);
      }
      OrderDelete(gi_356);
      li_0 = GetLastError();
      if (li_0 > 0/* NO_ERROR */) Print("Error 8102 - Error Removing Short Pending Order ticket=", gi_356, "  ", ErrorDescription(GetLastError()));
   }
}

void f0_0() {
   gi_460 = FALSE;
   if (gi_352 < 1 && gi_356 < 1) return;
   int li_0 = f0_15();
   if (li_0 == 1) {
      Alert("Error 9006 - Contact Support at [email protected]");
      return;
   }
   while (gi_384 < 5 && !IsTradeAllowed()) {
      gi_384++;
      Sleep(2000);
   }
   RefreshRates();
   gd_468 = NormalizeDouble(Ask + Distance.From.Price.Longs * vPoint, Digits);
   if (Auto.SL.Prev.Bars.to.Count > WHOLE_ARRAY) gd_484 = gd_508;
   else gd_484 = gd_468 - StopLoss.Pips.Longs * vPoint;
   if (Initial.TP3 > 0) gd_492 = NormalizeDouble(gd_468 + Initial.TP3 * vPoint, Digits);
   else {
      if (Initial.TP2 > 0) gd_492 = NormalizeDouble(gd_468 + Initial.TP2 * vPoint, Digits);
      else gd_492 = NormalizeDouble(gd_468 + Initial.TP1 * vPoint, Digits);
   }
   OrderSelect(gi_352, SELECT_BY_TICKET);
   OrderModify(gi_352, gd_468, gd_484, gd_492, OrderExpiration(), MediumSpringGreen);
   gi_404 = GetLastError();
   if (ErrorDescription(GetLastError()) != "no error") {
      Print("Error 8201 - Error Adjusting Long Pending Order ticket=", gi_352, "  ", ErrorDescription(GetLastError()), "  Buy at=", gd_468, "  SL=", gd_508, "   TP=", gd_492);
      return;
   }
   Sleep(3000);
   while (gi_384 < 5 && !IsTradeAllowed()) {
      gi_384++;
      Sleep(2000);
   }
   RefreshRates();
   gd_476 = NormalizeDouble(Bid - Distance.From.Price.Shorts * vPoint, Digits);
   if (Auto.SL.Prev.Bars.to.Count > WHOLE_ARRAY) gd_484 = gd_500;
   else gd_484 = gd_476 + StopLoss.Pips.Shorts * vPoint;
   if (Initial.TP3 > 0) gd_492 = NormalizeDouble(gd_476 - Initial.TP3 * vPoint, Digits);
   else {
      if (Initial.TP2 > 0) gd_492 = NormalizeDouble(gd_476 - Initial.TP2 * vPoint, Digits);
      else gd_492 = NormalizeDouble(gd_476 - Initial.TP1 * vPoint, Digits);
   }
   OrderSelect(gi_356, SELECT_BY_TICKET);
   OrderModify(gi_356, gd_476, gd_484, gd_492, OrderExpiration(), MediumVioletRed);
   gi_404 = GetLastError();
   if (ErrorDescription(GetLastError()) != "no error") {
      Print("Error 8202 - Error Adjusting Short Pending Order ticket=", gi_356, "  ", ErrorDescription(GetLastError()), "  Sell at=", gd_476, "  SL=", gd_500, "   TP=",
         gd_492);
      return;
   }
   gi_400 = gi_392;
   Sleep(3000);
}

void f0_6() {
   gi_344 = 0;
   gi_348 = 0;
   gi_352 = 0;
   gi_356 = 0;
   gi_372 = 0;
   int li_0 = f0_15();
   if (li_0 == 1) {
      Alert("Error 9007 - Contact Support at [email protected]");
      return;
   }
   for (int li_4 = OrdersTotal() - 1; li_4 >= 0; li_4--) {
      OrderSelect(li_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == gi_368) {
         if (OrderType() == OP_SELL) gi_348 = OrderTicket();
         if (OrderType() == OP_SELLSTOP) gi_356 = OrderTicket();
         if (OrderType() == OP_BUY) gi_344 = OrderTicket();
         if (OrderType() == OP_BUYSTOP) gi_352 = OrderTicket();
         gi_372++;
         if (gi_372 > 0 && Enable.News.Trading && (!Place.Straddle.Immediately)) gi_464 = TRUE;
      }
      if (gi_372 == 0) {
         if (gi_524 == TRUE) {
            for (int li_8 = 0; li_8 < ObjectsTotal(); li_8++) {
               ObjectsDeleteAll(0, OBJ_ARROW);
               ObjectsDeleteAll(0, OBJ_TREND);
            }
            gi_524 = FALSE;
         }
      }
      if (gi_372 > 0 && OrderSymbol() == Symbol() && OrderMagicNumber() == 0) {
         if (OrderType() == OP_SELL) gi_364 = OrderTicket();
         if (OrderType() == OP_BUY) gi_360 = OrderTicket();
         gi_372++;
      }
   }
   if (gi_372 == 0) {
      for (li_8 = 0; li_8 < ObjectsTotal(); li_8++) {
         ObjectsDeleteAll(0, OBJ_ARROW);
         ObjectsDeleteAll(0, OBJ_TREND);
      }
   }
}

void f0_20() {
   double ld_0;
   double ld_8;
   double ld_16;
   double ld_24;
   int li_32;
   int li_36;
   int li_40;
   f0_6();
   int li_44 = f0_15();
   if (li_44 == 1) {
      Alert("Error 9010 - Contact Support at [email protected]");
      return;
   }
   if (gi_344 > 0) {
      OrderSelect(gi_344, SELECT_BY_TICKET);
      ld_0 = NormalizeDouble(Lot.Size, 2);
      ld_8 = NormalizeDouble(Take.Out.Lots, 2);
      ld_16 = NormalizeDouble(OrderLots(), 2);
      li_32 = 100.0 * ld_0;
      li_36 = 100.0 * ld_8;
      li_40 = 100.0 * ld_16;
      if (li_32 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP1 * vPoint, Digits);
      if (li_32 == 2 * li_36) {
         if (li_40 == li_32) ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP1 * vPoint, Digits);
         else
            if (li_40 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP2 * vPoint, Digits);
      }
      if (li_32 == 3 * li_36) {
         if (li_40 == li_32) ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP1 * vPoint, Digits);
         else {
            if (li_40 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP3 * vPoint, Digits);
            else ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP2 * vPoint, Digits);
         }
      }
      RefreshRates();
      gi_376 = NormalizeDouble(Bid - OrderOpenPrice(), Digits) / vPoint;
      if (Bid >= ld_24) {
         gi_380 = 0;
         while (gi_380 < 5 && !IsTradeAllowed()) {
            gi_380++;
            Sleep(2000);
         }
         RefreshRates();
         if (OrderClose(OrderTicket(), Take.Out.Lots, Bid, Slippage, YellowGreen)) Sleep(2000);
         else Print("Error 8401 - Error Closing Long Entry Target @ ", NormalizeDouble(ld_24, Digits));
      }
   }
   if (gi_360 > 0) {
      OrderSelect(gi_360, SELECT_BY_TICKET);
      ld_0 = NormalizeDouble(Lot.Size, 2);
      ld_8 = NormalizeDouble(Take.Out.Lots, 2);
      ld_16 = NormalizeDouble(OrderLots(), 2);
      li_32 = 100.0 * ld_0;
      li_36 = 100.0 * ld_8;
      li_40 = 100.0 * ld_16;
      if (li_32 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP1 * vPoint, Digits);
      if (li_32 == 2 * li_36) {
         if (li_40 == li_32) ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP1 * vPoint, Digits);
         else
            if (li_40 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP2 * vPoint, Digits);
      }
      if (li_32 == 3 * li_36) {
         if (li_40 == li_32) ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP1 * vPoint, Digits);
         else {
            if (li_40 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP3 * vPoint, Digits);
            else ld_24 = NormalizeDouble(OrderOpenPrice() + Initial.TP2 * vPoint, Digits);
         }
      }
      RefreshRates();
      gi_376 = NormalizeDouble(Bid - OrderOpenPrice(), Digits) / vPoint;
      if (Bid >= ld_24) {
         gi_380 = 0;
         while (gi_380 < 5 && !IsTradeAllowed()) {
            gi_380++;
            Sleep(2000);
         }
         RefreshRates();
         if (OrderClose(OrderTicket(), Take.Out.Lots, Bid, Slippage, YellowGreen)) Sleep(2000);
         else Print("Error 8402 - Error Closing Long Entry Target @ ", NormalizeDouble(ld_24, Digits));
      }
   }
   if (gi_348 > 0) {
      OrderSelect(gi_348, SELECT_BY_TICKET);
      ld_0 = NormalizeDouble(Lot.Size, 2);
      ld_8 = NormalizeDouble(Take.Out.Lots, 2);
      ld_16 = NormalizeDouble(OrderLots(), 2);
      li_32 = 100.0 * ld_0;
      li_36 = 100.0 * ld_8;
      li_40 = 100.0 * ld_16;
      if (li_32 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP1 * vPoint, Digits);
      if (li_32 == 2 * li_36) {
         if (li_40 == li_32) ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP1 * vPoint, Digits);
         else
            if (li_40 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP2 * vPoint, Digits);
      }
      if (li_32 == 3 * li_36) {
         if (li_40 == li_32) ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP1 * vPoint, Digits);
         else {
            if (li_40 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP3 * vPoint, Digits);
            else ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP2 * vPoint, Digits);
         }
      }
      RefreshRates();
      gi_376 = NormalizeDouble(OrderOpenPrice() - Ask, Digits) / vPoint;
      if (Ask <= ld_24) {
         gi_380 = 0;
         while (gi_380 < 5 && !IsTradeAllowed()) {
            gi_380++;
            Sleep(2000);
         }
         RefreshRates();
         if (OrderClose(OrderTicket(), Take.Out.Lots, Ask, Slippage, YellowGreen)) Sleep(2000);
         else Print("Error 8403 - Error Closing Short Entry Target @ ", NormalizeDouble(ld_24, Digits));
      }
   }
   if (gi_364 > 0) {
      OrderSelect(gi_364, SELECT_BY_TICKET);
      ld_0 = NormalizeDouble(Lot.Size, 2);
      ld_8 = NormalizeDouble(Take.Out.Lots, 2);
      ld_16 = NormalizeDouble(OrderLots(), 2);
      li_32 = 100.0 * ld_0;
      li_36 = 100.0 * ld_8;
      li_40 = 100.0 * ld_16;
      if (li_32 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP1 * vPoint, Digits);
      if (li_32 == 2 * li_36) {
         if (li_40 == li_32) ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP1 * vPoint, Digits);
         else
            if (li_40 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP2 * vPoint, Digits);
      }
      if (li_32 == 3 * li_36) {
         if (li_40 == li_32) ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP1 * vPoint, Digits);
         else {
            if (li_40 == li_36) ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP3 * vPoint, Digits);
            else ld_24 = NormalizeDouble(OrderOpenPrice() - Initial.TP2 * vPoint, Digits);
         }
      }
      RefreshRates();
      gi_376 = NormalizeDouble(OrderOpenPrice() - Ask, Digits) / vPoint;
      if (Ask <= ld_24) {
         gi_380 = 0;
         while (gi_380 < 5 && !IsTradeAllowed()) {
            gi_380++;
            Sleep(2000);
         }
         RefreshRates();
         if (OrderClose(OrderTicket(), Take.Out.Lots, Ask, Slippage, YellowGreen)) {
            Sleep(2000);
            return;
         }
         Print("Error 8404 - Error Closing Short Entry Target @ ", NormalizeDouble(ld_24, Digits));
      }
   }
}

void f0_10(int ai_0) {
   double ld_4;
   double ld_12;
   double ld_20;
   double ld_28;
   f0_6();
   int li_36 = f0_15();
   if (li_36 == 1) {
      Alert("Error 9011 - Contact Support at [email protected]");
      return;
   }
   if (ai_0 == 0) {
      if (gi_344 > 0) {
         ld_4 = Trail.Pips * vPoint;
         OrderSelect(gi_344, SELECT_BY_TICKET);
         RefreshRates();
         if (Bid > OrderOpenPrice() + ld_4 && OrderStopLoss() < OrderOpenPrice() + (Bid - (OrderOpenPrice() + ld_4))) {
            ld_12 = NormalizeDouble(OrderOpenPrice() + (Bid - (OrderOpenPrice() + ld_4)), Digits);
            if (OrderStopLoss() < ld_12) {
               while (gi_384 < 5 && !IsTradeAllowed()) {
                  gi_384++;
                  Sleep(2000);
               }
               OrderModify(gi_344, OrderOpenPrice(), ld_12, OrderTakeProfit(), OrderExpiration(), MediumSpringGreen);
               Sleep(2000);
            }
         }
      }
      if (gi_348 > 0) {
         ld_20 = Trail.Pips * vPoint;
         OrderSelect(gi_348, SELECT_BY_TICKET);
         RefreshRates();
         if (Ask < OrderOpenPrice() - ld_20 && OrderStopLoss() > OrderOpenPrice() - (OrderOpenPrice() - ld_20) - Ask) {
            ld_28 = NormalizeDouble(OrderOpenPrice() - (OrderOpenPrice() - ld_20 - Ask), Digits);
            if (OrderStopLoss() > ld_28) {
               while (gi_384 < 5 && !IsTradeAllowed()) {
                  gi_384++;
                  Sleep(2000);
               }
               OrderModify(gi_348, OrderOpenPrice(), ld_28, OrderTakeProfit(), OrderExpiration(), MediumVioletRed);
               Sleep(2000);
            }
         }
      }
      if (gi_360 > 0) {
         ld_4 = Trail.Pips * vPoint;
         OrderSelect(gi_360, SELECT_BY_TICKET);
         RefreshRates();
         if (Bid > OrderOpenPrice() + ld_4 && OrderStopLoss() < OrderOpenPrice() + (Bid - (OrderOpenPrice() + ld_4))) {
            ld_12 = NormalizeDouble(OrderOpenPrice() + (Bid - (OrderOpenPrice() + ld_4)), Digits);
            if (OrderStopLoss() < ld_12) {
               while (gi_384 < 5 && !IsTradeAllowed()) {
                  gi_384++;
                  Sleep(2000);
               }
               OrderModify(gi_360, OrderOpenPrice(), ld_12, OrderTakeProfit(), OrderExpiration(), MediumSpringGreen);
               Sleep(2000);
            }
         }
      }
      if (gi_364 <= 0) return;
      ld_20 = Trail.Pips * vPoint;
      RefreshRates();
      OrderSelect(gi_364, SELECT_BY_TICKET);
      if (!(Ask < OrderOpenPrice() - ld_20 && OrderStopLoss() > OrderOpenPrice() - (OrderOpenPrice() - ld_20) - Ask)) return;
      ld_28 = NormalizeDouble(OrderOpenPrice() - (OrderOpenPrice() - ld_20 - Ask), Digits);
      if (OrderStopLoss() <= ld_28) return;
      while (gi_384 < 5 && !IsTradeAllowed()) {
         gi_384++;
         Sleep(2000);
      }
      OrderModify(gi_364, OrderOpenPrice(), ld_28, OrderTakeProfit(), OrderExpiration(), MediumVioletRed);
      Sleep(2000);
      return;
   }
   if (gi_344 > 0) {
      OrderSelect(gi_344, SELECT_BY_TICKET);
      RefreshRates();
      if (Bid >= OrderOpenPrice() + Move.To.BreakEven.at.pips * vPoint) {
         ld_4 = Trail.Pips * vPoint;
         if (Bid > OrderOpenPrice() + ld_4 && OrderStopLoss() < OrderOpenPrice() + (Bid - (OrderOpenPrice() + ld_4))) {
            ld_12 = NormalizeDouble(OrderOpenPrice() + (Bid - (OrderOpenPrice() + ld_4)), Digits);
            if (OrderStopLoss() < ld_12) {
               while (gi_384 < 5 && !IsTradeAllowed()) {
                  gi_384++;
                  Sleep(2000);
               }
               OrderModify(gi_344, OrderOpenPrice(), ld_12, OrderTakeProfit(), OrderExpiration(), MediumSpringGreen);
               Sleep(2000);
            }
         }
      }
   }
   if (gi_348 > 0) {
      OrderSelect(gi_348, SELECT_BY_TICKET);
      RefreshRates();
      if (Ask <= OrderOpenPrice() - Move.To.BreakEven.at.pips * vPoint) {
         ld_20 = Trail.Pips * vPoint;
         if (Ask < OrderOpenPrice() - ld_20 && OrderStopLoss() > OrderOpenPrice() - (OrderOpenPrice() - ld_20) - Ask) {
            ld_28 = NormalizeDouble(OrderOpenPrice() - (OrderOpenPrice() - ld_20 - Ask), Digits);
            if (OrderStopLoss() > ld_28) {
               while (gi_384 < 5 && !IsTradeAllowed()) {
                  gi_384++;
                  Sleep(2000);
               }
               OrderModify(gi_348, OrderOpenPrice(), ld_28, OrderTakeProfit(), OrderExpiration(), MediumVioletRed);
               Sleep(2000);
            }
         }
      }
   }
   if (gi_360 > 0) {
      OrderSelect(gi_360, SELECT_BY_TICKET);
      RefreshRates();
      if (Bid >= OrderOpenPrice() + Move.To.BreakEven.at.pips * vPoint) {
         ld_4 = Trail.Pips * vPoint;
         if (Bid > OrderOpenPrice() + ld_4 && OrderStopLoss() < OrderOpenPrice() + (Bid - (OrderOpenPrice() + ld_4))) {
            ld_12 = NormalizeDouble(OrderOpenPrice() + (Bid - (OrderOpenPrice() + ld_4)), Digits);
            if (OrderStopLoss() < ld_12) {
               while (gi_384 < 5 && !IsTradeAllowed()) {
                  gi_384++;
                  Sleep(2000);
               }
               OrderModify(gi_360, OrderOpenPrice(), ld_12, OrderTakeProfit(), OrderExpiration(), MediumSpringGreen);
               Sleep(2000);
            }
         }
      }
   }
   if (gi_364 > 0) {
      OrderSelect(gi_364, SELECT_BY_TICKET);
      RefreshRates();
      if (Ask <= OrderOpenPrice() - Move.To.BreakEven.at.pips * vPoint) {
         ld_20 = Trail.Pips * vPoint;
         if (Ask < OrderOpenPrice() - ld_20 && OrderStopLoss() > OrderOpenPrice() - (OrderOpenPrice() - ld_20) - Ask) {
            ld_28 = NormalizeDouble(OrderOpenPrice() - (OrderOpenPrice() - ld_20 - Ask), Digits);
            if (OrderStopLoss() > ld_28) {
               while (gi_384 < 5 && !IsTradeAllowed()) {
                  gi_384++;
                  Sleep(2000);
               }
               OrderModify(gi_364, OrderOpenPrice(), ld_28, OrderTakeProfit(), OrderExpiration(), MediumVioletRed);
               Sleep(2000);
            }
         }
      }
   }
}

void f0_21() {
   if (Trail.Starts.After.BreakEven) {
      f0_10(1);
      return;
   }
   f0_10(0);
}

void f0_1() {
   f0_6();
   int li_0 = f0_15();
   if (li_0 == 1) {
      Alert("Error 9013 - Contact Support at [email protected]");
      return;
   }
   if (gi_344 > 0) {
      OrderSelect(gi_344, SELECT_BY_TICKET);
      RefreshRates();
      if (OrderStopLoss() < OrderOpenPrice()) {
         if (Bid > Move.To.BreakEven.at.pips * vPoint + OrderOpenPrice()) {
            while (gi_384 < 5 && !IsTradeAllowed()) {
               gi_384++;
               Sleep(2000);
            }
            OrderModify(gi_344, OrderOpenPrice(), OrderOpenPrice() + Move.To.BreakEven.Lock.pips * vPoint, OrderTakeProfit(), OrderExpiration(), MediumSpringGreen);
            if (OrderSelect(gi_344, SELECT_BY_TICKET, MODE_TRADES)) {
               Print("Long StopLoss Moved to BE at : ", OrderStopLoss());
               Sleep(2000);
            } else Print("Error 8501 - Error moving Long StopLoss to BE: ", GetLastError());
         }
      }
   }
   if (gi_348 > 0) {
      OrderSelect(gi_348, SELECT_BY_TICKET);
      RefreshRates();
      if (OrderStopLoss() > OrderOpenPrice()) {
         if (Ask < OrderOpenPrice() - Move.To.BreakEven.at.pips * vPoint) {
            while (gi_384 < 5 && !IsTradeAllowed()) {
               gi_384++;
               Sleep(2000);
            }
            OrderModify(gi_348, OrderOpenPrice(), OrderOpenPrice() - Move.To.BreakEven.Lock.pips * vPoint, OrderTakeProfit(), OrderExpiration(), MediumVioletRed);
            if (OrderSelect(gi_348, SELECT_BY_TICKET, MODE_TRADES)) {
               Print("Short StopLoss Moved to BE at : ", OrderStopLoss());
               Sleep(2000);
            } else Print("Error 8502 - Error moving Short StopLoss to BE: ", GetLastError());
         }
      }
   }
   if (gi_360 > 0) {
      OrderSelect(gi_360, SELECT_BY_TICKET);
      RefreshRates();
      if (OrderStopLoss() < OrderOpenPrice()) {
         if (Bid > Move.To.BreakEven.at.pips * vPoint + OrderOpenPrice()) {
            while (gi_384 < 5 && !IsTradeAllowed()) {
               gi_384++;
               Sleep(2000);
            }
            OrderModify(gi_360, OrderOpenPrice(), OrderOpenPrice() + Move.To.BreakEven.Lock.pips * vPoint, OrderTakeProfit(), OrderExpiration(), MediumSpringGreen);
            if (OrderSelect(gi_360, SELECT_BY_TICKET, MODE_TRADES)) {
               Print("Long StopLoss Moved to BE at : ", OrderStopLoss());
               Sleep(2000);
            } else Print("Error 8503 - Error moving Long StopLoss to BE: ", GetLastError());
         }
      }
   }
   if (gi_364 > 0) {
      OrderSelect(gi_364, SELECT_BY_TICKET);
      RefreshRates();
      if (OrderStopLoss() > OrderOpenPrice()) {
         if (Ask < OrderOpenPrice() - Move.To.BreakEven.at.pips * vPoint) {
            while (gi_384 < 5 && !IsTradeAllowed()) {
               gi_384++;
               Sleep(2000);
            }
            OrderModify(gi_364, OrderOpenPrice(), OrderOpenPrice() - Move.To.BreakEven.Lock.pips * vPoint, OrderTakeProfit(), OrderExpiration(), MediumVioletRed);
            if (OrderSelect(gi_364, SELECT_BY_TICKET, MODE_TRADES)) {
               Print("Short StopLoss Moved to BE at : ", OrderStopLoss());
               Sleep(2000);
               return;
            }
            Print("Error 8504 - Error moving Short StopLoss to BE: ", GetLastError());
         }
      }
   }
}

void f0_12() {
   int li_0;
   int li_4;
   RefreshRates();
   if (gi_344 > 0) {
      OrderSelect(gi_344, SELECT_BY_TICKET);
      if (OrderStopLoss() == 0.0 || OrderTakeProfit() == 0.0) {
         if (OrderStopLoss() == 0.0) li_0 = gd_508;
         if (OrderTakeProfit() == 0.0) {
            if (Initial.TP3 > 0) li_4 = Initial.TP3;
            else {
               if (Initial.TP2 > 0) li_4 = Initial.TP2;
               else li_4 = Initial.TP1;
            }
         }
         if ((li_0 > 0 && OrderStopLoss() == 0.0) || (li_4 > 0 && OrderTakeProfit() == 0.0)) {
            gi_384 = 0;
            while (gi_384 < 5 && !IsTradeAllowed()) {
               gi_384++;
               Sleep(2000);
            }
            OrderModify(gi_344, OrderOpenPrice(), OrderOpenPrice() - li_0 * vPoint, OrderOpenPrice() + li_4 * vPoint, OrderExpiration(), MediumSpringGreen);
            if (OrderSelect(gi_344, SELECT_BY_TICKET, MODE_TRADES)) {
               Print("Initial SL or TP is Set for Long Entry");
               Sleep(2000);
            } else Print("Error 8601 - Error setting initial SL or TP for Long Entry");
         }
      }
   }
   if (gi_348 > 0) {
      OrderSelect(gi_348, SELECT_BY_TICKET);
      if (OrderStopLoss() == 0.0 || OrderTakeProfit() == 0.0) {
         if (OrderStopLoss() == 0.0) li_0 = gd_500;
         if (OrderTakeProfit() == 0.0) {
            if (Initial.TP3 > 0) li_4 = Initial.TP3;
            else {
               if (Initial.TP2 > 0) li_4 = Initial.TP2;
               else li_4 = Initial.TP1;
            }
         }
         if ((li_0 > 0 && OrderStopLoss() == 0.0) || (li_4 > 0 && OrderTakeProfit() == 0.0)) {
            gi_384 = 0;
            while (gi_384 < 5 && !IsTradeAllowed()) {
               gi_384++;
               Sleep(2000);
            }
            OrderModify(gi_348, OrderOpenPrice(), OrderOpenPrice() + li_0 * vPoint, OrderOpenPrice() - li_4 * vPoint, OrderExpiration(), MediumVioletRed);
            if (OrderSelect(gi_348, SELECT_BY_TICKET, MODE_TRADES)) {
               Print("Initial SL or TP is Set for Short Entry");
               Sleep(2000);
            } else Print("Error 8602 - Error setting initial SL or TP for Short Entry");
         }
      }
   }
   if (gi_360 > 0) {
      OrderSelect(gi_360, SELECT_BY_TICKET);
      if (OrderStopLoss() == 0.0 || OrderTakeProfit() == 0.0) {
         if (OrderStopLoss() == 0.0) li_0 = gd_508;
         if (OrderTakeProfit() == 0.0) {
            if (Initial.TP3 > 0) li_4 = Initial.TP3;
            else {
               if (Initial.TP2 > 0) li_4 = Initial.TP2;
               else li_4 = Initial.TP1;
            }
         }
         if ((li_0 > 0 && OrderStopLoss() == 0.0) || (li_4 > 0 && OrderTakeProfit() == 0.0)) {
            gi_384 = 0;
            while (gi_384 < 5 && !IsTradeAllowed()) {
               gi_384++;
               Sleep(2000);
            }
            OrderModify(gi_360, OrderOpenPrice(), OrderOpenPrice() - li_0 * vPoint, OrderOpenPrice() + li_4 * vPoint, OrderExpiration(), MediumSpringGreen);
            if (OrderSelect(gi_360, SELECT_BY_TICKET, MODE_TRADES)) {
               Print("Initial SL or TP is Set for Long Entry");
               Sleep(2000);
            } else Print("Error 8603 - Error setting initial SL or TP for Long Entry");
         }
      }
   }
   if (gi_364 > 0) {
      OrderSelect(gi_364, SELECT_BY_TICKET);
      if (OrderStopLoss() == 0.0 || OrderTakeProfit() == 0.0) {
         if (OrderStopLoss() == 0.0) li_0 = gd_500;
         if (OrderTakeProfit() == 0.0) {
            if (Initial.TP3 > 0) li_4 = Initial.TP3;
            else {
               if (Initial.TP2 > 0) li_4 = Initial.TP2;
               else li_4 = Initial.TP1;
            }
         }
         if ((li_0 > 0 && OrderStopLoss() == 0.0) || (li_4 > 0 && OrderTakeProfit() == 0.0)) {
            gi_384 = 0;
            while (gi_384 < 5 && !IsTradeAllowed()) {
               gi_384++;
               Sleep(2000);
            }
            OrderModify(gi_364, OrderOpenPrice(), OrderOpenPrice() + li_0 * vPoint, OrderOpenPrice() - li_4 * vPoint, OrderExpiration(), MediumVioletRed);
            if (OrderSelect(gi_364, SELECT_BY_TICKET, MODE_TRADES)) {
               Print("Initial SL or TP is Set for Short Entry");
               Sleep(2000);
               return;
            }
            Print("Error 8604 - Error setting initial SL or TP for Short Entry");
         }
      }
   }
}

void f0_7(int ai_0) {
   int li_4;
   int li_8 = f0_15();
   if (li_8 == 1) {
      Alert("Error 9015 - Contact Support at [email protected]");
      return;
   }
   for (int li_12 = OrdersTotal() - 1; li_12 >= 0; li_12--) {
      OrderSelect(li_12, SELECT_BY_POS, MODE_TRADES);
      if ((ShutDown.Current.Pair.Only && OrderSymbol() == Symbol()) || (!ShutDown.Current.Pair.Only)) {
         if (OrderType() == OP_BUY && ai_0 == 0 || ai_0 == 1 || ai_0 == 2) {
            li_4 = 0;
            while (li_4 < 5 && !IsTradeAllowed()) {
               li_4++;
               Sleep(1000);
            }
            RefreshRates();
            OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Yellow);
            Sleep(1000);
         }
         if (OrderType() == OP_SELL && ai_0 == 0 || ai_0 == 1 || ai_0 == 3) {
            li_4 = 0;
            while (li_4 < 5 && !IsTradeAllowed()) {
               li_4++;
               Sleep(1000);
            }
            RefreshRates();
            OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Yellow);
            Sleep(1000);
         }
         if (OrderType() == OP_BUYSTOP && ai_0 == 0 || ai_0 == 4 || ai_0 == 5) {
            li_4 = 0;
            while (li_4 < 5 && !IsTradeAllowed()) {
               li_4++;
               Sleep(1000);
            }
            OrderDelete(OrderTicket());
            Sleep(1000);
         }
         if (OrderType() == OP_SELLSTOP && ai_0 == 0 || ai_0 == 4 || ai_0 == 6) {
            li_4 = 0;
            while (li_4 < 5 && !IsTradeAllowed()) {
               li_4++;
               Sleep(1000);
            }
            OrderDelete(OrderTicket());
            Sleep(1000);
         }
      }
   }
}

void f0_13() {
   string ls_0;
   string ls_8 = "";
   string ls_16 = "";
   string ls_24 = "";
   string ls_32 = "";
   string ls_40 = "";
   string ls_48 = "";
   int li_56 = 0;
   double ld_60 = 0;
   f0_6();
   RefreshRates();
   if (gi_344 > 0) {
      OrderSelect(gi_344, SELECT_BY_TICKET);
      li_56 = NormalizeDouble((Bid - OrderOpenPrice()) / vPoint, Digits);
      ld_60 = OrderProfit();
   } else {
      if (gi_348 > 0) {
         OrderSelect(gi_348, SELECT_BY_TICKET);
         li_56 = NormalizeDouble((OrderOpenPrice() - Ask) / vPoint, Digits);
         ld_60 = OrderProfit();
      } else {
         if (gi_360 > 0) {
            OrderSelect(gi_360, SELECT_BY_TICKET);
            li_56 = NormalizeDouble((Bid - OrderOpenPrice()) / vPoint, Digits);
            ld_60 = OrderProfit();
         } else {
            if (gi_364 > 0) {
               OrderSelect(gi_364, SELECT_BY_TICKET);
               li_56 = NormalizeDouble((OrderOpenPrice() - Ask) / vPoint, Digits);
               ld_60 = OrderProfit();
            }
         }
      }
   }
   if (Move.To.BreakEven.at.pips > 0) {
      ls_16 = "S/L will move to B/E after: " + Move.To.BreakEven.at.pips + " pips and lock: " + Move.To.BreakEven.Lock.pips + " pips" 
      + "\n";
   } else ls_16 = "";
   if (Enable.News.Trading) {
      if (!gi_464) ls_32 = "NEWS TRADING IS ENABLED (UNTIL FIRST ENTRY)";
      else ls_32 = "STRADDLE IS PLACED";
      ls_32 = ls_32 
      + "\nEA WILL BE RESET AT MIDNIGHT\nUNLESS YOU RESET IT MANUALLY\nThat means the EA will work ONCE a day if not reset";
   } else ls_32 = "";
   if ((!Place.Straddle.Immediately) && Enable.News.Trading) {
      if (Adjust.Pending.Orders) {
         ls_24 = StringConcatenate("A straddle is to be placed ", DoubleToStr(Pre.Event.Entry.Seconds, 0), " Seconds before news \nat ", DoubleToStr(Distance.From.Price.Longs,
            0), " pips above and ", DoubleToStr(Distance.From.Price.Shorts, 0), " pips below price \nAdjusting every minute until ", DoubleToStr(Stop.Adjusting.Sec.Before.Event,
            0), " seconds before event time");
      }
   } else ls_24 = "";
   if (Initial.TP3 > 0) gd_492 = Initial.TP3;
   else {
      if (Initial.TP2 > 0) gd_492 = Initial.TP2;
      else gd_492 = Initial.TP1;
   }
   if (ls_32 != "") {
      Comment("\n\n", "Minimum allowed for SL & TP is ", gi_336, " pips", 
         "\n", "SL Longs: ", gd_508, " Shorts:", gd_500, "  TP:", gd_492, "  Trail:", Trail.Pips, 
         "\n", ls_16, 
         "\n", ls_24, 
      "\n\n", ls_32);
      return;
   }
   Comment("\n\n", "Minimum allowed for SL & TP is ", gi_336, " pips", 
      "\n", "SL Longs: ", gd_508, " Shorts:", gd_500, "  TP:", gd_492, "  Trail:", Trail.Pips, 
      "\n", ls_16, 
   "\n", ls_24);
}

string f0_14(string as_0, string as_8) {
   string ls_16;
   string ls_24;
   int li_32 = StrToInteger(as_0);
   int li_36 = StrToInteger(as_8);
   if (li_32 >= 0 && li_32 <= 9) ls_16 = "0";
   else ls_16 = "";
   if (li_36 >= 0 && li_36 <= 9) ls_24 = "0";
   else ls_24 = "";
   return (StringConcatenate(ls_16, as_0, ":", ls_24, as_8));
}

void f0_19() {
   string ls_0;
   string ls_8;
   string ls_16;
   string ls_24;
   string ls_32;
   if (gi_332) f0_8();
   int li_40 = 8;
   int li_44 = 16;
   int li_48 = 13;
   int li_52 = 21;
   int li_56 = 0;
   int li_60 = 7;
   int li_64 = 20;
   int li_68 = 3;
   f0_4();
   if (Event.Start.Hour >= 0 && Event.Start.Hour <= 9) gs_432 = "0";
   else gs_432 = "";
   if (Event.Start.Minutes >= 0 && Event.Start.Minutes <= 9) gs_440 = "0";
   else gs_440 = "";
   if (!Enable.News.Trading) {
      gs_424 = "No News Event Scheduled";
      f0_16("TradeHouseGlobal.com", 15, 15, 3);
      ObjectSetText("TradeHouseGlobal.com", gs_424, 10, "Tahoma", LightSkyBlue);
   } else {
      gs_424 = "NEWS SCHEDULED FOR (" + gs_432 + Event.Start.Hour + ":" + gs_440 + Event.Start.Minutes + ")";
      f0_16("TradeHouseGlobal.com", 15, 15, 3);
      ObjectSetText("TradeHouseGlobal.com", gs_424, 10, "Tahoma", White);
   }
   f0_16("TradeHouseGlobal", 5, 15, 1);
   ObjectSetText("TradeHouseGlobal", "[email protected]", 9, "Times New Roman", Red);
   f0_16("Artemis", 5, 15, 0);
   ObjectSetText("Artemis", gs_416, 9, "Times New Roman", Red);
   string ls_72 = f0_14(Hour(), Minute());
   string ls_80 = f0_14(TimeHour(TimeLocal()), TimeMinute(TimeLocal()));
   int li_88 = Time[0] + 60 * Period() - TimeCurrent();
   double ld_92 = li_88 / 60.0;
   int li_100 = li_88 % 60;
   li_88 = (li_88 - li_88 % 60) / 60;
   if (Hour() - gi_328 >= li_64 || Hour() - gi_328 <= li_68) ls_24 = "Sydney Open";
   else ls_24 = "Sydney Closed";
   if (Hour() - gi_328 >= li_40 && Hour() - gi_328 <= li_44) ls_0 = "London Open";
   else ls_0 = "London Closed";
   if (Hour() - gi_328 >= li_48 && Hour() - gi_328 <= li_52) ls_8 = "NewYork Open";
   else ls_8 = "NewYork Closed";
   if (Hour() - gi_328 >= li_56 && Hour() - gi_328 <= li_60) ls_16 = "Tokyo Open";
   else ls_16 = "Tokyo Closed";
   f0_16("Bar", 5, 90, 2);
   string ls_104 = li_88;
   if (li_88 >= 0 && li_88 <= 9) ls_104 = "0" + DoubleToStr(li_88, 0);
   else ls_104 = DoubleToStr(li_88, 0);
   if (li_100 >= 0 && li_100 <= 9) ls_32 = "0" + DoubleToStr(li_100, 0);
   else ls_32 = DoubleToStr(li_100, 0);
   ObjectSetText("Bar", "Bar Time to Close : " + "00:" + ls_104 + "." + ls_32, 8, "Tahoma", Yellow);
   f0_16("Broker", 5, 80, 2);
   ObjectSetText("Broker", "Broker\'s Time       : " + ls_72, 8, "Tahoma", Green);
   f0_16("Broker1", 5, 70, 2);
   ObjectSetText("Broker1", "Local Time           : " + ls_80, 8, "Tahoma", Blue);
   f0_16("Sydney", 5, 50, 2);
   if (ls_24 == "Sydney Open") ObjectSetText("Sydney", ls_24, 10, "Tahoma", DodgerBlue);
   else ObjectSetText("Sydney", ls_24, 10, "Tahoma", Red);
   f0_16("Tokyo", 5, 35, 2);
   if (ls_16 == "Tokyo Open") ObjectSetText("Tokyo", ls_16, 10, "Tahoma", DodgerBlue);
   else ObjectSetText("Tokyo", ls_16, 10, "Tahoma", Red);
   f0_16("London", 5, 20, 2);
   if (ls_0 == "London Open" && ls_8 == "NewYork Open") ObjectSetText("London", ls_0, 10, "Tahoma", Lime);
   else {
      if (ls_0 == "London Open") ObjectSetText("London", ls_0, 10, "Tahoma", DodgerBlue);
      else ObjectSetText("London", ls_0, 10, "Tahoma", Red);
   }
   f0_16("NewYork", 5, 5, 2);
   if (ls_0 == "London Open" && ls_8 == "NewYork Open") {
      ObjectSetText("NewYork", ls_8, 10, "Tahoma", Lime);
      return;
   }
   if (ls_8 == "NewYork Open") {
      ObjectSetText("NewYork", ls_8, 10, "Tahoma", DodgerBlue);
      return;
   }
   ObjectSetText("NewYork", ls_8, 10, "Tahoma", Red);
}

int f0_9(string as_0, int ai_8) {
   if (as_0 == "EURUSD" || as_0 == "EURUSDm") return (ai_8 + 1000);
   if (as_0 == "GBPUSD" || as_0 == "GBPUSDm") return (ai_8 + 2000);
   if (as_0 == "USDCHF" || as_0 == "USDCHFm") return (ai_8 + 3000);
   if (as_0 == "USDJPY" || as_0 == "USDJPYm") return (ai_8 + 4000);
   if (as_0 == "EURJPY" || as_0 == "EURJPYm") return (ai_8 + 5000);
   if (as_0 == "EURCHF" || as_0 == "EURCHFm") return (ai_8 + 6000);
   if (as_0 == "EURGBP" || as_0 == "EURGBPm") return (ai_8 + 7000);
   if (as_0 == "USDCAD" || as_0 == "USDCADm") return (ai_8 + 8000);
   if (as_0 == "AUDUSD" || as_0 == "AUDUSDm") return (ai_8 + 9000);
   if (as_0 == "GBPCHF" || as_0 == "GBPCHFm") return (ai_8 + 10000);
   if (as_0 == "GBPJPY" || as_0 == "GBPJPYm") return (ai_8 + 11000);
   if (as_0 == "CHFJPY" || as_0 == "CHFJPYm") return (ai_8 + 12000);
   if (as_0 == "NZDUSD" || as_0 == "NZDUSDm") return (ai_8 + 13000);
   if (as_0 == "EURCAD" || as_0 == "EURCADm") return (ai_8 + 14000);
   if (as_0 == "AUDJPY" || as_0 == "AUDJPYm") return (ai_8 + 15000);
   if (as_0 == "EURAUD" || as_0 == "EURAUDm") return (ai_8 + 16000);
   if (as_0 == "AUDCAD" || as_0 == "AUDCADm") return (ai_8 + 17000);
   if (as_0 == "AUDNZD" || as_0 == "AUDNZDm") return (ai_8 + 18000);
   if (as_0 == "NZDJPY" || as_0 == "NZDJPYm") return (ai_8 + 19000);
   if (as_0 == "CADJPY" || as_0 == "CADJPYm") return (ai_8 + 20000);
   if (as_0 == "XAUUSD" || as_0 == "XAUUSDm") return (ai_8 + 21000);
   if (as_0 == "XAGUSD" || as_0 == "XAGUSDm") return (ai_8 + 22000);
   if (as_0 == "GBPAUD" || as_0 == "GBPAUDm") return (ai_8 + 23000);
   if (as_0 == "GBPCAD" || as_0 == "GBPCADm") return (ai_8 + 24000);
   if (as_0 == "AUFCHF" || as_0 == "AUFCHFm") return (ai_8 + 25000);
   if (as_0 == "CADCHF" || as_0 == "CADCHFm") return (ai_8 + 26000);
   if (as_0 == "NZDCHF" || as_0 == "NZDCHFm") return (ai_8 + 27000);
   return (0);
}

int f0_16(string as_0, int ai_8, int ai_12, int ai_16) {
   ObjectCreate(as_0, OBJ_LABEL, 0, 0, 0);
   ObjectSet(as_0, OBJPROP_CORNER, ai_16);
   ObjectSet(as_0, OBJPROP_XDISTANCE, ai_8);
   ObjectSet(as_0, OBJPROP_YDISTANCE, ai_12);
   ObjectSet(as_0, OBJPROP_BACK, TRUE);
   return (0);
}

int f0_15() {
   /*
   int li_0 = 5;
   int li_4 = 30;
   int li_8 = 100;
   int li_12 = 10;
   int li_16 = 38 - li_12;
   bool li_20 = FALSE;
   if (Year() > li_8 * li_4 + li_12) li_20 = TRUE;
   if (Year() == li_8 * li_4 + li_12 && Month() > li_0) li_20 = TRUE;
   if (Year() == li_8 * li_4 + li_12 && Month() == li_0 && Day() >= li_16) li_20 = TRUE;
   gs_448 = StringConcatenate(li_8 * li_4 + li_12, "/", li_0, "/", li_16);
   if (li_20 == TRUE) {
      Alert("Error 1000 - Demo version has expired\nContact us at [email protected]");
      return (1);
   }
   */
   return (0);
}

Recommend