//+------------------------------------------------------------------+
//|                                                                  |
//|   v 4.2                                                          |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+


extern bool Jaipong = FALSE;
extern bool Keroncong = TRUE;
extern bool Tortor = FALSE;

extern double Lots = 0.01;
extern double LotExponent = 1.5;

extern int next_step_after = PERIOD_H1;
extern bool Filter_MA = TRUE;
extern int PERIOD_MA = PERIOD_H1;

extern bool close_next_Jaipong = FALSE;
extern bool close_next_Keroncong = FALSE;
extern bool close_next_Tortor = FALSE;

int PERIOD = 60;

extern bool report = FALSE;

extern double Jaipong_Loss_Limit = -3000.0;
extern double Keroncong_Loss_Limit = -3000.0;
extern double Tortor_Loss_Limit = -3000.0;

extern int MaxTrades_Hilo = 10;
extern int MaxTrades_15 = 10;
extern int MaxTrades_16 = 10;

extern int max_J_steps = 50000;
extern int max_K_steps = 50000;
extern int max_T_steps = 50000;

extern bool Auto_MagicNumber = TRUE;
extern int MagicNumber_Hilo = 11111;
extern int G_magic_176_15 = 22222;
extern int G_magic_176_16 = 33333;


  /// -------------------------------------------  Trio Total  --------------------  
double Jai_lot, Jai;
double Ker_lot, Ker;
double Tor_lot, Tor; 

double max_loss_J=0;
double max_loss_K=0;
double max_loss_T=0;

int J, K, T;

int MagicJ;
int MagicK;
int MagicT;

string a, b, c;
string posJ, posK, posT;

int step_J = 0; 
int step_K = 0;
int step_T = 0;

int J_r = 0; 
int K_r = 0;
int T_r = 0;

double Jai_r=0;
double Ker_r=0;
double Tor_r=0;

int last_step_J=0;
int last_step_K=0;
int last_step_T=0;



/// -------------------------------------------  Trio Total  -------------------- end


int Gi_108 = 2;
extern double MaxLots = 5.0;
extern bool MM = FALSE;
extern double TakeProfit = 30.0;
extern bool UseEquityStop = FALSE;
extern double TotalEquityRisk = 20.0;
extern string t2 = "Time Setting";
extern bool CloseFriday = FALSE;
extern int CloseFridayHour = 17;
extern bool OpenMondey = FALSE;
extern int OpenMondeyHour = 0;
extern string t3 = "Setting for Dancing Jaipong";
bool Gi_220 = FALSE;
double Gd_224 = 48.0;
extern bool UseTrailingStop_Hilo = FALSE;
double G_pips_236 = 500.0;
extern double TrailStart_Hilo = 10.0;
extern double TrailStop_Hilo = 5.0;
extern double PipStep_Hilo = 30.0;
extern double slip_Hilo = 3.0;
double G_price_280;
double Gd_288;
double Gd_unused_296;
double Gd_unused_304;
double G_price_312;
double G_bid_320;
double G_ask_328;
double Gd_336;
double Gd_344;
bool Gi_360;
string Gs_364 = "Dancing Jaipong";
int Gi_372 = 0;
int Gi_376;
int Gi_380 = 0;
double Gd_384;
int G_pos_392 = 0;
int Gi_396;
double Gd_400 = 0.0;
bool Gi_408 = FALSE;
bool Gi_412 = FALSE;
bool Gi_416 = FALSE;
int Gi_420;
bool Gi_424 = FALSE;
double Gd_428;
double Gd_436;
extern string t4 = "Setting for Dancing Keroncong";
extern double PipStep_15 = 30.0;

extern bool UseTrailingStop_15 = FALSE;
double G_pips_508 = 500.0;
extern double TrailStart_15 = 10.0;
extern double TrailStop_15 = 5.0;
bool Gi_532 = FALSE;
double Gd_536 = 48.0;
extern double slip_15 = 3.0;
double G_price_564;
double Gd_572;
double G_price_596;
double G_bid_604;
double G_ask_612;
double Gd_620;
double Gd_628;
double Gd_636;
bool Gi_644;
string Gs_648 = "Dancing Keroncong";
int Gi_656 = 0;
int Gi_660;
int Gi_664 = 0;
double Gd_668;
int G_pos_676 = 0;
int Gi_680;
double Gd_684 = 0.0;
bool Gi_692 = FALSE;
bool Gi_696 = FALSE;
bool Gi_700 = FALSE;
int Gi_704;
bool Gi_708 = FALSE;
double Gd_712;
double Gd_720;
int G_datetime_728 = 1;
extern string t5 = "Setting for Dancing Tortor";
int G_timeframe_784 = PERIOD_M1;
extern bool UseTrailingStop_16 = FALSE;
double G_pips_792 = 500.0;
extern double TrailStart_16 = 10.0;
extern double TrailStop_16 = 5.0;
bool Gi_816 = FALSE;
double Gd_820 = 48.0;
extern double PipStep_16 = 30.0;
extern double slip_16 = 3.0;
double G_price_848;
double Gd_856;
double Gd_unused_864;
double Gd_unused_872;
double G_price_880;
double G_bid_888;
double G_ask_896;
double Gd_904;
double Gd_912;
double Gd_920;
bool Gi_928;
string Gs_932 = "Dancing Tortor";
int Gi_940 = 0;
int Gi_944;
int Gi_948 = 0;
double Gd_952;
int G_pos_960 = 0;
int Gi_964;
double Gd_968 = 0.0;
bool Gi_976 = FALSE;
bool Gi_980 = FALSE;
bool Gi_984 = FALSE;
int Gi_988;
bool Gi_992 = FALSE;
double Gd_996;
double Gd_1004;
int G_datetime_1012 = 1;
bool G_corner_1052 = TRUE;
int Gi_1056 = 0;
int Gi_1060 = 10;
int G_window_1064 = 0;
bool Gi_1068 = TRUE;
bool Gi_unused_1072 = TRUE;
bool Gi_1076 = FALSE;
int G_color_1080 = Gray;
int G_color_1084 = Gray;
int G_color_1088 = Gray;
int G_color_1092 = DarkOrange;
int Gi_unused_1096 = 36095;
int G_color_1100 = Lime;
int G_color_1104 = OrangeRed;
int Gi_1108 = 65280;
int Gi_1112 = 17919;
int G_color_1116 = Lime;
int G_color_1120 = Red;
int G_color_1124 = Orange;
int G_period_1128 = 8;
int G_period_1132 = 17;
int G_period_1136 = 9;
int G_applied_price_1140 = PRICE_CLOSE;
int G_color_1144 = Lime;
int G_color_1148 = Tomato;
int G_color_1152 = Green;
int G_color_1156 = Red;
int G_period_1176 = 9;
int G_applied_price_1180 = PRICE_CLOSE;
int G_period_1192 = 13;
int G_applied_price_1196 = PRICE_CLOSE;
int G_period_1208 = 5;
int G_period_1212 = 3;
int G_slowing_1216 = 3;
int G_ma_method_1220 = MODE_EMA;
int G_color_1232 = Lime;
int G_color_1236 = Red;
int G_color_1240 = Orange;
int G_period_1252 = 5;
int G_period_1256 = 9;
int G_ma_method_1260 = MODE_EMA;
int G_applied_price_1264 = PRICE_CLOSE;
int G_color_1276 = Lime;
int G_color_1280 = Red;
string Gs_dummy_1292;
string G_text_1464;
string G_text_1472;
bool Gi_1480 = FALSE;//TRUE;
extern string KEY = "";
int Gi_1492;
int G_str2int_1496;
int G_str2int_1500;
int G_str2int_1504;
bool MA;


