/*
   Generated by ex4-to-mq4 decompiler FREEWARE 4.0.451.7
   Website: Ht tp:/ /WwW.Me tAqu OTE S. net
   E-mail : s U pp OR T @meT aqu Ot eS . nET
*/

double Gb_pips_76 = 500.0;
double Gs_pips_76 = 500.0;
double Gbd_84 = 10.0;
double Gsd_84 = 10.0;
double Gbd_92 = 5.0;
double Gsd_92 = 5.0;
extern double LotExponent = 1.4;
extern bool DynamicPips = TRUE;
extern int DefaultPips = 12;
extern int Glubina = 24;
extern int DEL = 2;
extern double slip = 3.0;
extern double Lots = 0.1;
extern int lotdecimal = 1;
extern double TakeProfit = 10.0;
extern double Drop = 5000.0;
extern double RsiMinimum = 30.0;
extern double RsiMaximum = 70.0;
extern int MagicNumber_b = 2222;
extern int MaxTrades_b = 15;
extern int MagicNumber_s = 3333;
extern int MaxTrades_s = 15;
int Gbi_180 = 0;
int Gsi_180 = 0;
extern bool UseEquityStop = FALSE;
extern double TotalEquityRisk = 20.0;
extern bool UseTrailingStop = FALSE;
extern bool UseTimeOut = FALSE;
extern double MaxTradeOpenHours = 48.0;
extern bool TSLast = FALSE;
extern int TSStartLast = 15;
extern int TSStopLast = 7;
extern int TSNum = 100;
extern int PlusKoleno = 2;
extern bool RecalcTP = TRUE;
extern string sss = "new for add pips";
extern bool FirstTP = FALSE;
extern int StKoleno = 4;
extern int AddPips = 2;
int Gbi_260 = 0;
int Gsi_260 = 0;
extern bool TPforSL = FALSE;
extern string ssss = "new for dynamic lot";
extern bool DynLots = FALSE;
double Gb_lots_280;
double Gs_lots_280;
extern int Prosadka = 400;
extern int LastBars = 0;
extern bool UseMargin = FALSE;
int Gbia_unused_300[30];
int Gsia_unused_300[30];
int Gbi_unused_304;
int Gsi_unused_304;
double Gbd_308 = 0.0;
double Gsd_308 = 0.0;
double Gbd_316;
double Gsd_316;
double Gbd_324;
double Gsd_324;
double Gbd_unused_332;
double Gsd_unused_332;
double Gbd_unused_340;
double Gsd_unused_340;
double Gbd_348;
double Gsd_348;
double Gb_bid_356;
double Gs_bid_356;
double Gb_ask_364;
double Gs_ask_364;
double Gbd_372;
double Gsd_372;
double Gbd_380;
double Gsd_380;
double Gbd_388;
double Gsd_388;
bool Gbi_396;
bool Gsi_396;
string Gbs_400 = "Ilan1.67_Nikolaus_buy";
string Gss_400 = "Ilan1.67_Nikolaus_sell";
int Gbi_408 = 0;
int Gsi_408 = 0;
int Gbi_unused_412;
int Gsi_unused_412;
int Gbi_416 = 0;
int Gsi_416 = 0;
double Gbd_420;
double Gsd_420;
int Gb_pos_428 = 0;
int Gs_pos_428 = 0;
int Gbi_432;
int Gsi_432;
double Gbd_436 = 0.0;
double Gsd_436 = 0.0;
bool Gbi_444 = FALSE;
bool Gsi_444 = FALSE;
bool Gbi_448 = FALSE;
bool Gsi_448 = FALSE;
bool Gbi_452 = FALSE;
bool Gsi_452 = FALSE;
int Gbi_456;
int Gsi_456;
int Gbi_460 = 0;
int Gsi_460 = 0;
bool Gbi_464 = FALSE;
bool Gsi_464 = FALSE;
bool Gbi_468 = FALSE;
bool Gsi_468 = FALSE;
double Gbd_472;
double Gsd_472;
double Gbd_480;
double Gsd_480;
int Gbi_488 = 1;
int Gsi_488 = 1;
int Gbi_492 = 0;
int Gsi_492 = 0;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   Gbd_388 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
   Gb_lots_280 = Lots;
   Gsd_388 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
   Gs_lots_280 = Lots;
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   double Lbd_4;
   double Lbd_12;
   double icloseb_20;
   double icloseb_28;
   if (!FirstTP) Gbi_260 = 1;
   Gbi_432 = f0_11b();
   if (Gbi_432 < Gbi_460 && RecalcTP) Gbi_468 = TRUE;
   Gbi_460 = Gbi_432;
   int Lbi_0 = 0;
   if (Gbi_432 > StKoleno) Lbi_0 = (Gbi_432 - StKoleno) * AddPips;
   if (Gbi_432 == 1 && (!FirstTP)) {
      for (Gb_pos_428 = OrdersTotal() - 1; Gb_pos_428 >= 0; Gb_pos_428--) {
         OrderSelect(Gb_pos_428, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
            if (OrderStopLoss() == 0.0) Gbi_488 = 1;
            if (OrderStopLoss() > 0.0) Gbi_488 = -1;
         }
      }
   }
   if (Gbi_432 == 1 && (!FirstTP)) {
      for (Gb_pos_428 = OrdersTotal() - 1; Gb_pos_428 >= 0; Gb_pos_428--) {
         OrderSelect(Gb_pos_428, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b)
            if (OrderTakeProfit() > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), 0, 0, 0, Aqua);
      }
   }
   if (DynamicPips) {
      Lbd_4 = High[iHighest(NULL, 0, MODE_HIGH, Glubina, 1)];
      Lbd_12 = Low[iLowest(NULL, 0, MODE_LOW, Glubina, 1)];
      Gbi_180 = NormalizeDouble((Lbd_4 - Lbd_12) / DEL / Point, 0);
      if (Gbi_180 < DefaultPips + Lbi_0) Gbi_180 = DefaultPips + Lbi_0;
   } else Gbi_180 = DefaultPips + Lbi_0;
   if (UseTrailingStop) f0_13b(Gbd_84, Gbd_92, Gbd_348);
   if (TSLast) f0_1b();
   if ((iCCI(NULL, PERIOD_M15, 55, PRICE_CLOSE, 0) > Drop && Gbi_452) || (iCCI(NULL, PERIOD_M15, 55, PRICE_CLOSE, 0) < (-Drop) && Gbi_448)) {
      f0_3b();
      Print("Closed All due to TimeOut");
   }
   if (Gbi_408 == Time[0] && (!Gbi_468)) return (0);
   Gbi_408 = Time[0];
   double Lbd_36 = f0_5b();
   if (UseEquityStop) {
      if (Lbd_36 < 0.0 && MathAbs(Lbd_36) > TotalEquityRisk / 100.0 * f0_8b()) {
         f0_3b();
         Print("Closed All due to Stop Out");
         Gbi_464 = FALSE;
      }
   }
   if (Gbi_432 == 0) Gbi_396 = FALSE;
   for (Gb_pos_428 = OrdersTotal() - 1; Gb_pos_428 >= 0; Gb_pos_428--) {
      OrderSelect(Gb_pos_428, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
         if (OrderType() == OP_BUY) {
            Gbi_448 = TRUE;
            Gbi_452 = FALSE;
            break;
         }
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
         if (OrderType() == OP_SELL) {
            Gbi_448 = FALSE;
            Gbi_452 = TRUE;
            break;
         }
      }
   }
   if (Gbi_432 == 1 && (!FirstTP)) {
      for (Gb_pos_428 = OrdersTotal() - 1; Gb_pos_428 >= 0; Gb_pos_428--) {
         OrderSelect(Gb_pos_428, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
            if (OrderStopLoss() + OrderTakeProfit() == 0.0) Gbi_488 = 1;
            if (OrderStopLoss() + OrderTakeProfit() > 0.0) Gbi_488 = -1;
            if (Gbi_488 == -1) Gbi_492++;
         }
      }
   }
   Gbd_308 = 0;
   if (Gbi_432 > 1 && (!FirstTP)) {
      for (Gb_pos_428 = OrdersTotal() - 1; Gb_pos_428 >= 0; Gb_pos_428--) {
         OrderSelect(Gb_pos_428, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
            Gbd_308 += OrderStopLoss();
            Gbd_308 += OrderTakeProfit();
         }
      }
      if (Gbd_308 == 0.0) {
         Gbi_488 = 1;
         Gbi_468 = TRUE;
      }
   }
   if ((Gbi_432 > 0 && Gbi_432 <= MaxTrades_b) || (Gbi_432 > MaxTrades_b && Gbi_488 == -1)) {
      RefreshRates();
      Gbd_372 = f0_2b();
      Gbd_380 = f0_6b();
      if (Gbi_448 && (Gbd_372 - Ask) * Gbi_488 >= Gbi_180 * Point) Gbi_444 = TRUE;
      if (Gbi_452 && (Bid - Gbd_380) * Gbi_488 >= Gbi_180 * Point) Gbi_444 = TRUE;
   }
   if (Gbi_432 < 1) {
      Gbi_452 = FALSE;
      Gbi_448 = FALSE;
      Gbi_444 = TRUE;
      Gbd_324 = AccountEquity();
   }
   if (Gbi_444) {
      Gbd_372 = f0_2b();
      Gbd_380 = f0_6b();
      if (Gbi_452) {
         Gbi_416 = Gbi_432;
         Gbd_420 = NormalizeDouble(Lots * MathPow(LotExponent, Gbi_416), lotdecimal);
         RefreshRates();
         if (Gbi_488 == -1) Gbd_420 = NormalizeDouble(Lots * MathPow(LotExponent, PlusKoleno - 1), lotdecimal);
         Gbi_456 = f0_10b(1, Gbd_420, Bid, slip, Ask, 0, 0, Gbs_400 + "-" + Gbi_416 + "-" + Gbi_180, MagicNumber_b, 0, HotPink);
         Gbi_unused_304 = 1;
         if (Gbi_456 < 0) {
            Gbi_unused_304 = 0;
            Print("Error: ", GetLastError());
            return (0);
         }
         Gbd_380 = f0_6b();
         Gbi_444 = FALSE;
         Gbi_464 = TRUE;
      } else {
         if (Gbi_448) {
            Gbi_416 = Gbi_432;
            Gbd_420 = NormalizeDouble(Lots * MathPow(LotExponent, Gbi_416), lotdecimal);
            RefreshRates();
            if (Gbi_488 == -1) Gbd_420 = NormalizeDouble(Lots * MathPow(LotExponent, PlusKoleno - 1), lotdecimal);
            Gbi_456 = f0_10b(0, Gbd_420, Ask, slip, Bid, 0, 0, Gbs_400 + "-" + Gbi_416 + "-" + Gbi_180, MagicNumber_b, 0, Lime);
            Gbi_unused_304 = 1;
            if (Gbi_456 < 0) {
               Gbi_unused_304 = 0;
               Print("Error: ", GetLastError());
               return (0);
            }
            Gbd_372 = f0_2b();
            Gbi_444 = FALSE;
            Gbi_464 = TRUE;
         }
      }
   }
   if (Gbi_444 && Gbi_432 < 1) {
      icloseb_20 = iClose(Symbol(), 0, 2);
      icloseb_28 = iClose(Symbol(), 0, 1);
      Gb_bid_356 = Bid;
      Gb_ask_364 = Ask;
      if (DynLots) Lots = f0_7b();
      else Lots = Gb_lots_280;
      if ((!Gbi_452) && !Gbi_448) {
         Gbi_416 = Gbi_432;
         Gbd_420 = NormalizeDouble(Lots * MathPow(LotExponent, Gbi_416), lotdecimal);
         if (icloseb_20 > icloseb_28) {
            if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > RsiMinimum) {
               Gbi_456 = f0_10b(1, Gbd_420, Gb_bid_356, slip, Gb_bid_356, 0, 0, Gbs_400 + "-" + Gbi_416, MagicNumber_b, 0, HotPink);
               Gbi_unused_304 = 1;
               if (Gbi_456 < 0) {
                  Gbi_unused_304 = 0;
                  Print("Error: ", GetLastError());
                  return (0);
               }
               Gbd_372 = f0_2b();
               Gbi_464 = TRUE;
            }
         } else {
            if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < RsiMaximum) {
               Gbi_456 = f0_10b(0, Gbd_420, Gb_ask_364, slip, Gb_ask_364, 0, 0, Gbs_400 + "-" + Gbi_416, MagicNumber_b, 0, Lime);
               Gbi_unused_304 = 1;
               if (Gbi_456 < 0) {
                  Gbi_unused_304 = 0;
                  Print("Error: ", GetLastError());
                  return (0);
               }
               Gbd_380 = f0_6b();
               Gbi_464 = TRUE;
            }
         }
         if (Gbi_456 > 0) Gbi_unused_412 = TimeCurrent() + 60.0 * (60.0 * MaxTradeOpenHours);
         Gbi_444 = FALSE;
      }
   }
   Gbi_432 = f0_11b();
   Gbd_348 = 0;
   double Lbd_44 = 0;
   for (Gb_pos_428 = OrdersTotal() - 1; Gb_pos_428 >= 0; Gb_pos_428--) {
      OrderSelect(Gb_pos_428, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
            Gbd_348 += OrderOpenPrice() * OrderLots();
            Lbd_44 += OrderLots();
         }
      }
   }
   if (Gbi_432 > 0) Gbd_348 = NormalizeDouble(Gbd_348 / Lbd_44, Digits);
   if (Gbi_464 || Gbi_468) {
      for (Gb_pos_428 = OrdersTotal() - 1; Gb_pos_428 >= 0; Gb_pos_428--) {
         OrderSelect(Gb_pos_428, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
            if (OrderType() == OP_BUY) {
               Gbd_316 = Gbd_348 + TakeProfit * Point;
               Gbd_unused_332 = Gbd_316;
               Gbd_436 = Gbd_348 - Gb_pips_76 * Point;
               Gbi_396 = TRUE;
            }
         }
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
            if (OrderType() == OP_SELL) {
               Gbd_316 = Gbd_348 - TakeProfit * Point;
               Gbd_unused_340 = Gbd_316;
               Gbd_436 = Gbd_348 + Gb_pips_76 * Point;
               Gbi_396 = TRUE;
            }
         }
      }
   }
   if (Gbi_464 || Gbi_468 && Gbi_432 > Gbi_260 && Gbi_488 > 0) {
      if (Gbi_396 == TRUE) {
         for (Gb_pos_428 = OrdersTotal() - 1; Gb_pos_428 >= 0; Gb_pos_428--) {
            OrderSelect(Gb_pos_428, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b && OrderStopLoss() > 0.0) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) OrderModify(OrderTicket(), NormalizeDouble(Gbd_348, Digits), NormalizeDouble(OrderStopLoss(), Digits), NormalizeDouble(Gbd_316, Digits), 0, Yellow);
            Gbi_464 = FALSE;
            Gbi_468 = FALSE;
         }
      }
   }
   double Lsd_4;
   double Lsd_12;
   double icloses_20;
   double icloses_28;
   if (!FirstTP) Gsi_260 = 1;
   Gsi_432 = f0_11s();
   if (Gsi_432 < Gsi_460 && RecalcTP) Gsi_468 = TRUE;
   Gsi_460 = Gsi_432;
   int Lsi_0 = 0;
   if (Gsi_432 > StKoleno) Lsi_0 = (Gsi_432 - StKoleno) * AddPips;
   if (Gsi_432 == 1 && (!FirstTP)) {
      for (Gs_pos_428 = OrdersTotal() - 1; Gs_pos_428 >= 0; Gs_pos_428--) {
         OrderSelect(Gs_pos_428, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
            if (OrderStopLoss() == 0.0) Gsi_488 = 1;
            if (OrderStopLoss() > 0.0) Gsi_488 = -1;
         }
      }
   }
   if (Gsi_432 == 1 && (!FirstTP)) {
      for (Gs_pos_428 = OrdersTotal() - 1; Gs_pos_428 >= 0; Gs_pos_428--) {
         OrderSelect(Gs_pos_428, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s)
            if (OrderTakeProfit() > 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), 0, 0, 0, Aqua);
      }
   }
   if (DynamicPips) {
      Lsd_4 = High[iHighest(NULL, 0, MODE_HIGH, Glubina, 1)];
      Lsd_12 = Low[iLowest(NULL, 0, MODE_LOW, Glubina, 1)];
      Gsi_180 = NormalizeDouble((Lsd_4 - Lsd_12) / DEL / Point, 0);
      if (Gsi_180 < DefaultPips + Lsi_0) Gsi_180 = DefaultPips + Lsi_0;
   } else Gsi_180 = DefaultPips + Lsi_0;
   if (UseTrailingStop) f0_13s(Gsd_84, Gsd_92, Gsd_348);
   if (TSLast) f0_1s();
   if ((iCCI(NULL, PERIOD_M15, 55, PRICE_CLOSE, 0) > Drop && Gsi_452) || (iCCI(NULL, PERIOD_M15, 55, PRICE_CLOSE, 0) < (-Drop) && Gsi_448)) {
      f0_3s();
      Print("Closed All due to TimeOut");
   }
   if (Gsi_408 == Time[0] && (!Gsi_468)) return (0);
   Gsi_408 = Time[0];
   double Lsd_36 = f0_5s();
   if (UseEquityStop) {
      if (Lsd_36 < 0.0 && MathAbs(Lsd_36) > TotalEquityRisk / 100.0 * f0_8s()) {
         f0_3s();
         Print("Closed All due to Stop Out");
         Gsi_464 = FALSE;
      }
   }
   if (Gsi_432 == 0) Gsi_396 = FALSE;
   for (Gs_pos_428 = OrdersTotal() - 1; Gs_pos_428 >= 0; Gs_pos_428--) {
      OrderSelect(Gs_pos_428, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
         if (OrderType() == OP_BUY) {
            Gsi_448 = TRUE;
            Gsi_452 = FALSE;
            break;
         }
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
         if (OrderType() == OP_SELL) {
            Gsi_448 = FALSE;
            Gsi_452 = TRUE;
            break;
         }
      }
   }
   if (Gsi_432 == 1 && (!FirstTP)) {
      for (Gs_pos_428 = OrdersTotal() - 1; Gs_pos_428 >= 0; Gs_pos_428--) {
         OrderSelect(Gs_pos_428, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
            if (OrderStopLoss() + OrderTakeProfit() == 0.0) Gsi_488 = 1;
            if (OrderStopLoss() + OrderTakeProfit() > 0.0) Gsi_488 = -1;
            if (Gsi_488 == -1) Gsi_492++;
         }
      }
   }
   Gsd_308 = 0;
   if (Gsi_432 > 1 && (!FirstTP)) {
      for (Gs_pos_428 = OrdersTotal() - 1; Gs_pos_428 >= 0; Gs_pos_428--) {
         OrderSelect(Gs_pos_428, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
            Gsd_308 += OrderStopLoss();
            Gsd_308 += OrderTakeProfit();
         }
      }
      if (Gsd_308 == 0.0) {
         Gsi_488 = 1;
         Gsi_468 = TRUE;
      }
   }
   if ((Gsi_432 > 0 && Gsi_432 <= MaxTrades_s) || (Gsi_432 > MaxTrades_s && Gsi_488 == -1)) {
      RefreshRates();
      Gsd_372 = f0_2s();
      Gsd_380 = f0_6s();
      if (Gsi_448 && (Gsd_372 - Ask) * Gsi_488 >= Gsi_180 * Point) Gsi_444 = TRUE;
      if (Gsi_452 && (Bid - Gsd_380) * Gsi_488 >= Gsi_180 * Point) Gsi_444 = TRUE;
   }
   if (Gsi_432 < 1) {
      Gsi_452 = FALSE;
      Gsi_448 = FALSE;
      Gsi_444 = TRUE;
      Gsd_324 = AccountEquity();
   }
   if (Gsi_444) {
      Gsd_372 = f0_2s();
      Gsd_380 = f0_6s();
      if (Gsi_452) {
         Gsi_416 = Gsi_432;
         Gsd_420 = NormalizeDouble(Lots * MathPow(LotExponent, Gsi_416), lotdecimal);
         RefreshRates();
         if (Gsi_488 == -1) Gsd_420 = NormalizeDouble(Lots * MathPow(LotExponent, PlusKoleno - 1), lotdecimal);
         Gsi_456 = f0_10s(1, Gsd_420, Bid, slip, Ask, 0, 0, Gss_400 + "-" + Gsi_416 + "-" + Gsi_180, MagicNumber_s, 0, HotPink);
         Gsi_unused_304 = 1;
         if (Gsi_456 < 0) {
            Gsi_unused_304 = 0;
            Print("Error: ", GetLastError());
            return (0);
         }
         Gsd_380 = f0_6s();
         Gsi_444 = FALSE;
         Gsi_464 = TRUE;
      } else {
         if (Gsi_448) {
            Gsi_416 = Gsi_432;
            Gsd_420 = NormalizeDouble(Lots * MathPow(LotExponent, Gsi_416), lotdecimal);
            RefreshRates();
            if (Gsi_488 == -1) Gsd_420 = NormalizeDouble(Lots * MathPow(LotExponent, PlusKoleno - 1), lotdecimal);
            Gsi_456 = f0_10s(0, Gsd_420, Ask, slip, Bid, 0, 0, Gss_400 + "-" + Gsi_416 + "-" + Gsi_180, MagicNumber_s, 0, Lime);
            Gsi_unused_304 = 1;
            if (Gsi_456 < 0) {
               Gsi_unused_304 = 0;
               Print("Error: ", GetLastError());
               return (0);
            }
            Gsd_372 = f0_2s();
            Gsi_444 = FALSE;
            Gsi_464 = TRUE;
         }
      }
   }
   if (Gsi_444 && Gsi_432 < 1) {
      icloses_20 = iClose(Symbol(), 0, 2);
      icloses_28 = iClose(Symbol(), 0, 1);
      Gs_bid_356 = Bid;
      Gs_ask_364 = Ask;
      if (DynLots) Lots = f0_7s();
      else Lots = Gs_lots_280;
      if ((!Gsi_452) && !Gsi_448) {
         Gsi_416 = Gsi_432;
         Gsd_420 = NormalizeDouble(Lots * MathPow(LotExponent, Gsi_416), lotdecimal);
         if (icloses_20 > icloses_28) {
            if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) > RsiMinimum) {
               Gsi_456 = f0_10s(1, Gsd_420, Gs_bid_356, slip, Gs_bid_356, 0, 0, Gss_400 + "-" + Gsi_416, MagicNumber_s, 0, HotPink);
               Gsi_unused_304 = 1;
               if (Gsi_456 < 0) {
                  Gsi_unused_304 = 0;
                  Print("Error: ", GetLastError());
                  return (0);
               }
               Gsd_372 = f0_2s();
               Gsi_464 = TRUE;
            }
         } else {
            if (iRSI(NULL, PERIOD_H1, 14, PRICE_CLOSE, 1) < RsiMaximum) {
               Gsi_456 = f0_10s(0, Gsd_420, Gs_ask_364, slip, Gs_ask_364, 0, 0, Gss_400 + "-" + Gsi_416, MagicNumber_s, 0, Lime);
               Gsi_unused_304 = 1;
               if (Gsi_456 < 0) {
                  Gsi_unused_304 = 0;
                  Print("Error: ", GetLastError());
                  return (0);
               }
               Gsd_380 = f0_6s();
               Gsi_464 = TRUE;
            }
         }
         if (Gsi_456 > 0) Gsi_unused_412 = TimeCurrent() + 60.0 * (60.0 * MaxTradeOpenHours);
         Gsi_444 = FALSE;
      }
   }
   Gsi_432 = f0_11s();
   Gsd_348 = 0;
   double Lsd_44 = 0;
   for (Gs_pos_428 = OrdersTotal() - 1; Gs_pos_428 >= 0; Gs_pos_428--) {
      OrderSelect(Gs_pos_428, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
            Gsd_348 += OrderOpenPrice() * OrderLots();
            Lsd_44 += OrderLots();
         }
      }
   }
   if (Gsi_432 > 0) Gsd_348 = NormalizeDouble(Gsd_348 / Lsd_44, Digits);
   if (Gsi_464 || Gsi_468) {
      for (Gs_pos_428 = OrdersTotal() - 1; Gs_pos_428 >= 0; Gs_pos_428--) {
         OrderSelect(Gs_pos_428, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
            if (OrderType() == OP_BUY) {
               Gsd_316 = Gsd_348 + TakeProfit * Point;
               Gsd_unused_332 = Gsd_316;
               Gsd_436 = Gsd_348 - Gs_pips_76 * Point;
               Gsi_396 = TRUE;
            }
         }
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
            if (OrderType() == OP_SELL) {
               Gsd_316 = Gsd_348 - TakeProfit * Point;
               Gsd_unused_340 = Gsd_316;
               Gsd_436 = Gsd_348 + Gs_pips_76 * Point;
               Gsi_396 = TRUE;
            }
         }
      }
   }
   if (Gsi_464 || Gsi_468 && Gsi_432 > Gsi_260 && Gsi_488 > 0) {
      if (Gsi_396 == TRUE) {
         for (Gs_pos_428 = OrdersTotal() - 1; Gs_pos_428 >= 0; Gs_pos_428--) {
            OrderSelect(Gs_pos_428, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s && OrderStopLoss() > 0.0) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) OrderModify(OrderTicket(), NormalizeDouble(Gsd_348, Digits), NormalizeDouble(OrderStopLoss(), Digits), NormalizeDouble(Gsd_316, Digits), 0, Yellow);
            Gsi_464 = FALSE;
            Gsi_468 = FALSE;
         }
      }
   }
   return (0);
}