int init()                                      
   {
   if(Auto_MagicNumber = TRUE){
   if (Symbol()== "EURUSD"){ MagicNumber_Hilo = 17777;
                             G_magic_176_15 = 27777;
                             G_magic_176_16 = 37777; }
                             
   if (Symbol()== "USDJPY"){ MagicNumber_Hilo = 18888;
                             G_magic_176_15 = 28888;
                             G_magic_176_16 = 38888; }
                             
   if (Symbol()== "EURJPY"){ MagicNumber_Hilo = 19999;
                             G_magic_176_15 = 29999;
                             G_magic_176_16 = 39999; }
                             
   if (Symbol()== "AUDUSD"){ MagicNumber_Hilo = 16666;
                             G_magic_176_15 = 26666;
                             G_magic_176_16 = 36666; }

   }
   
   
   if(Filter_MA = FALSE) MA = TRUE;
                    else MA = FALSE;
   return(0);                                      
   } 


int start() {


   string Ls_unused_100;
   color color_108;
   int Li_unused_112;
   double ihigh_1128;
   double ilow_1136;
   double iclose_1144;
   double iclose_1152;
   double Ld_1192;
   double Ld_1248;
   double Ld_1256;
   int Li_1264;
   int count_1268;
   double Ld_1316;
   double Ld_1324;
   int Li_1332;
   int count_1336;
  

      color ColorJ=Yellow;
      color ColorK=Yellow;
      color ColorT=Yellow;   
      
      Jai_lot=0; Jai=0; J=0;
      Ker_lot=0; Ker=0; K=0;
      Tor_lot=0; Tor=0; T=0;

 /// ---------------------------------------------------------
 
    if (close_next_Jaipong == TRUE && f0_4()==0 )  Jaipong = FALSE;
    if (close_next_Keroncong == TRUE && f0_5()==0) Keroncong = FALSE;
    if (close_next_Tortor == TRUE && f0_12()==0) Tortor = FALSE;

   double ww=iMA(NULL,PERIOD_MA,29,0,MODE_LWMA,PRICE_CLOSE,1);

  //--------------------------------------------   Jaipong  ----------------------
   if (Jaipong == TRUE) 
   {
   
   double Ld_1160 = LotExponent;
   int Li_1168 = Gi_108;
   double Ld_1172 = TakeProfit;
   bool bool_1180 = UseEquityStop;
   double Ld_1184 = TotalEquityRisk;
         if (MM == TRUE) 
           {
               if (MathCeil(AccountBalance()) < 2000.0) Ld_1192 = Lots;
               else Ld_1192 = 0.00001 * MathCeil(AccountBalance());
           }   else Ld_1192 = Lots;
         if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour + ":00")))
             return (0);
         if (UseTrailingStop_Hilo) f0_35(TrailStart_Hilo, TrailStop_Hilo, G_price_312);
         if (Gi_220)
            {
            if (TimeCurrent() >= Gi_376) {
               f0_24();
               Print("Closed All due_Hilo to TimeOut"); }
            }
         if (Gi_372 == Time[0]) return (0);
         Gi_372 = Time[0];
         double Ld_1200 = f0_31();
         if (bool_1180) {
            if (Ld_1200 < 0.0 && MathAbs(Ld_1200) > Ld_1184 / 100.0 * f0_7()) {
               f0_24();
               Print("Closed All due_Hilo to Stop Out");
               Gi_424 = FALSE;
            }
         }
         
   Gi_396 = f0_4();
   if (Gi_396 == 0) Gi_360 = FALSE;
   for (G_pos_392 = OrdersTotal() - 1; G_pos_392 >= 0; G_pos_392--)
    {
      OrderSelect(G_pos_392, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
         if (OrderType() == OP_BUY) {
            Gi_412 = TRUE;
            Gi_416 = FALSE;
            break;
         }
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
         if (OrderType() == OP_SELL) {
            Gi_412 = FALSE;
            Gi_416 = TRUE;
            break;
         }
      }
    }
    
   if (Gi_396 > 0 && Gi_396 <= MaxTrades_Hilo) {
      RefreshRates();
      Gd_336 = f0_32();
      Gd_344 = f0_20();
      if (Gi_412 && Gd_336 - Ask >= PipStep_Hilo * Point) Gi_408 = TRUE;
      if (Gi_416 && Bid - Gd_344 >= PipStep_Hilo * Point) Gi_408 = TRUE;
   }
   if (Gi_396 < 1) {
      Gi_416 = FALSE;
      Gi_412 = FALSE;
      Gi_408 = TRUE;
      Gd_288 = AccountEquity();
   }
   if (Gi_408) {
      Gd_336 = f0_32();
      Gd_344 = f0_20();
      if (Gi_416) {
         Gi_380 = Gi_396;
         Gd_384 = NormalizeDouble(Ld_1192 * MathPow(Ld_1160, Gi_380), Li_1168);  // îïðåäåëåíèå ïîñëåäóùåãî ëîòà (x 1.5)
         RefreshRates();
         Gi_420 = f0_3(1, Gd_384, Bid, slip_Hilo, Ask, 0, 0, Gs_364 + "-" + Gi_380, MagicNumber_Hilo, 0, HotPink);
         if (Gi_420 < 0) {
            Print("Error: ", GetLastError());
            return (0);
         }
         Gd_344 = f0_20();
         Gi_408 = FALSE;
         Gi_424 = TRUE;
      } else {
         if (Gi_412) {
            Gi_380 = Gi_396;
            Gd_384 = NormalizeDouble(Ld_1192 * MathPow(Ld_1160, Gi_380), Li_1168); // îïðåäåëåíèå ïîñëåäóùåãî ëîòà (x 1.5)
            Gi_420 = f0_3(0, Gd_384, Ask, slip_Hilo, Bid, 0, 0, Gs_364 + "-" + Gi_380, MagicNumber_Hilo, 0, HotPink );
            if (Gi_420 < 0) {
               Print("Error: ", GetLastError());
               return (0);
            }
            Gd_336 = f0_32();
            Gi_408 = FALSE;
            Gi_424 = TRUE;
         }
      }
   }
   if (Gi_408 && Gi_396 < 1 )           // -------   / íà÷àëî ñòðàòåãèè Jaipong
    {                   
      ihigh_1128 = iHigh(Symbol(), 0, 1);
      ilow_1136 = iLow(Symbol(), 0, 2);
      G_bid_320 = Bid;
      G_ask_328 = Ask;
      if ((!Gi_416) && !Gi_412 && step_J < max_J_steps) {
         Gi_380 = Gi_396;
         Gd_384 = NormalizeDouble(Ld_1192 * MathPow(Ld_1160, Gi_380), Li_1168);
         if (ihigh_1128 > ilow_1136) {
            if (iRSI(NULL, PERIOD, 14, PRICE_CLOSE, 1) > 30.0)
             {
               Gi_420 = f0_3(1, Gd_384, G_bid_320, slip_Hilo, G_bid_320, 0, 0, Gs_364 + "-" + Gi_380, MagicNumber_Hilo, 0, HotPink );
               if (Gi_420 < 0) {
                  Print("Error: ", GetLastError());
                  return (0);
               }
               Gd_336 = f0_32();
               Gi_424 = TRUE;
               step_J = step_J+1; last_step_J=1;

            }
         } else {
            if (iRSI(NULL, PERIOD, 14, PRICE_CLOSE, 1) < 70.0) {
               Gi_420 = f0_3(0, Gd_384, G_ask_328, slip_Hilo, G_ask_328, 0, 0, Gs_364 + "-" + Gi_380, MagicNumber_Hilo, 0, HotPink );
               if (Gi_420 < 0) {
                  Print("Error: ", GetLastError());
                  return (0);
               }
               Gd_344 = f0_20();
               Gi_424 = TRUE;
               step_J = step_J+1; last_step_J=1;
            }
         }
         if (Gi_420 > 0) Gi_376 = TimeCurrent() + 60.0 * (60.0 * Gd_224);
         Gi_408 = FALSE;
      }
      
   }
   Gi_396 = f0_4();
   G_price_312 = 0;
   double Ld_1208 = 0;
   for (G_pos_392 = OrdersTotal() - 1; G_pos_392 >= 0; G_pos_392--) {
      OrderSelect(G_pos_392, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
            G_price_312 += OrderOpenPrice() * OrderLots();
            Ld_1208 += OrderLots();
         }
      }
   }
   if (Gi_396 > 0) G_price_312 = NormalizeDouble(G_price_312 / Ld_1208, Digits);
   if (Gi_424) {
      for (G_pos_392 = OrdersTotal() - 1; G_pos_392 >= 0; G_pos_392--) {
         OrderSelect(G_pos_392, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
            if (OrderType() == OP_BUY) {
               G_price_280 = G_price_312 + Ld_1172 * Point;
               Gd_unused_296 = G_price_280;
               Gd_400 = G_price_312 - G_pips_236 * Point;
               Gi_360 = TRUE;
            }
         }
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) {
            if (OrderType() == OP_SELL) {
               G_price_280 = G_price_312 - Ld_1172 * Point;
               Gd_unused_304 = G_price_280;
               Gd_400 = G_price_312 + G_pips_236 * Point;
               Gi_360 = TRUE;
            }
         }
      }
      

   }
   if (Gi_424) {
      if (Gi_360 == TRUE) {
         for (G_pos_392 = OrdersTotal() - 1; G_pos_392 >= 0; G_pos_392--) {
            OrderSelect(G_pos_392, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo) OrderModify(OrderTicket(), G_price_312, OrderStopLoss(), G_price_280, 0, Yellow);
            Gi_424 = FALSE;
         }
      }
   }
   }
   
   // ----------------------------------------------   Keroncong  ---------------------

   if (Keroncong == TRUE) {

   double Ld_1216 = LotExponent;
   int Li_1224 = Gi_108;
   double Ld_1228 = TakeProfit;
   bool bool_1236 = UseEquityStop;
   double Ld_1240 = TotalEquityRisk;
   if (MM == TRUE) {
      if (MathCeil(AccountBalance()) < 2000.0) Ld_1248 = Lots;
      else Ld_1248 = 0.00001 * MathCeil(AccountBalance());
   } else Ld_1248 = Lots;
   if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
      ":00"))) return (0);
   if (UseTrailingStop_15) f0_21(TrailStart_15, TrailStop_15, G_price_596);
 
 
 ////////----------------------------------------
 
 
   if (Gi_656 != Time[0]) {    /// Gi_656 = 0;
      Gi_656 = Time[0];
      Ld_1256 = f0_29();     /// f0_29() ñóììàðíûé ïðîôèò âñåõ ïîçèöèé
      if (bool_1236) {
         if (Ld_1256 < 0.0 && MathAbs(Ld_1256) > Ld_1240 / 100.0 * f0_16()) {
            f0_18();
            Print("Closed All due to Stop Out");
            Gi_708 = FALSE;
         }
      }
      
      Gi_680 = f0_5();  /// êîë-âî îòêðûòûõ ïîç.
      if (Gi_680 == 0) Gi_644 = FALSE;
      for (G_pos_676 = OrdersTotal() - 1; G_pos_676 >= 0; G_pos_676--) {
         OrderSelect(G_pos_676, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_15) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15) {
            if (OrderType() == OP_BUY) {
               Gi_696 = TRUE;  ///////  BUY
               Gi_700 = FALSE;
               break;
            }
         }
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15) {
            if (OrderType() == OP_SELL) {
               Gi_696 = FALSE; 
               Gi_700 = TRUE;  ////////// SELL
               break;
            }
         }
      }
      if (Gi_680 > 0 && Gi_680 <= MaxTrades_15) {
         RefreshRates();
         Gd_620 = f0_36();
         Gd_628 = f0_28();
         if (Gi_696 && Gd_620 - Ask >= PipStep_15 * Point) Gi_692 = TRUE;
         if (Gi_700 && Bid - Gd_628 >= PipStep_15 * Point) Gi_692 = TRUE;
      }
      if (Gi_680 < 1) {   // êîë-âî îòêðûòûõ ïîç.
         Gi_700 = FALSE;
         Gi_696 = FALSE;
         Gi_692 = TRUE;
         Gd_572 = AccountEquity();
      }
      if (Gi_692) {          ///åñëè äà, òî ïðîäîëæàåì ðàñòè ñåòêó
         Gd_620 = f0_36();
         Gd_628 = f0_28();
         if (Gi_700) {   /// åñëè åñòü SELL
            Gi_664 = Gi_680;/// êîë-âî îòêðûòûõ ïîç.
            Gd_668 = NormalizeDouble(Ld_1248 * MathPow(Ld_1216, Gi_664), Li_1224);
            RefreshRates();
            Gi_704 = f0_2(1, Gd_668, Bid, slip_15, Ask, 0, 0, Gs_648 + "-" + Gi_664, G_magic_176_15, 0, Lime);
            if (Gi_704 < 0) {
               Print("Error: ", GetLastError());
               return (0);
            }
            Gd_628 = f0_28();
            Gi_692 = FALSE;
            Gi_708 = TRUE;
         } else {
            if (Gi_696) {        /// åñëè åñòü BUY
               Gi_664 = Gi_680; /// êîë-âî îòêðûòûõ ïîç.
               Gd_668 = NormalizeDouble(Ld_1248 * MathPow(Ld_1216, Gi_664), Li_1224);
               Gi_704 = f0_2(0, Gd_668, Ask, slip_15, Bid, 0, 0, Gs_648 + "-" + Gi_664, G_magic_176_15, 0, Lime);
               if (Gi_704 < 0) {
                  Print("Error: ", GetLastError());
                  return (0);
               }
               Gd_620 = f0_36();
               Gi_692 = FALSE;
               Gi_708 = TRUE;
            }
         }
      }
   }
   
  ////                                        ÎÒÊÐÛÒÈÅ ÏÎÇ.
 /////////////// -------------------------------------------------------
   
   
   
   
   if (G_datetime_728 != iTime(NULL, next_step_after, 0)) {
      Li_1264 = OrdersTotal();
      count_1268 = 0;
      for (int Li_1272 = Li_1264; Li_1272 >= 1; Li_1272--) {
         OrderSelect(Li_1272 - 1, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_15) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15) count_1268++;
      }
      if (Li_1264 == 0 || count_1268 < 1)
       if (step_K < max_K_steps) {
         iclose_1144 = iClose(Symbol(), 0, 2);
         iclose_1152 = iClose(Symbol(), 0, 1);
         G_bid_604 = Bid;
         G_ask_612 = Ask;
         Gi_664 = Gi_680;
         Gd_668 = Ld_1248;
         if (iclose_1144 > iclose_1152 ) {  //sell
            if(MA || iclose_1152 < ww){
            Gi_704 = f0_2(1, Gd_668, G_bid_604, slip_15, G_bid_604, 0, 0, Gs_648 + "-" + Gi_664, G_magic_176_15, 0, Lime);
            if (Gi_704 < 0) {
               Print("Error: ", GetLastError());
               return (0);
            }
            Gd_620 = f0_36();
            Gi_708 = TRUE; step_K = step_K + 1; last_step_K=1; }}
        else {  //buy
            if(MA || iclose_1152 > ww){
            Gi_704 = f0_2(0, Gd_668, G_ask_612, slip_15, G_ask_612, 0, 0, Gs_648 + "-" + Gi_664, G_magic_176_15, 0, Lime);
            if (Gi_704 < 0) {
               Print("Error: ", GetLastError());
               return (0);
            }
            Gd_628 = f0_28();
            Gi_708 = TRUE;  step_K = step_K + 1;  last_step_K=1;
         }}
         if (Gi_704 > 0) Gi_660 = TimeCurrent() + 60.0 * (60.0 * Gd_536);
         Gi_692 = FALSE;
         
       }
      }
      G_datetime_728 = iTime(NULL, next_step_after, 0);
      
   /////// -------------------------------------------------------------
     
   Gi_680 = f0_5();
   G_price_596 = 0;
   double Ld_1276 = 0;
   for (G_pos_676 = OrdersTotal() - 1; G_pos_676 >= 0; G_pos_676--) {
      OrderSelect(G_pos_676, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_15) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15) {
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
            G_price_596 += OrderOpenPrice() * OrderLots();
            Ld_1276 += OrderLots();
         }
      }
   }
   
   if (Gi_680 > 0) G_price_596 = NormalizeDouble(G_price_596 / Ld_1276, Digits);
   if (Gi_708) {
      for (G_pos_676 = OrdersTotal() - 1; G_pos_676 >= 0; G_pos_676--) {
         OrderSelect(G_pos_676, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_15) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15) {
            if (OrderType() == OP_BUY) {
               G_price_564 = G_price_596 + Ld_1228 * Point;   ////   Ld_1228 = TakeProfit;
               Gd_684 = G_price_596 - G_pips_508 * Point;
               Gi_644 = TRUE;
            }
         }
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15) {
            if (OrderType() == OP_SELL) {
               G_price_564 = G_price_596 - Ld_1228 * Point;
               Gd_684 = G_price_596 + G_pips_508 * Point;
               Gi_644 = TRUE;
            }
         }
      }
   }
   if (Gi_708) {
      if (Gi_644 == TRUE) {
         for (G_pos_676 = OrdersTotal() - 1; G_pos_676 >= 0; G_pos_676--) {
            OrderSelect(G_pos_676, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_15) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15) OrderModify(OrderTicket(), G_price_596, OrderStopLoss(), G_price_564, 0, Yellow);
            Gi_708 = FALSE;
         }
      }
   }
  } 
   
   
  
   // ----------------------------------------------   Tortor  --------------------- 

   if (Tortor == TRUE) {
   
   double Ld_1284 = LotExponent;
   int Li_1292 = Gi_108;
   double Ld_1296 = TakeProfit;
   bool bool_1304 = UseEquityStop;
   double Ld_1308 = TotalEquityRisk;
   if (MM == TRUE) {
      if (MathCeil(AccountBalance()) < 2000.0) Ld_1316 = Lots;
      else Ld_1316 = 0.00001 * MathCeil(AccountBalance());
   } else Ld_1316 = Lots;
   if ((CloseFriday == TRUE && DayOfWeek() == 5 && TimeCurrent() >= StrToTime(CloseFridayHour + ":00")) || (OpenMondey == TRUE && DayOfWeek() == 1 && TimeCurrent() <= StrToTime(OpenMondeyHour +
      ":00"))) return (0);
   if (UseTrailingStop_16) f0_34(TrailStart_16, TrailStop_16, G_price_880);
   if (Gi_816) {
      if (TimeCurrent() >= Gi_944) {
         f0_0();
         Print("Closed All due to TimeOut");
      }
   }
   if (Gi_940 != Time[0]) {
      Gi_940 = Time[0];
      Ld_1324 = f0_8();
      if (bool_1304)
       {
         if (Ld_1324 < 0.0 && MathAbs(Ld_1324) > Ld_1308 / 100.0 * f0_30())
          {
            f0_0();
            Print("Closed All due to Stop Out");
            Gi_992 = FALSE;
          }
       }
      Gi_964 = f0_12();
      if (Gi_964 == 0) Gi_928 = FALSE;
      for (G_pos_960 = OrdersTotal() - 1; G_pos_960 >= 0; G_pos_960--) {
         OrderSelect(G_pos_960, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_16) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16) {
            if (OrderType() == OP_BUY) {
               Gi_980 = TRUE;
               Gi_984 = FALSE;
               break;
            }
         }
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16) {
            if (OrderType() == OP_SELL) {
               Gi_980 = FALSE;
               Gi_984 = TRUE;
               break;
            }
         }
      }
      if (Gi_964 > 0 && Gi_964 <= MaxTrades_16) {
         RefreshRates();
         Gd_904 = f0_17();
         Gd_912 = f0_27();
         if (Gi_980 && Gd_904 - Ask >= PipStep_16 * Point) Gi_976 = TRUE;
         if (Gi_984 && Bid - Gd_912 >= PipStep_16 * Point) Gi_976 = TRUE;
      }
      if (Gi_964 < 1) {
         Gi_984 = FALSE;
         Gi_980 = FALSE;
         Gd_856 = AccountEquity();
      }
      if (Gi_976) {
         Gd_904 = f0_17();
         Gd_912 = f0_27();
         if (Gi_984) {
            Gi_948 = Gi_964;
            Gd_952 = NormalizeDouble(Ld_1316 * MathPow(Ld_1284, Gi_948), Li_1292);
            RefreshRates();
            Gi_988 = f0_6(1, Gd_952, Bid, slip_16, Ask, 0, 0, Gs_932 + "-" + Gi_948, G_magic_176_16, 0, Black);
            if (Gi_988 < 0) {
               Print("Error: ", GetLastError());
               return (0);
            }
            Gd_912 = f0_27();
            Gi_976 = FALSE;
            Gi_992 = TRUE;
         } else {
            if (Gi_980) {
               Gi_948 = Gi_964;
               Gd_952 = NormalizeDouble(Ld_1316 * MathPow(Ld_1284, Gi_948), Li_1292);
               Gi_988 = f0_6(0, Gd_952, Ask, slip_16, Bid, 0, 0, Gs_932 + "-" + Gi_948, G_magic_176_16, 0, Black);
               if (Gi_988 < 0) {
                  Print("Error: ", GetLastError());
                  return (0);
               }
               Gd_904 = f0_17();
               Gi_976 = FALSE;
               Gi_992 = TRUE;
            }
         }
      }
   }
   if (G_datetime_1012 != iTime(NULL, G_timeframe_784, 0)) {
      Li_1332 = OrdersTotal();
      count_1336 = 0;
      for (int Li_1340 = Li_1332; Li_1340 >= 1; Li_1340--) {
         OrderSelect(Li_1340 - 1, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_16) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16) count_1336++;
      }
      if (Li_1332 == 0 || count_1336 < 1) 
       if (step_T < max_T_steps)
         {
         iclose_1144 = iClose(Symbol(), 0, 2);
         iclose_1152 = iClose(Symbol(), 0, 1);
         G_bid_888 = Bid;
         G_ask_896 = Ask;
         Gi_948 = Gi_964;
         Gd_952 = Ld_1316;
                  
         if (iclose_1144 > iclose_1152) {
            if (iRSI(NULL, PERIOD, 14, PRICE_CLOSE, 1) > 30.0) {
               Gi_988 = f0_6(1, Gd_952, G_bid_888, slip_16, G_bid_888, 0, 0, Gs_932 + "-" + Gi_948, G_magic_176_16, 0, Black);
               if (Gi_988 < 0) {
                  Print("Error: ", GetLastError());
                  return (0);
               }
               Gd_904 = f0_17();
               Gi_992 = TRUE;  step_T = step_T + 1;  last_step_T=1;
            }
         } else {
            if (iRSI(NULL, PERIOD, 14, PRICE_CLOSE, 1) < 70.0) {
               Gi_988 = f0_6(0, Gd_952, G_ask_896, slip_16, G_ask_896, 0, 0, Gs_932 + "-" + Gi_948, G_magic_176_16, 0, Black);
               if (Gi_988 < 0) {
                  Print("Error: ", GetLastError());
                  return (0);
               }
               Gd_912 = f0_27();
               Gi_992 = TRUE;  step_T = step_T + 1; last_step_T=1;
            }
         }
         if (Gi_988 > 0) Gi_944 = TimeCurrent() + 60.0 * (60.0 * Gd_820);
         Gi_976 = FALSE;
         
      }
      G_datetime_1012 = iTime(NULL, G_timeframe_784, 0);
   }
   Gi_964 = f0_12();
   G_price_880 = 0;
   double Ld_1344 = 0;
   for (G_pos_960 = OrdersTotal() - 1; G_pos_960 >= 0; G_pos_960--) {
      OrderSelect(G_pos_960, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_16) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16) {
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
            G_price_880 += OrderOpenPrice() * OrderLots();
            Ld_1344 += OrderLots();
         }
      }
   }
   if (Gi_964 > 0) G_price_880 = NormalizeDouble(G_price_880 / Ld_1344, Digits);
   if (Gi_992) {
      for (G_pos_960 = OrdersTotal() - 1; G_pos_960 >= 0; G_pos_960--) {
         OrderSelect(G_pos_960, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_16) continue;
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16) {
            if (OrderType() == OP_BUY) {
               G_price_848 = G_price_880 + Ld_1296 * Point;
               Gd_unused_864 = G_price_848;
               Gd_968 = G_price_880 - G_pips_792 * Point;
               Gi_928 = TRUE;
            }
         }
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16) {
            if (OrderType() == OP_SELL) {
               G_price_848 = G_price_880 - Ld_1296 * Point;
               Gd_unused_872 = G_price_848;
               Gd_968 = G_price_880 + G_pips_792 * Point;
               Gi_928 = TRUE;
            }
         }
      }
   }
   if (Gi_992) {
      if (Gi_928 == TRUE) {
         for (G_pos_960 = OrdersTotal() - 1; G_pos_960 >= 0; G_pos_960--) {
            OrderSelect(G_pos_960, SELECT_BY_POS, MODE_TRADES);
            if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_16) continue;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16) OrderModify(OrderTicket(), G_price_880, OrderStopLoss(), G_price_848, 0, Yellow);
            Gi_992 = FALSE;
         }
      }
   }
   }
   
   /// -------------------------------------------  Trio Total  --------------------
   

  if (OrdersTotal()>0)
     {
      
      for(int i=OrdersTotal()-1; i>=0; i--)

                {
                OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
                  if(OrderSymbol()==Symbol()&& OrderMagicNumber()==MagicNumber_Hilo)
                    { 
                      if (OrderType()==0) posJ="Buy";
                      else posJ="Sell";
                      a = StringSubstr(OrderComment(),8,1);
                      Jai_lot=Jai_lot + OrderLots();
                      Jai=Jai + OrderProfit();      Jai_r=Jai;    if (Jai<max_loss_J) max_loss_J=Jai;
                      J=J+1;                        J_r=J;
                      
  
                    }
                  else if(OrderSymbol()==Symbol()&& OrderMagicNumber()==G_magic_176_15)
                    {
                      if (OrderType()==0) posK="Buy";
                      else posK="Sell";
                      b = StringSubstr(OrderComment(),8,1);
                      Ker_lot=Ker_lot + OrderLots();
                      Ker=Ker + OrderProfit();          if (Ker<max_loss_K) max_loss_K=Ker;
                      K=K+1;   K_r=K; Ker_r=Ker;
                    } 
                  else if(OrderSymbol()==Symbol()&& OrderMagicNumber()==G_magic_176_16)
                    { 
                      if (OrderType()==0) posT="Buy";
                      else posT="Sell";
                      c = StringSubstr(OrderComment(),8,1);
                      Tor_lot=Tor_lot + OrderLots();
                      Tor=Tor + OrderProfit();         if (Tor<max_loss_T) max_loss_T=Tor;
                      T=T+1;   T_r=T; Tor_r=Tor;
                    }         
                }
                
              
    
       ObjectDelete("Total Jaipon");
       ObjectDelete("Total Keronc");
       ObjectDelete("Total Tortor");

       if (Jaipong == TRUE){  if(J>7) ColorJ=Red;
          ObjectCreate("Total Jaipon", OBJ_LABEL,0, 0, 0); 
                       ObjectSet( "Total Jaipon",OBJPROP_CORNER, 2);
                       ObjectSet( "Total Jaipon",OBJPROP_YDISTANCE, 50);
                       ObjectSet( "Total Jaipon",OBJPROP_XDISTANCE, 5);  
                       ObjectSetText("Total Jaipon", a + "  " +posJ+"  "+ IntegerToString(J)/* ñê. êîëåí */ + "    " + DoubleToStr(Jai, 2)/* profit*/ + "    " + DoubleToStr(Jai_lot, 2) + "   max loss "+ max_loss_J + "    step "+IntegerToString(step_J), 14, "Arial", ColorJ );}
      if (Keroncong == TRUE){    if(K>7) ColorK=Red;            
         ObjectCreate("Total Keronc", OBJ_LABEL,0, 0, 0); 
                       ObjectSet( "Total Keronc",OBJPROP_CORNER, 2);
                       ObjectSet( "Total Keronc",OBJPROP_YDISTANCE, 30);
                       ObjectSet( "Total Keronc",OBJPROP_XDISTANCE, 5);  
                       ObjectSetText("Total Keronc", b + " " +posK+"   " +IntegerToString(K) + "    " + DoubleToStr(Ker, 2) + "    " + DoubleToStr(Ker_lot, 2) + "   max loss "+ max_loss_K + "    step "+IntegerToString(step_K), 14, "Arial", ColorK ); }  
       if (Tortor == TRUE){    if(T>7) ColorT=Red;              
          ObjectCreate("Total Tortor", OBJ_LABEL,0, 0, 0); 
                       ObjectSet( "Total Tortor",OBJPROP_CORNER, 2);
                       ObjectSet( "Total Tortor",OBJPROP_YDISTANCE, 10);
                       ObjectSet( "Total Tortor",OBJPROP_XDISTANCE, 5);  
                       ObjectSetText("Total Tortor", c + " " +posT+"   "+ IntegerToString(T) + "    " + DoubleToStr(Tor, 2) + "    " + DoubleToStr(Tor_lot, 2)+ "   max loss "+ max_loss_T + "    step "+IntegerToString(step_T), 14, "Arial", ColorT ); }   
      }

      
 /// ------------------------  Over loss close  --------------    
  
   if(max_loss_J < Jaipong_Loss_Limit && J>MaxTrades_Hilo)
      {
         f0_24();
         Print("Maximum Loss Jaipong was -",max_loss_J);
         max_loss_J=0;
         Print("Closed All Jaipong due Over Limit");
      }
  if(max_loss_K < Keroncong_Loss_Limit && K>MaxTrades_15)
      {
         f0_18();
         Print("Maximum Loss Keroncong was -",max_loss_K);
         max_loss_K=0;
         Print("Closed All Keroncong due Over Limit");
      }
  if(max_loss_T < Tortor_Loss_Limit && T>MaxTrades_16)
      {
         f0_0();
         Print("Maximum Loss Tortor was -",max_loss_T);
         max_loss_T=0;
         Print("Closed All Tortor due Over Limit");
      }
 ///---------------------------------------------------------- Trio Report  -----------------
     
     if (report==TRUE) {
      int handle;
      string date, min, report_file;
      report_file=TimeToStr(TimeLocal(),TIME_DATE)+"_report.csv";
      if (J==0 && last_step_J==1){ handle=FileOpen(report_file,FILE_CSV|FILE_READ|FILE_WRITE,"\t");
             if(handle<1) { Print("File (report) not found, the last error is ", GetLastError()); return(false); }
             if(handle>0) {date = StringSubstr(TimeToStr(TimeLocal(),TIME_DATE|TIME_MINUTES), 5, 5);
                           min = StringSubstr(TimeToStr(TimeLocal(),TIME_DATE|TIME_MINUTES), 11, 5);
                           FileSeek(handle, 0, SEEK_END);
                           FileWrite(handle,Symbol(), " J step ", step_J, J_r , Jai_r , min, "  ", date );
                           FileClose(handle);
                           handle=0; J_r=0; Jai_r=0; last_step_J=0;
                          }
                    }
      if (K==0 && last_step_K==1){  handle=FileOpen(report_file,FILE_CSV|FILE_READ|FILE_WRITE,"\t");
             if(handle<1) { Print("File (report) not found, the last error is ", GetLastError()); return(false);  }
             if(handle>0) {date = StringSubstr(TimeToStr(TimeLocal(),TIME_DATE|TIME_MINUTES), 5, 5);
                           min = StringSubstr(TimeToStr(TimeLocal(),TIME_DATE|TIME_MINUTES), 11, 5);
                           FileSeek(handle, 0, SEEK_END);
                           FileWrite(handle,Symbol(), " K step ", step_K, K_r , Ker_r , min, "  ", date );
                           FileClose(handle);
                           handle=0; K_r=0; Ker_r=0; last_step_K=0;
                          }
                    }   

      if (T==0 && last_step_T==1){ handle=FileOpen(report_file,FILE_CSV|FILE_READ|FILE_WRITE,"\t");
             if(handle<1) { Print("File (report) not found, the last error is ", GetLastError()); return(false); }
             if(handle>0) { date = StringSubstr(TimeToStr(TimeLocal(),TIME_DATE|TIME_MINUTES), 5, 5);
                            min = StringSubstr(TimeToStr(TimeLocal(),TIME_DATE|TIME_MINUTES), 11, 5);
                           FileSeek(handle, 0, SEEK_END);
                           FileWrite(handle,Symbol(), " T step ", step_T, T_r , Tor_r , min, "  ", date );
                           FileClose(handle);
                           handle=0; T_r=0; Tor_r=0; last_step_T=0;
                          }
                    }
             }
 ///----------------------------------------------------------

   return (0);
}



  // ------------------------  end all programm int start()  ---------------------



int f0_4() {                 //ïîäñ÷¸ò îòêðûòûõ ïîç. Jaipong
   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_Hilo) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
         if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
   }
   return (count_0);
}

void f0_24() {           //çàêðûòèå âñåõ Jaipong

   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_Hilo) {
            if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip_Hilo, Blue);
            if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip_Hilo, Red);
         }
         Sleep(1000);
      }
   }
}

//              îòêðûòèå ïîçèöèé Jaipong

int f0_3(int Ai_0, double A_lots_4, double A_price_12, int A_slippage_20, double Ad_24, int Ai_32, int Ai_36, string A_comment_40, int A_magic_48, int A_datetime_52, color A_color_56) {
   int ticket_60 = 0;
   int error_64 = 0;
   int count_68 = 0;
   int Li_72 = 100;
   switch (Ai_0) {
   case 2:
      for (count_68 = 0; count_68 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, A_lots_4, A_price_12, A_slippage_20, f0_22(Ad_24, Ai_32), f0_19(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, A_lots_4, A_price_12, A_slippage_20, f0_22(Ad_24, Ai_32), f0_19(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         RefreshRates();
         ticket_60 = OrderSend(Symbol(), OP_BUY, A_lots_4, Ask, A_slippage_20, f0_22(Bid, Ai_32), f0_19(Ask, Ai_36), A_comment_40, A_magic_48, A_datetime_52, A_color_56);
         PlaySound("jaipong.wav");
         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 3:
      for (count_68 = 0; count_68 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, A_lots_4, A_price_12, A_slippage_20, f0_11(Ad_24, Ai_32), f0_1(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, A_lots_4, A_price_12, A_slippage_20, f0_11(Ad_24, Ai_32), f0_1(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELL, A_lots_4, Bid, A_slippage_20, f0_11(Ask, Ai_32), f0_1(Bid, Ai_36), A_comment_40, A_magic_48, A_datetime_52, A_color_56);
         PlaySound("jaipong.wav");
         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);
}

// ABBF0924C7D109476997F144FF69BA18
double f0_22(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 - Ai_8 * Point);
}

// 65324E009A83B2CB88BFB3D4529CFA3F
double f0_11(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 + Ai_8 * Point);
}

// A4B319A5A3851A7BB5CE0B195DF27F55
double f0_19(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 + Ai_8 * Point);
}

// 0CCFFE5E259E6D9684C883601327DD0E
double f0_1(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 - Ai_8 * Point);
}

// ïîäñ÷¸ò ïðîôèòà 
double f0_31() {
   double Ld_ret_0 = 0;
   for (G_pos_392 = OrdersTotal() - 1; G_pos_392 >= 0; G_pos_392--) {
      OrderSelect(G_pos_392, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber_Hilo) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo)
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) Ld_ret_0 += OrderProfit();
   }
   return (Ld_ret_0);
}