// CBBD1151F6D49BC6C817A0B96D15036D
int f0_11b() {
   int count_0 = 0;
   for (int pos_4 = OrdersTotal() - 1; pos_4 >= 0; pos_4--) {
      OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b)
         if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
   }
   return (count_0);
}

// 41BB59E8D36C416E4C62910D9E765220
void f0_3b() {
   for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
      OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol()) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
            if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip, Blue);
            if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip, Red);
         }
         Sleep(1000);
      }
   }
}

// C159FD8BED695B6E6A109D3B72C199C3
int f0_10b(int Abi_0, double Ab_lots_4, double Ab_price_12, int Ab_slippage_20, double Abd_24, int Abi_32, int Abi_36, string Ab_comment_40, int Ab_magic_48, int Ab_datetime_52, color Ab_color_56) {
   int ticket_60 = 0;
   int error_64 = 0;
   int count_68 = 0;
   int Lbi_72 = 100;
   switch (Abi_0) {
   case 2:
      for (count_68 = 0; count_68 < Lbi_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, Ab_lots_4, Ab_price_12, Ab_slippage_20, f0_9b(Abd_24, Abi_32), f0_12b(Ab_price_12, Abi_36), Ab_comment_40, Ab_magic_48,
            Ab_datetime_52, Ab_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(1000);
      }
      break;
   case 4:
      for (count_68 = 0; count_68 < Lbi_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, Ab_lots_4, Ab_price_12, Ab_slippage_20, f0_9b(Abd_24, Abi_32), f0_12b(Ab_price_12, Abi_36), Ab_comment_40, Ab_magic_48,
            Ab_datetime_52, Ab_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(5000);
      }
      break;
   case 0:
      for (count_68 = 0; count_68 < Lbi_72; count_68++) {
         RefreshRates();
         ticket_60 = OrderSend(Symbol(), OP_BUY, Ab_lots_4, NormalizeDouble(Ask, Digits), Ab_slippage_20, NormalizeDouble(f0_9b(Bid, Abi_32), Digits), NormalizeDouble(f0_12b(Ask,
            Abi_36), Digits), Ab_comment_40, Ab_magic_48, Ab_datetime_52, Ab_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(5000);
      }
   }
   return (ticket_60);
}

// A04259EF619300E271488B8ABD9DF8A9
double f0_9b(double Abd_0, int Abi_8) {
   if (Abi_8 == 0) return (0);
   return (Abd_0 - Abi_8 * Point);
}

// CE75B31DDDC1519B313C4C612EF22D86
double f0_12b(double Abd_0, int Abi_8) {
   if (Abi_8 == 0) return (0);
   return (Abd_0 + Abi_8 * Point);
}

// 4A186EA1A04A05E39FD2E7A94BB28576
double f0_5b() {
   double Lbd_ret_0 = 0;
   for (Gb_pos_428 = OrdersTotal() - 1; Gb_pos_428 >= 0; Gb_pos_428--) {
      OrderSelect(Gb_pos_428, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b)
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) Lbd_ret_0 += OrderProfit();
   }
   return (Lbd_ret_0);
}