//                               ----------------------    çàìåíà StopLoss  -------------
void f0_35(int Ai_0, int Ai_4, double A_price_8) {
   int Li_16;
   double order_stoploss_20;
   double price_28;
   if (Ai_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_Hilo) continue;
            if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber_Hilo) {
               if (OrderType() == OP_BUY) {
                  Li_16 = NormalizeDouble((Bid - A_price_8) / Point, 0);
                  if (Li_16 < Ai_0) continue;
                  order_stoploss_20 = OrderStopLoss();
                  price_28 = Bid - Ai_4 * Point;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_28 > order_stoploss_20)) OrderModify(OrderTicket(), A_price_8, price_28, OrderTakeProfit(), 0, Aqua);
               }
               if (OrderType() == OP_SELL) {
                  Li_16 = NormalizeDouble((A_price_8 - Ask) / Point, 0);
                  if (Li_16 < Ai_0) continue;
                  order_stoploss_20 = OrderStopLoss();
                  price_28 = Ask + Ai_4 * Point;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_28 < order_stoploss_20)) OrderModify(OrderTicket(), A_price_8, price_28, OrderTakeProfit(), 0, Red);
               }
            }
            Sleep(1000);
         }
      }
   }
}

//            ------------------------   Áàëàíñ -----------
double f0_7() {
   if (f0_4() == 0) Gd_428 = AccountEquity();
   if (Gd_428 < Gd_436) Gd_428 = Gd_436;
   else Gd_428 = AccountEquity();
   Gd_436 = AccountEquity();
   return (Gd_428);
}