// FDD5E0C68EEEAC73C07299767285F173
void f0_13b(int Abi_0, int Abi_4, double Abd_8) {
   int Lbi_16;
   double order_stoploss_20;
   double price_28;
   if (Abi_4 != 0) {
      for (int pos_36 = OrdersTotal() - 1; pos_36 >= 0; pos_36--) {
         if (OrderSelect(pos_36, SELECT_BY_POS, MODE_TRADES)) {
            if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
               if (OrderType() == OP_BUY) {
                  Lbi_16 = NormalizeDouble((Bid - Abd_8) / Point, 0);
                  if (Lbi_16 < Abi_0) continue;
                  order_stoploss_20 = OrderStopLoss();
                  price_28 = Bid - Abi_4 * Point;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_28 > order_stoploss_20)) OrderModify(OrderTicket(), NormalizeDouble(Abd_8, Digits), price_28, OrderTakeProfit(), 0, Aqua);
               }
               if (OrderType() == OP_SELL) {
                  Lbi_16 = NormalizeDouble((Abd_8 - Ask) / Point, 0);
                  if (Lbi_16 < Abi_0) continue;
                  order_stoploss_20 = OrderStopLoss();
                  price_28 = Ask + Abi_4 * Point;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_28 < order_stoploss_20)) OrderModify(OrderTicket(), NormalizeDouble(Abd_8, Digits), price_28, OrderTakeProfit(), 0, Red);
               }
            }
            Sleep(1000);
         }
      }
   }
}

// 16F7A9F90431C662B402ADB5C157532A
void f0_1b() {
   double price_0;
   int Lbi_12;
   double order_stoploss_16;
   int Lbi_8 = TSNum;
   for (int pos_24 = OrdersTotal() - 1; pos_24 >= 0; pos_24--) {
      if (OrderSelect(pos_24, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b) {
            order_stoploss_16 = OrderStopLoss();
            if (OrderType() == OP_BUY) {
               if (Lbi_8 > 0) {
                  Lbi_12 = NormalizeDouble((Bid - OrderOpenPrice()) / Point, 0);
                  if (Lbi_12 < TSStartLast) continue;
                  if (order_stoploss_16 > Bid - TSStopLast * Point) continue;
                  price_0 = Bid - TSStopLast * Point;
                  if (TPforSL) {
                     if (price_0 != order_stoploss_16) OrderModify(OrderTicket(), OrderOpenPrice(), price_0, OrderTakeProfit(), 0, Aqua);
                  } else
                     if (price_0 != order_stoploss_16) OrderModify(OrderTicket(), OrderOpenPrice(), price_0, 0, 0, Aqua);
                  Lbi_8--;
               } else
                  if (order_stoploss_16 != 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), 0, OrderTakeProfit(), 0, Aqua);
            }
            if (OrderType() == OP_SELL) {
               if (Lbi_8 > 0) {
                  Lbi_12 = NormalizeDouble((OrderOpenPrice() - Ask) / Point, 0);
                  if (Lbi_12 < TSStartLast) continue;
                  price_0 = Ask + TSStopLast * Point;
                  if (order_stoploss_16 < price_0 && order_stoploss_16 != 0.0) continue;
                  if (TPforSL) {
                     if (price_0 != order_stoploss_16) OrderModify(OrderTicket(), OrderOpenPrice(), price_0, OrderTakeProfit(), 0, Red);
                  } else
                     if (price_0 != order_stoploss_16) OrderModify(OrderTicket(), OrderOpenPrice(), price_0, 0, 0, Red);
                  Lbi_8--;
               } else
                  if (order_stoploss_16 != 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), 0, OrderTakeProfit(), 0, Red);
            }
         }
         Sleep(500);
      }
   }
}