//                           ------------   
double f0_32() {
   double order_open_price_0;
   int ticket_8;
   double Ld_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_Hilo) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_BUY) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            Ld_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// A5F3F48E555BFC9A5526CC1B30FF0AB2
double f0_20() {
   double order_open_price_0;
   int ticket_8;
   double Ld_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_Hilo) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber_Hilo && OrderType() == OP_SELL) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            Ld_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// 22F0FA52408CE450B63ADF3F087F21DE
int f0_5() {
   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() != G_magic_176_15) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15)
         if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
   }
   return (count_0);
}

// A180C6ED0DC34AACA6CCA8CB05FECC10
void f0_18() {
   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() == G_magic_176_15) {
            if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip_15, Blue);
            if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip_15, Red);
         }
         Sleep(1000);
      }
   }
}

// 114DC2E883BB39B95234C711A240BE3E
int f0_2(int Ai_0, double A_lots_4, double A_price_12, int A_slippage_20, double Ad_24, int Ai_32, int Ai_36, string A_comment_40, int A_magic_48, int A_datetime_52, color A_color_56) {
   int ticket_60 = 0;
   int error_64 = 0;
   int count_68 = 0;
   int Li_72 = 100;
   switch (Ai_0) {
   case 2:
      for (count_68 = 0; count_68 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, A_lots_4, A_price_12, A_slippage_20, f0_13(Ad_24, Ai_32), f0_25(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, A_lots_4, A_price_12, A_slippage_20, f0_13(Ad_24, Ai_32), f0_25(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         RefreshRates();
         ticket_60 = OrderSend(Symbol(), OP_BUY, A_lots_4, Ask, A_slippage_20, f0_13(Bid, Ai_32), f0_25(Ask, Ai_36), A_comment_40, A_magic_48, A_datetime_52, A_color_56);
         PlaySound("keroncong.wav");
         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 3:
      for (count_68 = 0; count_68 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, A_lots_4, A_price_12, A_slippage_20, f0_33(Ad_24, Ai_32), f0_26(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, A_lots_4, A_price_12, A_slippage_20, f0_33(Ad_24, Ai_32), f0_26(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELL, A_lots_4, Bid, A_slippage_20, f0_33(Ask, Ai_32), f0_26(Bid, Ai_36), A_comment_40, A_magic_48, A_datetime_52, A_color_56);
         PlaySound("keroncong.wav");
         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);
}

// 7AE15E889172CCCB33ECFB32124CDF19
double f0_13(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 - Ai_8 * Point);
}

// E29638E1934BE380D2D902E838F29BF7
double f0_33(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 + Ai_8 * Point);
}

// BCF3A4C4831B7913DD5F18AF706ADC75
double f0_25(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 + Ai_8 * Point);
}

// C4C44C724F3DAE9C33262735893D433A
double f0_26(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 - Ai_8 * Point);
}

// D3C476201B00C1A782FB71A65C106452
double f0_29() {
   double Ld_ret_0 = 0;
   for (G_pos_676 = OrdersTotal() - 1; G_pos_676 >= 0; G_pos_676--) {
      OrderSelect(G_pos_676, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_15) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15)
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) Ld_ret_0 += OrderProfit();
   }
   return (Ld_ret_0);
}