// 91C97865111C4DD6B44C584F4B9358BB
double f0_8b() {
   if (f0_11b() == 0) Gbd_472 = AccountEquity();
   if (Gbd_472 < Gbd_480) Gbd_472 = Gbd_480;
   else Gbd_472 = AccountEquity();
   Gbd_480 = AccountEquity();
   return (Gbd_472);
}

// 262336F736ADFEEC641C03BB3514631C
double f0_2b() {
   double order_open_price_0;
   int ticket_8;
   double Lbd_unused_12 = 0;
   int ticket_20 = 0;
   for (int pos_24 = OrdersTotal() - 1; pos_24 >= 0; pos_24--) {
      OrderSelect(pos_24, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b && OrderType() == OP_BUY) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            Lbd_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// 599A26C25DF2561FBAA884F47E1B315C
double f0_6b() {
   double order_open_price_0;
   int ticket_8;
   double Lbd_unused_12 = 0;
   int ticket_20 = 0;
   for (int pos_24 = OrdersTotal() - 1; pos_24 >= 0; pos_24--) {
      OrderSelect(pos_24, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_b) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_b && OrderType() == OP_SELL) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            Lbd_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// 672C128A781DEFC467E66806532557DD
double f0_7b() {
   double high_4;
   double low_12;
   double Lbd_60;
   double Lbd_80;
   double Lbd_92;
   int digits_0 = MarketInfo(Symbol(), MODE_DIGITS);
   Lots = Gb_lots_280;
   if (LastBars > WHOLE_ARRAY) {
      high_4 = High[iHighest(NULL, 0, MODE_HIGH, LastBars, 1)];
      low_12 = Low[iLowest(NULL, 0, MODE_LOW, LastBars, 1)];
      Prosadka = (high_4 - low_12) * MathPow(10, digits_0);
   }
   double free_magrin_20 = AccountBalance();
   double tickvalue_28 = MarketInfo(Symbol(), MODE_TICKVALUE);
   double Lbd_36 = MarketInfo(Symbol(), MODE_MINLOT);
   double Lbd_44 = MarketInfo(Symbol(), MODE_MAXLOT);
   double lotstep_52 = MarketInfo(Symbol(), MODE_LOTSTEP);
   if (UseMargin) free_magrin_20 = AccountFreeMargin();
   int Lbi_68 = DefaultPips * MaxTrades_b / LotExponent;
   for (double Lbd_ret_72 = Lots; Lbd_ret_72 <= AccountFreeMargin() * TotalEquityRisk / 100.0 / MarketInfo(Symbol(), MODE_MARGINREQUIRED); Lbd_ret_72 += NormalizeDouble(lotstep_52,
      lotdecimal)) {
      Lbd_60 = 0;
      Lbd_80 = 0;
      Lbd_60 = Lbd_ret_72;
      for (int Lbi_88 = 0; Lbi_88 <= MaxTrades_b; Lbi_88++) Lbd_80 += NormalizeDouble(Lbd_60 * MathPow(LotExponent, Lbi_88), lotdecimal);
      Lbd_92 = NormalizeDouble(free_magrin_20 * TotalEquityRisk / 100.0 / Lbd_80 / tickvalue_28, 0) + Lbi_68;
      if (Lbd_92 < Prosadka) break;
   }
   if (Lbd_ret_72 < Lbd_36) Lbd_ret_72 = Lbd_36;
   if (Lbd_ret_72 > Lbd_44) Lbd_ret_72 = Lbd_44;
   return (Lbd_ret_72);
}

// CBBD1151F6D49BC6C817A0B96D15036D
int f0_11s() {
   int count_0 = 0;
   for (int pos_4 = OrdersTotal() - 1; pos_4 >= 0; pos_4--) {
      OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s)
         if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
   }
   return (count_0);
}

// 41BB59E8D36C416E4C62910D9E765220
void f0_3s() {
   for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
      OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol()) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
            if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip, Blue);
            if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip, Red);
         }
         Sleep(1000);
      }
   }
}