// A84D2ACC80FE890D5547A65D5C3D18EE
void f0_21(int Ai_0, int Ai_4, double A_price_8) {
   int Li_16;
   double order_stoploss_20;
   double price_28;
   if (Ai_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() != G_magic_176_15) continue;
            if (OrderSymbol() == Symbol() || OrderMagicNumber() == G_magic_176_15) {
               if (OrderType() == OP_BUY) {
                  Li_16 = NormalizeDouble((Bid - A_price_8) / Point, 0);
                  if (Li_16 < Ai_0) continue;
                  order_stoploss_20 = OrderStopLoss();
                  price_28 = Bid - Ai_4 * Point;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_28 > order_stoploss_20)) OrderModify(OrderTicket(), A_price_8, price_28, OrderTakeProfit(), 0, Aqua);
               }
               if (OrderType() == OP_SELL) {
                  Li_16 = NormalizeDouble((A_price_8 - Ask) / Point, 0);
                  if (Li_16 < Ai_0) continue;
                  order_stoploss_20 = OrderStopLoss();
                  price_28 = Ask + Ai_4 * Point;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_28 < order_stoploss_20)) OrderModify(OrderTicket(), A_price_8, price_28, OrderTakeProfit(), 0, Red);
               }
            }
            Sleep(1000);
         }
      }
   }
}