// C159FD8BED695B6E6A109D3B72C199C3
int f0_10s(int Asi_0, double As_lots_4, double As_price_12, int As_slippage_20, double Asd_24, int Asi_32, int Asi_36, string As_comment_40, int As_magic_48, int As_datetime_52, color As_color_56) {
   int ticket_60 = 0;
   int error_64 = 0;
   int count_68 = 0;
   int Lsi_72 = 100;
   switch (Asi_0) {
   case 3:
      for (count_68 = 0; count_68 < Lsi_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, As_lots_4, As_price_12, As_slippage_20, f0_0s(Asd_24, Asi_32), f0_4s(As_price_12, Asi_36), As_comment_40, As_magic_48,
            As_datetime_52, As_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(5000);
      }
      break;
   case 5:
      for (count_68 = 0; count_68 < Lsi_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, As_lots_4, As_price_12, As_slippage_20, f0_0s(Asd_24, Asi_32), f0_4s(As_price_12, Asi_36), As_comment_40, As_magic_48,
            As_datetime_52, As_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(5000);
      }
      break;
   case 1:
      for (count_68 = 0; count_68 < Lsi_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELL, As_lots_4, NormalizeDouble(Bid, Digits), As_slippage_20, NormalizeDouble(f0_0s(Ask, Asi_32), Digits), NormalizeDouble(f0_4s(Bid,
            Asi_36), Digits), As_comment_40, As_magic_48, As_datetime_52, As_color_56);
         error_64 = GetLastError();
         if (error_64 == 0/* NO_ERROR */) break;
         if (!((error_64 == 4/* SERVER_BUSY */ || error_64 == 137/* BROKER_BUSY */ || error_64 == 146/* TRADE_CONTEXT_BUSY */ || error_64 == 136/* OFF_QUOTES */))) break;
         Sleep(5000);
      }
   }
   return (ticket_60);
}