// 9EB62284E5C15187BCA5B502C66B6C59
double f0_16() {
   if (f0_5() == 0) Gd_712 = AccountEquity();
   if (Gd_712 < Gd_720) Gd_712 = Gd_720;
   else Gd_712 = AccountEquity();
   Gd_720 = AccountEquity();
   return (Gd_712);
}

// F66F194C04A03CB5E74EC2A8C1DD0537
double f0_36() {
   double order_open_price_0;
   int ticket_8;
   double Ld_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() != G_magic_176_15) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15 && OrderType() == OP_BUY) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            Ld_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// C8E1186288BBCE29FD09990000128B35
double f0_28() {
   double order_open_price_0;
   int ticket_8;
   double Ld_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() != G_magic_176_15) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_15 && OrderType() == OP_SELL) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            Ld_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// 6EF0698100DD80AB6B7953B95E5FAD5C
int f0_12() {
   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() != G_magic_176_16) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16)
         if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
   }
   return (count_0);
}

// 065CE9405D7D7C2EAE70F2FF0F5A8147
void f0_0() {
   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() == G_magic_176_16) {
            if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, slip_16, Blue);
            if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, slip_16, Red);
         }
         Sleep(1000);
      }
   }
}

// 25977731C5753DECF295DA11C4378DE5
int f0_6(int Ai_0, double A_lots_4, double A_price_12, int A_slippage_20, double Ad_24, int Ai_32, int Ai_36, string A_comment_40, int A_magic_48, int A_datetime_52, color A_color_56) {
   int ticket_60 = 0;
   int error_64 = 0;
   int count_68 = 0;
   int Li_72 = 100;
   switch (Ai_0) {
   case 2:
      for (count_68 = 0; count_68 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, A_lots_4, A_price_12, A_slippage_20, f0_14(Ad_24, Ai_32), f0_9(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, A_lots_4, A_price_12, A_slippage_20, f0_14(Ad_24, Ai_32), f0_9(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         RefreshRates();
         ticket_60 = OrderSend(Symbol(), OP_BUY, A_lots_4, Ask, A_slippage_20, f0_14(Bid, Ai_32), f0_9(Ask, Ai_36), A_comment_40, A_magic_48, A_datetime_52, A_color_56);
         PlaySound("tortor.wav");
         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 3:
      for (count_68 = 0; count_68 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, A_lots_4, A_price_12, A_slippage_20, f0_23(Ad_24, Ai_32), f0_10(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, A_lots_4, A_price_12, A_slippage_20, f0_23(Ad_24, Ai_32), f0_10(A_price_12, Ai_36), A_comment_40, A_magic_48, A_datetime_52,
            A_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 < Li_72; count_68++) {
         ticket_60 = OrderSend(Symbol(), OP_SELL, A_lots_4, Bid, A_slippage_20, f0_23(Ask, Ai_32), f0_10(Bid, Ai_36), A_comment_40, A_magic_48, A_datetime_52, A_color_56);
         PlaySound("tortor.wav");
         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);
}

// 87D810BEA6B0AD2FCF70C69C17E19362
double f0_14(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 - Ai_8 * Point);
}

// B3477275C69E607F97F2840B12AE4A9F
double f0_23(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 + Ai_8 * Point);
}

// 37FA8C95BB37E55BB52283CC69099A5F
double f0_9(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 + Ai_8 * Point);
}

// 5EF05A0BDFEED3445F4FE51BA1977B3C
double f0_10(double Ad_0, int Ai_8) {
   if (Ai_8 == 0) return (0);
   return (Ad_0 - Ai_8 * Point);
}

// 31C5A9E59B9C6E81AE342B735890CD44
double f0_8() {
   double Ld_ret_0 = 0;
   for (G_pos_960 = OrdersTotal() - 1; G_pos_960 >= 0; G_pos_960--) {
      OrderSelect(G_pos_960, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != G_magic_176_16) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16)
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) Ld_ret_0 += OrderProfit();
   }
   return (Ld_ret_0);
}

// ED2502136334FB187FF67433121886AF
void f0_34(int Ai_0, int Ai_4, double A_price_8) {
   int Li_16;
   double order_stoploss_20;
   double price_28;
   if (Ai_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() != G_magic_176_16) continue;
            if (OrderSymbol() == Symbol() || OrderMagicNumber() == G_magic_176_16) {
               if (OrderType() == OP_BUY) {
                  Li_16 = NormalizeDouble((Bid - A_price_8) / Point, 0);
                  if (Li_16 < Ai_0) continue;
                  order_stoploss_20 = OrderStopLoss();
                  price_28 = Bid - Ai_4 * Point;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_28 > order_stoploss_20)) OrderModify(OrderTicket(), A_price_8, price_28, OrderTakeProfit(), 0, Aqua);
               }
               if (OrderType() == OP_SELL) {
                  Li_16 = NormalizeDouble((A_price_8 - Ask) / Point, 0);
                  if (Li_16 < Ai_0) continue;
                  order_stoploss_20 = OrderStopLoss();
                  price_28 = Ask + Ai_4 * Point;
                  if (order_stoploss_20 == 0.0 || (order_stoploss_20 != 0.0 && price_28 < order_stoploss_20)) OrderModify(OrderTicket(), A_price_8, price_28, OrderTakeProfit(), 0, Red);
               }
            }
            Sleep(1000);
         }
      }
   }
}

// DED4C3E9893A50A6B8A9A57E1BCD0548
double f0_30() {
   if (f0_12() == 0) Gd_996 = AccountEquity();
   if (Gd_996 < Gd_1004) Gd_996 = Gd_1004;
   else Gd_996 = AccountEquity();
   Gd_1004 = AccountEquity();
   return (Gd_996);
}

// 9FC0A73FE3F286FD086830C3094E8AB3
double f0_17() {
   double order_open_price_0;
   int ticket_8;
   double Ld_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() != G_magic_176_16) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16 && OrderType() == OP_BUY) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            Ld_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}

// C55A286500E20535F02887DCF6EFC3C6
double f0_27() {
   double order_open_price_0;
   int ticket_8;
   double Ld_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() != G_magic_176_16) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == G_magic_176_16 && OrderType() == OP_SELL) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            order_open_price_0 = OrderOpenPrice();
            Ld_unused_12 = order_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (order_open_price_0);
}