// 0D578CA46072792DE50D5B9F5F5F8784
double f0_0s(double Asd_0, int Asi_8) {
   if (Asi_8 == 0) return (0);
   return (Asd_0 + Asi_8 * Point);
}

// 4347D7B92E8469B198EAA742F66BBE62
double f0_4s(double Asd_0, int Asi_8) {
   if (Asi_8 == 0) return (0);
   return (Asd_0 - Asi_8 * Point);
}

// 4A186EA1A04A05E39FD2E7A94BB28576
double f0_5s() {
   double Lsd_ret_0 = 0;
   for (Gs_pos_428 = OrdersTotal() - 1; Gs_pos_428 >= 0; Gs_pos_428--) {
      OrderSelect(Gs_pos_428, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s)
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) Lsd_ret_0 += OrderProfit();
   }
   return (Lsd_ret_0);
}

// FDD5E0C68EEEAC73C07299767285F173
void f0_13s(int Asi_0, int Asi_4, double Asd_8) {
   int Lsi_16;
   double order_stoploss_20;
   double price_28;
   if (Asi_4 != 0) {
      for (int pos_36 = OrdersTotal() - 1; pos_36 >= 0; pos_36--) {
         if (OrderSelect(pos_36, SELECT_BY_POS, MODE_TRADES)) {
            if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
               if (OrderType() == OP_BUY) {
                  Lsi_16 = NormalizeDouble((Bid - Asd_8) / Point, 0);
                  if (Lsi_16 < Asi_0) continue;
                  order_stoploss_20 = OrderStopLoss();
                  price_28 = Bid - Asi_4 * Point;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_28 > order_stoploss_20)) OrderModify(OrderTicket(), NormalizeDouble(Asd_8, Digits), price_28, OrderTakeProfit(), 0, Aqua);
               }
               if (OrderType() == OP_SELL) {
                  Lsi_16 = NormalizeDouble((Asd_8 - Ask) / Point, 0);
                  if (Lsi_16 < Asi_0) continue;
                  order_stoploss_20 = OrderStopLoss();
                  price_28 = Ask + Asi_4 * Point;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_28 < order_stoploss_20)) OrderModify(OrderTicket(), NormalizeDouble(Asd_8, Digits), price_28, OrderTakeProfit(), 0, Red);
               }
            }
            Sleep(1000);
         }
      }
   }
}

// 16F7A9F90431C662B402ADB5C157532A
void f0_1s() {
   double price_0;
   int Lsi_12;
   double order_stoploss_16;
   int Lsi_8 = TSNum;
   for (int pos_24 = OrdersTotal() - 1; pos_24 >= 0; pos_24--) {
      if (OrderSelect(pos_24, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s) {
            order_stoploss_16 = OrderStopLoss();
            if (OrderType() == OP_BUY) {
               if (Lsi_8 > 0) {
                  Lsi_12 = NormalizeDouble((Bid - OrderOpenPrice()) / Point, 0);
                  if (Lsi_12 < TSStartLast) continue;
                  if (order_stoploss_16 > Bid - TSStopLast * Point) continue;
                  price_0 = Bid - TSStopLast * Point;
                  if (TPforSL) {
                     if (price_0 != order_stoploss_16) OrderModify(OrderTicket(), OrderOpenPrice(), price_0, OrderTakeProfit(), 0, Aqua);
                  } else
                     if (price_0 != order_stoploss_16) OrderModify(OrderTicket(), OrderOpenPrice(), price_0, 0, 0, Aqua);
                  Lsi_8--;
               } else
                  if (order_stoploss_16 != 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), 0, OrderTakeProfit(), 0, Aqua);
            }
            if (OrderType() == OP_SELL) {
               if (Lsi_8 > 0) {
                  Lsi_12 = NormalizeDouble((OrderOpenPrice() - Ask) / Point, 0);
                  if (Lsi_12 < TSStartLast) continue;
                  price_0 = Ask + TSStopLast * Point;
                  if (order_stoploss_16 < price_0 && order_stoploss_16 != 0.0) continue;
                  if (TPforSL) {
                     if (price_0 != order_stoploss_16) OrderModify(OrderTicket(), OrderOpenPrice(), price_0, OrderTakeProfit(), 0, Red);
                  } else
                     if (price_0 != order_stoploss_16) OrderModify(OrderTicket(), OrderOpenPrice(), price_0, 0, 0, Red);
                  Lsi_8--;
               } else
                  if (order_stoploss_16 != 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), 0, OrderTakeProfit(), 0, Red);
            }
         }
         Sleep(500);
      }
   }
}

// 91C97865111C4DD6B44C584F4B9358BB
double f0_8s() {
   if (f0_11s() == 0) Gsd_472 = AccountEquity();
   if (Gsd_472 < Gsd_480) Gsd_472 = Gsd_480;
   else Gsd_472 = AccountEquity();
   Gsd_480 = AccountEquity();
   return (Gsd_472);
}

// 262336F736ADFEEC641C03BB3514631C
double f0_2s() {
   double order_open_price_0;
   int ticket_8;
   double Lsd_unused_12 = 0;
   int ticket_20 = 0;
   for (int pos_24 = OrdersTotal() - 1; pos_24 >= 0; pos_24--) {
      OrderSelect(pos_24, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s && OrderType() == OP_BUY) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            Lsd_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// 599A26C25DF2561FBAA884F47E1B315C
double f0_6s() {
   double order_open_price_0;
   int ticket_8;
   double Lsd_unused_12 = 0;
   int ticket_20 = 0;
   for (int pos_24 = OrdersTotal() - 1; pos_24 >= 0; pos_24--) {
      OrderSelect(pos_24, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_s) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_s && OrderType() == OP_SELL) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            Lsd_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// 672C128A781DEFC467E66806532557DD
double f0_7s() {
   double high_4;
   double low_12;
   double Lsd_60;
   double Lsd_80;
   double Lsd_92;
   int digits_0 = MarketInfo(Symbol(), MODE_DIGITS);
   Lots = Gs_lots_280;
   if (LastBars > WHOLE_ARRAY) {
      high_4 = High[iHighest(NULL, 0, MODE_HIGH, LastBars, 1)];
      low_12 = Low[iLowest(NULL, 0, MODE_LOW, LastBars, 1)];
      Prosadka = (high_4 - low_12) * MathPow(10, digits_0);
   }
   double free_magrin_20 = AccountBalance();
   double tickvalue_28 = MarketInfo(Symbol(), MODE_TICKVALUE);
   double Lsd_36 = MarketInfo(Symbol(), MODE_MINLOT);
   double Lsd_44 = MarketInfo(Symbol(), MODE_MAXLOT);
   double lotstep_52 = MarketInfo(Symbol(), MODE_LOTSTEP);
   if (UseMargin) free_magrin_20 = AccountFreeMargin();
   int Lsi_68 = DefaultPips * MaxTrades_s / LotExponent;
   for (double Lsd_ret_72 = Lots; Lsd_ret_72 <= AccountFreeMargin() * TotalEquityRisk / 100.0 / MarketInfo(Symbol(), MODE_MARGINREQUIRED); Lsd_ret_72 += NormalizeDouble(lotstep_52,
      lotdecimal)) {
      Lsd_60 = 0;
      Lsd_80 = 0;
      Lsd_60 = Lsd_ret_72;
      for (int Lsi_88 = 0; Lsi_88 <= MaxTrades_s; Lsi_88++) Lsd_80 += NormalizeDouble(Lsd_60 * MathPow(LotExponent, Lsi_88), lotdecimal);
      Lsd_92 = NormalizeDouble(free_magrin_20 * TotalEquityRisk / 100.0 / Lsd_80 / tickvalue_28, 0) + Lsi_68;
      if (Lsd_92 < Prosadka) break;
   }
   if (Lsd_ret_72 < Lsd_36) Lsd_ret_72 = Lsd_36;
   if (Lsd_ret_72 > Lsd_44) Lsd_ret_72 = Lsd_44;
   return (Lsd_ret_72);
}