/*
   Generated by EX4-TO-MQ4 decompiler V4.0.226.1e [-]
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "FXA Trading Group"
#property link      "http://www.forex-ea.ru"

extern bool Hedging = TRUE;
extern int MaxTrades = 5;
extern bool AutoLots = TRUE;
extern double Lots = 0.01;
extern int risk = 1;
extern bool CheckFreeMargin = TRUE;
extern double TakeProfit = 20.0;
extern double Stoploss = 2000.0;
extern double Dist1 = 85.0;
extern double Dist2 = 85.0;
extern bool TrailSL = TRUE;
extern int TrailPips = 22;
double gd_152;
double gd_160;
double gd_168;
bool gi_176 = TRUE;
bool gi_180 = FALSE;
double gd_184;
double g_ima_192;
double g_ienvelopes_200;
double g_ienvelopes_208;
double g_ienvelopes_216;
double g_ienvelopes_224;
double g_ichimoku_232;
int gi_240 = 1;
bool gi_244 = FALSE;
bool gi_248 = TRUE;
double gd_252 = 1.667;
int g_magic_260;
double g_price_264;
double gd_272;
double gd_unused_280;
double gd_unused_288;
bool gi_unused_296 = FALSE;
double gd_unused_300 = 20.0;
double g_price_308;
double g_bid_316;
double g_ask_324;
double gd_332;
double gd_340;
double gd_348;
double gd_356 = 3.0;
double gd_364;
int gi_372 = 0;
int gi_376 = 0;
bool gi_380;
string gs_gbpusd_384 = "GBPUSD";
int gi_392 = 0;
bool gi_396 = FALSE;
bool gi_400 = FALSE;
bool gi_404 = FALSE;
int gi_unused_408;
int gi_412;
double gd_416;
int g_pos_424 = 0;
int gi_428;
double gd_432 = 0.0;
bool gi_440 = FALSE;
int g_datetime_444 = 0;
int g_datetime_448 = 0;

int init() {
   gd_348 = MarketInfo(Symbol(), MODE_SPREAD) * Point;
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   /*int li_0;
   int li_4;
   int li_8;*/
   bool li_12;
   int timeframe_16;
   double ld_20;
   double ld_28;
   double ld_36;
   double str2dbl_44;
   double str2dbl_52;
   double str2dbl_60;
   string ls_68;
   string ls_76;
   double ld_unused_84;
   double ld_unused_92;
   int li_unused_100;
   int li_104;
   int li_unused_108;
   double ld_112;
   double ord_lots_120;
   double ord_lots_128;
   double iclose_136;
   double iclose_144;
   double ld_152;
   int li_160;
   int li_164;
   if (IsDemo() == TRUE || IsDemo() == FALSE) {
      if (MarketInfo(Symbol(), MODE_LOTSTEP) == 0.1) gd_364 = 1;
      else gd_364 = 2;
      li_12 = TRUE;
      /*li_0 = 29;
      li_4 = 11;
      li_8 = 2010;
      if (Year() < li_8) li_12 = TRUE;
      if (Year() == li_8 && Month() < li_4) li_12 = TRUE;
      if (Year() == li_8 && Month() == li_4 && Day() <= li_0) li_12 = TRUE;*/
      if (li_12 == TRUE) {
         if (Year() > 0 && Month() > 0) {
            gd_184 = Dist1;
            for (int pos_168 = 0; pos_168 <= OrdersTotal() - 1; pos_168++) {
               OrderSelect(pos_168, SELECT_BY_POS, MODE_TRADES);
               if (OrderSymbol() == Symbol() && OrderMagicNumber() == 51400 || OrderMagicNumber() == 51401) {
                  if (OrderType() == OP_BUY)
                     if (OrderOpenPrice() - Bid > Stoploss / 10000.0) OrderClose(OrderTicket(), OrderLots(), Bid, 2, CLR_NONE);
                  if (OrderType() == OP_SELL)
                     if (Ask - OrderOpenPrice() > Stoploss / 10000.0) OrderClose(OrderTicket(), OrderLots(), Ask, 2, CLR_NONE);
               }
            }
            if (TrailSL == TRUE) {
               if (CountTradesB() == 1) {
                  for (int pos_172 = 0; pos_172 <= OrdersTotal() - 1; pos_172++) {
                     OrderSelect(pos_172, SELECT_BY_POS, MODE_TRADES);
                     if (OrderSymbol() == Symbol() && OrderMagicNumber() == 51400 || OrderMagicNumber() == 51402) {
                        if (OrderType() == OP_BUY)
                           if (Bid - OrderOpenPrice() >= TrailPips / 10000.0 && OrderStopLoss() < Bid - TrailPips / 10000.0 - 0.0002) OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailPips / 10000.0 + 0.0002, Bid - TrailPips / 10000.0 + 0.0002 + 0.002, 0, Yellow);
                     }
                  }
               }
               if (CountTradesS() == 1) {
                  for (pos_172 = 0; pos_172 <= OrdersTotal() - 1; pos_172++) {
                     OrderSelect(pos_172, SELECT_BY_POS, MODE_TRADES);
                     if (OrderSymbol() == Symbol() && OrderMagicNumber() == 51402 || OrderMagicNumber() == 51402) {
                        if (OrderType() == OP_SELL)
                           if (OrderOpenPrice() - Ask >= TrailPips / 10000.0 && OrderStopLoss() > Ask + TrailPips / 10000.0 - 0.0002) OrderModify(OrderTicket(), OrderOpenPrice(), Ask + TrailPips / 10000.0 - 0.0002, Ask + TrailPips / 10000.0 - 0.0002 - 0.002, 0, Yellow);
                     }
                  }
               }
            }
            timeframe_16 = Period();
            if (Hedging == TRUE) {
               if (gi_176 == TRUE) g_magic_260 = 51401;
               else g_magic_260 = 12378;
               if (timeframe_16 == PERIOD_H4 && StringSubstr(Symbol(), 0, 6) == "GBPUSD") {
                  if (ld_20 == ld_28) {
                     ls_76 = "FXA Trading Group www.forex-ea.org";
                     ls_76 = ls_76 
                     + "\nBroker: " + AccountCompany();
                     if (IsDemo() == TRUE) {
                        ls_76 = ls_76 
                        + "\nDemo Account: " + AccountNumber();
                     } else {
                        ls_76 = ls_76 
                        + "\nReal Account: " + AccountNumber();
                     }
                     gi_unused_408 = 0;
                     if (gi_176 == TRUE) {
                        gi_440 = FALSE;
                        if (AccountLeverage() <= 500) {
                           gd_152 = AccountFreeMargin() / 500.0;
                           gd_160 = MarketInfo(Symbol(), MODE_MARGINREQUIRED) * MarketInfo(Symbol(), MODE_MINLOT);
                           if (AutoLots == TRUE) {
                              Lots = 0;
                              gd_168 = MathFloor(AccountFreeMargin() / (500.0 * gd_160)) * MarketInfo(Symbol(), MODE_MINLOT);
                              if (gd_168 < MarketInfo(Symbol(), MODE_MINLOT)) Lots = MarketInfo(Symbol(), MODE_MINLOT);
                              else Lots = gd_168;
                           }
                           if (gd_160 <= gd_152) gi_unused_408 = 1;
                           else {
                              li_104 = 500.0 * gd_160;
                              ls_76 = ls_76 
                              + "\nFree Margin should be around: " + li_104 + " [atleast]";
                           }
                        } else {
                           Lots = 0;
                           Alert("Account Leverage should be 500 or LESS\nYour Account Leverage is: ", AccountLeverage());
                        }
                     }
                     li_unused_108 = TakeProfit;
                     Comment(ls_76);
                     if (gi_372 == Time[0]) return (0);
                     gi_372 = Time[0];
                     ld_112 = CalculateProfit();
                     gi_428 = CountTrades();
                     if (gi_428 == 0) gi_380 = FALSE;
                     for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                        OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                        if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                        if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                           if (OrderType() == OP_BUY) {
                              gi_400 = TRUE;
                              gi_404 = FALSE;
                              ord_lots_120 = OrderLots();
                              break;
                           }
                        }
                        if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                           if (OrderType() == OP_SELL) {
                              gi_400 = FALSE;
                              gi_404 = TRUE;
                              ord_lots_128 = OrderLots();
                              break;
                           }
                        }
                     }
                     if (gi_428 > 0 && gi_428 <= MaxTrades) {
                        RefreshRates();
                        if (gi_428 == 1) gd_184 = Dist2;
                        if (gi_428 > 0) gd_184 = Dist2;
                        if (gi_428 > 1) gd_184 = Dist2;
                        gd_332 = LastBuyPrice();
                        gd_340 = LastSellPrice();
                        if (gi_180 != FALSE) gd_184 = 2.5 * (Dist1 * gi_428);
                        if (gi_400 && gd_332 - Ask >= gd_184 / 10000.0) gi_396 = TRUE;
                        if (gi_404 && Bid - gd_340 >= gd_184 / 10000.0) gi_396 = TRUE;
                     }
                     if (gi_428 < 1) {
                        gi_404 = FALSE;
                        gi_400 = FALSE;
                        gi_396 = TRUE;
                        gd_272 = AccountEquity();
                     }
                     if (gi_396) {
                        gd_332 = LastBuyPrice();
                        gd_340 = LastSellPrice();
                        if (gi_404) {
                           if (gi_244) {
                              fOrderCloseMarket(0, 1);
                              gd_416 = NormalizeDouble(gd_252 * ord_lots_128, gd_364);
                           } else gd_416 = fGetLots(OP_SELL);
                           if (gi_248) {
                              gi_392 = gi_428;
                              if (gd_416 > 0.0) {
                                 RefreshRates();
                                 if (gi_412 < 0) {
                                    Print("Error: ", GetLastError());
                                    return (0);
                                 }
                                 gd_340 = LastSellPrice();
                                 gi_396 = FALSE;
                                 gi_440 = TRUE;
                              }
                           }
                        } else {
                           if (gi_400) {
                              if (gi_244) {
                                 fOrderCloseMarket(1, 0);
                                 gd_416 = NormalizeDouble(gd_252 * ord_lots_120, gd_364);
                              } else gd_416 = fGetLots(OP_BUY);
                              if (gi_248) {
                                 gi_392 = gi_428;
                                 if (gd_416 > 0.0) {
                                    gi_412 = OpenPendingOrder(0, gd_416, Ask, gd_356, Bid, 0, 0, gs_gbpusd_384 + "-" + gi_392, g_magic_260, 0, Lime);
                                    if (gi_412 < 0) {
                                       Print("Error: ", GetLastError());
                                       return (0);
                                    }
                                    gd_332 = LastBuyPrice();
                                    gi_396 = FALSE;
                                    gi_440 = TRUE;
                                 }
                              }
                           }
                        }
                     }
                     if (gi_396 && gi_428 < 1) {
                        iclose_136 = iClose(Symbol(), 0, 2);
                        iclose_144 = iClose(Symbol(), 0, 1);
                        g_bid_316 = Bid;
                        g_ask_324 = Ask;
                        if ((!gi_404) && !gi_400) {
                           gi_392 = gi_428;
                           if (iclose_136 > iclose_144) {
                              gd_416 = fGetLots(OP_SELL);
                              if (gd_416 > 0.0) {
                                 if (gi_412 < 0) {
                                    Print(gd_416, "Error: ", GetLastError());
                                    return (0);
                                 }
                                 gd_332 = LastBuyPrice();
                                 gi_440 = TRUE;
                              }
                           } else {
                              gd_416 = fGetLots(OP_BUY);
                              if (gd_416 > 0.0) {
                                 gi_412 = OpenPendingOrder(0, gd_416, g_ask_324, gd_356, g_ask_324, 0, 0, gs_gbpusd_384 + "-" + gi_392, g_magic_260, 0, Lime);
                                 if (gi_412 < 0) {
                                    Print(gd_416, "Error: ", GetLastError());
                                    return (0);
                                 }
                                 gd_340 = LastSellPrice();
                                 gi_440 = TRUE;
                              }
                           }
                        }
                        gi_396 = FALSE;
                     }
                     gi_428 = CountTrades();
                     g_price_308 = 0;
                     ld_152 = 0;
                     for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                        OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                        if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                        if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                           if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
                              g_price_308 += OrderOpenPrice() * OrderLots();
                              ld_152 += OrderLots();
                           }
                        }
                     }
                     if (gi_428 > 0) g_price_308 = NormalizeDouble(g_price_308 / ld_152, Digits);
                     if (gi_440) {
                        for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                           OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                           if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                           if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                              if (OrderType() == OP_BUY) {
                                 g_price_264 = g_price_308 + TakeProfit / 10000.0;
                                 gd_unused_280 = g_price_264;
                                 gd_432 = g_price_308 - Stoploss * Point;
                                 gi_380 = TRUE;
                              }
                           }
                           if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                              if (OrderType() == OP_SELL) {
                                 g_price_264 = g_price_308 - TakeProfit / 10000.0;
                                 gd_unused_288 = g_price_264;
                                 gd_432 = g_price_308 + Stoploss * Point;
                                 gi_380 = TRUE;
                              }
                           }
                        }
                     }
                     if (gi_440) {
                        if (gi_380 == TRUE) {
                           for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                              OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                              if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                              if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                                 if (OrderStopLoss() > 0.0) OrderModify(OrderTicket(), g_price_308, OrderStopLoss(), g_price_264, 0, Yellow);
                                 else OrderModify(OrderTicket(), g_price_308, OrderOpenPrice() - Stoploss / 10000.0, g_price_264, 0, Yellow);
                              }
                              gi_440 = FALSE;
                           }
                        }
                     }
                  } else Alert("Please Activate your copy\nof FXA Trading Group www.forex-ea.org");
               } else {
                  Alert("Works only on GBPUSD 4 Hour Chart", 
                  "\nbut You are trying to use it on ", Symbol(), " ", Period());
               }
               if (gi_176 == TRUE) {
                  gi_396 = FALSE;
                  g_magic_260 = 51402;
               } else g_magic_260 = 12378;
               if (timeframe_16 == PERIOD_H4 && StringSubstr(Symbol(), 0, 6) == "GBPUSD") {
                  ld_20 = 0;
                  ld_28 = 0;
                  ld_36 = 0;
                  str2dbl_44 = 0;
                  str2dbl_52 = 0;
                  str2dbl_60 = 0;
                  if (ld_20 == ld_28) {
                     ls_76 = "FXA Trading Group www.forex-ea.org";
                     ls_76 = ls_76 
                     + "\nBroker: " + AccountCompany();
                     if (IsDemo() == TRUE) {
                        ls_76 = ls_76 
                        + "\nDemo Account: " + AccountNumber();
                     } else {
                        ls_76 = ls_76 
                        + "\nReal Account: " + AccountNumber();
                     }
                     gi_unused_408 = 0;
                     ld_unused_84 = 0;
                     ld_unused_92 = 0;
                     li_unused_100 = 0;
                     if (gi_176 == TRUE) {
                        gi_440 = FALSE;
                        if (AccountLeverage() <= 500) {
                           gd_152 = AccountFreeMargin() / 500.0;
                           gd_160 = MarketInfo(Symbol(), MODE_MARGINREQUIRED) * MarketInfo(Symbol(), MODE_MINLOT);
                           if (AutoLots == TRUE) {
                              Lots = 0;
                              gd_168 = MathFloor(AccountFreeMargin() / (1000.0 * gd_160)) * MarketInfo(Symbol(), MODE_MINLOT);
                              if (gd_168 < MarketInfo(Symbol(), MODE_MINLOT)) Lots = MarketInfo(Symbol(), MODE_MINLOT);
                              else Lots = gd_168;
                           }
                           if (gd_160 <= gd_152) gi_unused_408 = 1;
                           else {
                              li_160 = 500.0 * gd_160;
                              ls_76 = ls_76 
                              + "\nFree Margin should be around: " + li_160 + " [atleast]";
                           }
                        } else {
                           Lots = 0;
                           Alert("Account Leverage should be 500 or LESS\nYour Account Leverage is: ", AccountLeverage());
                        }
                     }
                     li_unused_108 = TakeProfit;
                     Comment(ls_76);
                     if (gi_376 == Time[0]) return (0);
                     gi_376 = Time[0];
                     ld_112 = CalculateProfit();
                     gi_428 = CountTrades();
                     if (gi_428 == 0) gi_380 = FALSE;
                     ord_lots_120 = 0;
                     ord_lots_128 = 0;
                     for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                        OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                        if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                        if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                           if (OrderType() == OP_BUY) {
                              gi_400 = TRUE;
                              gi_404 = FALSE;
                              ord_lots_120 = OrderLots();
                              break;
                           }
                        }
                        if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                           if (OrderType() == OP_SELL) {
                              gi_400 = FALSE;
                              gi_404 = TRUE;
                              ord_lots_128 = OrderLots();
                              break;
                           }
                        }
                     }
                     if (gi_428 > 0 && gi_428 <= MaxTrades) {
                        RefreshRates();
                        if (gi_428 == 1) gd_184 = Dist2;
                        if (gi_428 > 0) gd_184 = Dist2;
                        if (gi_428 > 1) gd_184 = Dist2;
                        gd_332 = LastBuyPrice();
                        gd_340 = LastSellPrice();
                        if (gi_180 != FALSE) gd_184 = 2.5 * (Dist1 * gi_428);
                        if (gi_400 && gd_332 - Ask >= gd_184 / 10000.0) gi_396 = TRUE;
                        if (gi_404 && Bid - gd_340 >= gd_184 / 10000.0) gi_396 = TRUE;
                     }
                     if (gi_428 < 1) {
                        gi_404 = FALSE;
                        gi_400 = FALSE;
                        gi_396 = TRUE;
                        gd_272 = AccountEquity();
                     }
                     if (gi_396) {
                        gd_332 = LastBuyPrice();
                        gd_340 = LastSellPrice();
                        if (gi_404) {
                           if (gi_244) {
                              fOrderCloseMarket(0, 1);
                              gd_416 = NormalizeDouble(gd_252 * ord_lots_128, gd_364);
                           } else gd_416 = fGetLots(OP_SELL);
                           if (gi_248) {
                              gi_392 = gi_428;
                              if (gd_416 > 0.0) {
                                 RefreshRates();
                                 gi_412 = OpenPendingOrder(1, gd_416, Bid, gd_356, Ask, 0, 0, gs_gbpusd_384 + "-" + gi_392, g_magic_260, 0, HotPink);
                                 if (gi_412 < 0) {
                                    Print("Error: ", GetLastError());
                                    return (0);
                                 }
                                 gd_340 = LastSellPrice();
                                 gi_396 = FALSE;
                                 gi_440 = TRUE;
                              }
                           }
                        } else {
                           if (gi_400) {
                              if (gi_244) {
                                 fOrderCloseMarket(1, 0);
                                 gd_416 = NormalizeDouble(gd_252 * ord_lots_120, gd_364);
                              } else gd_416 = fGetLots(OP_BUY);
                              if (gi_248) {
                                 gi_392 = gi_428;
                                 if (gd_416 > 0.0) {
                                    if (gi_412 < 0) {
                                       Print("Error: ", GetLastError());
                                       return (0);
                                    }
                                    gd_332 = LastBuyPrice();
                                    gi_396 = FALSE;
                                    gi_440 = TRUE;
                                 }
                              }
                           }
                        }
                     }
                     if (gi_396 && gi_428 < 1) {
                        iclose_136 = iClose(Symbol(), 0, 2);
                        iclose_144 = iClose(Symbol(), 0, 1);
                        g_bid_316 = Bid;
                        g_ask_324 = Ask;
                        if ((!gi_404) && !gi_400) {
                           gi_392 = gi_428;
                           if (iclose_136 > iclose_144) {
                              gd_416 = fGetLots(OP_SELL);
                              if (gd_416 > 0.0) {
                                 gi_412 = OpenPendingOrder(1, gd_416, g_bid_316, gd_356, g_bid_316, 0, 0, gs_gbpusd_384 + "-" + gi_392, g_magic_260, 0, HotPink);
                                 if (gi_412 < 0) {
                                    Print(gd_416, "Error: ", GetLastError());
                                    return (0);
                                 }
                                 gd_332 = LastBuyPrice();
                                 gi_440 = TRUE;
                              }
                           } else {
                              gd_416 = fGetLots(OP_BUY);
                              if (gd_416 > 0.0) {
                                 if (gi_412 < 0) {
                                    Print(gd_416, "Error: ", GetLastError());
                                    return (0);
                                 }
                                 gd_340 = LastSellPrice();
                                 gi_440 = TRUE;
                              }
                           }
                        }
                        gi_396 = FALSE;
                     }
                     gi_428 = CountTrades();
                     g_price_308 = 0;
                     ld_152 = 0;
                     for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                        OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                        if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                        if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                           if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
                              g_price_308 += OrderOpenPrice() * OrderLots();
                              ld_152 += OrderLots();
                           }
                        }
                     }
                     if (gi_428 > 0) g_price_308 = NormalizeDouble(g_price_308 / ld_152, Digits);
                     if (gi_440) {
                        for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                           OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                           if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                           if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                              if (OrderType() == OP_BUY) {
                                 g_price_264 = g_price_308 + TakeProfit / 10000.0;
                                 gd_unused_280 = g_price_264;
                                 gd_432 = g_price_308 - Stoploss * Point;
                                 gi_380 = TRUE;
                              }
                           }
                           if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                              if (OrderType() == OP_SELL) {
                                 g_price_264 = g_price_308 - TakeProfit / 10000.0;
                                 gd_unused_288 = g_price_264;
                                 gd_432 = g_price_308 + Stoploss * Point;
                                 gi_380 = TRUE;
                              }
                           }
                        }
                     }
                     if (gi_440) {
                        if (gi_380 == TRUE) {
                           for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                              OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                              if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                              if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                                 if (OrderStopLoss() > 0.0) OrderModify(OrderTicket(), g_price_308, OrderStopLoss(), g_price_264, 0, Yellow);
                                 else OrderModify(OrderTicket(), g_price_308, OrderOpenPrice() + Stoploss / 10000.0, g_price_264, 0, Yellow);
                              }
                              gi_440 = FALSE;
                           }
                        }
                     }
                  } else Alert("Please Activate your copy\nof FXA Trading Group www.forex-ea.org");
               } else {
                  Alert("Works only on GBPUSD 4 Hour Chart", 
                  "\nbut You are trying to use it on ", Symbol(), " ", Period());
               }
            } else {
               if (gi_176 == TRUE) {
                  gi_396 = FALSE;
                  g_magic_260 = 51402;
               } else g_magic_260 = 12378;
               if (timeframe_16 == PERIOD_H4 && StringSubstr(Symbol(), 0, 6) == "GBPUSD") {
                  ld_20 = 0;
                  ld_28 = 0;
                  ld_36 = 0;
                  str2dbl_44 = 0;
                  str2dbl_52 = 0;
                  str2dbl_60 = 0;
                  if (IsDemo() == TRUE) {
                     ls_68 = AccountNumber();
                     ld_36 = StringLen(ls_68);
                     str2dbl_44 = StrToDouble(StringSubstr(ls_68, 0, 1));
                     str2dbl_52 = StrToDouble(StringSubstr(ls_68, 1, 1));
                     str2dbl_60 = StrToDouble(StringSubstr(ls_68, ld_36 - 1.0, 1));
                     ld_28 = AccountNumber() + 739;
                     ld_28 = ld_28 + 189.0 * str2dbl_44 + 204.0 * str2dbl_52 + 118.0 * str2dbl_60;
                  } else {
                     ls_68 = AccountNumber();
                     ld_36 = StringLen(ls_68);
                     str2dbl_44 = StrToDouble(StringSubstr(ls_68, 0, 1));
                     str2dbl_52 = StrToDouble(StringSubstr(ls_68, 1, 1));
                     str2dbl_60 = StrToDouble(StringSubstr(ls_68, ld_36 - 1.0, 1));
                     ld_28 = AccountNumber() + 839;
                     ld_28 = ld_28 + 176.0 * str2dbl_44 + 298.0 * str2dbl_52 + 328.0 * str2dbl_60;
                  }
                  if (ld_20 == ld_28) {
                     ls_76 = "FXA Trading Group www.forex-ea.org";
                     ls_76 = ls_76 
                     + "\nBroker: " + AccountCompany();
                     if (IsDemo() == TRUE) {
                        ls_76 = ls_76 
                        + "\nDemo Account: " + AccountNumber();
                     } else {
                        ls_76 = ls_76 
                        + "\nReal Account: " + AccountNumber();
                     }
                     gi_unused_408 = 0;
                     ld_unused_84 = 0;
                     ld_unused_92 = 0;
                     li_unused_100 = 0;
                     if (gi_176 == TRUE) {
                        gi_440 = FALSE;
                        if (AccountLeverage() <= 500) {
                           gd_152 = AccountFreeMargin() / 500.0;
                           gd_160 = MarketInfo(Symbol(), MODE_MARGINREQUIRED) * MarketInfo(Symbol(), MODE_MINLOT);
                           if (AutoLots == TRUE) {
                              Lots = 0;
                              gd_168 = MathFloor(AccountFreeMargin() / (500.0 * gd_160)) * MarketInfo(Symbol(), MODE_MINLOT);
                              if (gd_168 < MarketInfo(Symbol(), MODE_MINLOT)) Lots = MarketInfo(Symbol(), MODE_MINLOT);
                              else Lots = gd_168;
                           }
                           if (gd_160 <= gd_152) gi_unused_408 = 1;
                           else {
                              li_164 = 500.0 * gd_160;
                              ls_76 = ls_76 
                              + "\nFree Margin should be around: " + li_164 + " [atleast]";
                           }
                        } else {
                           Lots = 0;
                           Alert("Account Leverage should be 100 or LESS\nYour Account Leverage is: ", AccountLeverage());
                        }
                     }
                     li_unused_108 = TakeProfit;
                     Comment(ls_76);
                     if (gi_376 == Time[0]) return (0);
                     gi_376 = Time[0];
                     ld_112 = CalculateProfit();
                     gi_428 = CountTrades();
                     if (gi_428 == 0) gi_380 = FALSE;
                     ord_lots_120 = 0;
                     ord_lots_128 = 0;
                     for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                        OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                        if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                        if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                           if (OrderType() == OP_BUY) {
                              gi_400 = TRUE;
                              gi_404 = FALSE;
                              ord_lots_120 = OrderLots();
                              break;
                           }
                        }
                        if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                           if (OrderType() == OP_SELL) {
                              gi_400 = FALSE;
                              gi_404 = TRUE;
                              ord_lots_128 = OrderLots();
                              break;
                           }
                        }
                     }
                     if (gi_428 > 0 && gi_428 <= MaxTrades) {
                        RefreshRates();
                        if (gi_428 == 1) gd_184 = Dist2;
                        if (gi_428 > 0) gd_184 = Dist2;
                        if (gi_428 > 1) gd_184 = Dist2;
                        gd_332 = LastBuyPrice();
                        gd_340 = LastSellPrice();
                        if (gi_180 != FALSE) gd_184 = 2.5 * (Dist1 * gi_428);
                        if (gi_400 && gd_332 - Ask >= gd_184 / 10000.0) gi_396 = TRUE;
                        if (gi_404 && Bid - gd_340 >= gd_184 / 10000.0) gi_396 = TRUE;
                     }
                     if (gi_428 < 1) {
                        gi_404 = FALSE;
                        gi_400 = FALSE;
                        gi_396 = TRUE;
                        gd_272 = AccountEquity();
                     }
                     if (gi_396) {
                        gd_332 = LastBuyPrice();
                        gd_340 = LastSellPrice();
                        if (gi_404) {
                           if (gi_244) {
                              fOrderCloseMarket(0, 1);
                              gd_416 = NormalizeDouble(gd_252 * ord_lots_128, gd_364);
                           } else gd_416 = fGetLots(OP_SELL);
                           if (gi_248) {
                              gi_392 = gi_428;
                              if (gd_416 > 0.0) {
                                 RefreshRates();
                                 gi_412 = OpenPendingOrder(1, gd_416, Bid, gd_356, Ask, 0, 0, gs_gbpusd_384 + "-" + gi_392, g_magic_260, 0, HotPink);
                                 if (gi_412 < 0) {
                                    Print("Error: ", GetLastError());
                                    return (0);
                                 }
                                 gd_340 = LastSellPrice();
                                 gi_396 = FALSE;
                                 gi_440 = TRUE;
                              }
                           }
                        } else {
                           if (gi_400) {
                              if (gi_244) {
                                 fOrderCloseMarket(1, 0);
                                 gd_416 = NormalizeDouble(gd_252 * ord_lots_120, gd_364);
                              } else gd_416 = fGetLots(OP_BUY);
                              if (gi_248) {
                                 gi_392 = gi_428;
                                 if (gd_416 > 0.0) {
                                    gi_412 = OpenPendingOrder(0, gd_416, Ask, gd_356, Bid, 0, 0, gs_gbpusd_384 + "-" + gi_392, g_magic_260, 0, Lime);
                                    if (gi_412 < 0) {
                                       Print("Error: ", GetLastError());
                                       return (0);
                                    }
                                    gd_332 = LastBuyPrice();
                                    gi_396 = FALSE;
                                    gi_440 = TRUE;
                                 }
                              }
                           }
                        }
                     }
                     if (gi_396 && gi_428 < 1) {
                        iclose_136 = iClose(Symbol(), 0, 2);
                        iclose_144 = iClose(Symbol(), 0, 1);
                        g_bid_316 = Bid;
                        g_ask_324 = Ask;
                        if ((!gi_404) && !gi_400) {
                           gi_392 = gi_428;
                           if (iclose_136 > iclose_144) {
                              gd_416 = fGetLots(OP_SELL);
                              if (gd_416 > 0.0) {
                                 gi_412 = OpenPendingOrder(1, gd_416, g_bid_316, gd_356, g_bid_316, 0, 0, gs_gbpusd_384 + "-" + gi_392, g_magic_260, 0, HotPink);
                                 if (gi_412 < 0) {
                                    Print(gd_416, "Error: ", GetLastError());
                                    return (0);
                                 }
                                 gd_332 = LastBuyPrice();
                                 gi_440 = TRUE;
                              }
                           } else {
                              gd_416 = fGetLots(OP_BUY);
                              if (gd_416 > 0.0) {
                                 gi_412 = OpenPendingOrder(0, gd_416, g_ask_324, gd_356, g_ask_324, 0, 0, gs_gbpusd_384 + "-" + gi_392, g_magic_260, 0, Lime);
                                 if (gi_412 < 0) {
                                    Print(gd_416, "Error: ", GetLastError());
                                    return (0);
                                 }
                                 gd_340 = LastSellPrice();
                                 gi_440 = TRUE;
                              }
                           }
                        }
                        gi_396 = FALSE;
                     }
                     gi_428 = CountTrades();
                     g_price_308 = 0;
                     ld_152 = 0;
                     for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                        OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                        if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                        if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                           if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
                              g_price_308 += OrderOpenPrice() * OrderLots();
                              ld_152 += OrderLots();
                           }
                        }
                     }
                     if (gi_428 > 0) g_price_308 = NormalizeDouble(g_price_308 / ld_152, Digits);
                     if (gi_440) {
                        for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                           OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                           if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                           if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                              if (OrderType() == OP_BUY) {
                                 g_price_264 = g_price_308 + TakeProfit / 10000.0;
                                 gd_unused_280 = g_price_264;
                                 gd_432 = g_price_308 - Stoploss * Point;
                                 gi_380 = TRUE;
                              }
                           }
                           if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                              if (OrderType() == OP_SELL) {
                                 g_price_264 = g_price_308 - TakeProfit / 10000.0;
                                 gd_unused_288 = g_price_264;
                                 gd_432 = g_price_308 + Stoploss * Point;
                                 gi_380 = TRUE;
                              }
                           }
                        }
                     }
                     if (gi_440) {
                        if (gi_380 == TRUE) {
                           for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
                              OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
                              if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
                              if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
                                 if (OrderStopLoss() > 0.0) OrderModify(OrderTicket(), g_price_308, OrderStopLoss(), g_price_264, 0, Yellow);
                                 else {
                                    if (OrderType() == OP_SELL) OrderModify(OrderTicket(), g_price_308, OrderOpenPrice() + Stoploss / 10000.0, g_price_264, 0, Yellow);
                                    else
                                       if (OrderType() == OP_BUY) OrderModify(OrderTicket(), g_price_308, OrderOpenPrice() - Stoploss / 10000.0, g_price_264, 0, Yellow);
                                 }
                              }
                              gi_440 = FALSE;
                           }
                        }
                     }
                  } else Alert("Please Activate your copy\nof FXA Trading Group www.forex-ea.org");
               } else {
                  Alert("Works only on GBPUSD 4 Hour Chart", 
                  "\nbut You are trying to use it on ", Symbol(), " ", Period());
               }
            }
         }
      } else Alert("License Expired");
   } else Alert("BUY! to run on Real Account");
   return (0);
}

double ND(double ad_0) {
   return (NormalizeDouble(ad_0, Digits));
}

int fOrderCloseMarket(bool ai_0 = TRUE, bool ai_4 = TRUE) {
   int li_ret_8 = 0;
   for (int pos_12 = OrdersTotal() - 1; pos_12 >= 0; pos_12--) {
      if (OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
            if (OrderType() == OP_BUY && ai_0) {
               RefreshRates();
               if (!IsTradeContextBusy()) {
                  if (!OrderClose(OrderTicket(), OrderLots(), ND(Bid), 5, CLR_NONE)) {
                     Print("Error close BUY " + OrderTicket());
                     li_ret_8 = -1;
                  }
               } else {
                  if (g_datetime_444 != iTime(NULL, 0, 0)) {
                     g_datetime_444 = iTime(NULL, 0, 0);
                     Print("Need close BUY " + OrderTicket() + ". Trade Context Busy");
                  }
                  return (-2);
               }
            }
            if (OrderType() == OP_SELL && ai_4) {
               RefreshRates();
               if (!IsTradeContextBusy()) {
                  if (!(!OrderClose(OrderTicket(), OrderLots(), ND(Ask), 5, CLR_NONE))) continue;
                  Print("Error close SELL " + OrderTicket());
                  li_ret_8 = -1;
                  continue;
               }
               if (g_datetime_448 != iTime(NULL, 0, 0)) {
                  g_datetime_448 = iTime(NULL, 0, 0);
                  Print("Need close SELL " + OrderTicket() + ". Trade Context Busy");
               }
               return (-2);
            }
         }
      }
   }
   return (li_ret_8);
}

double fGetLots(int a_cmd_0) {
   double ld_ret_4;
   int datetime_12;
   switch (gi_240) {
   case 0:
      ld_ret_4 = Lots * risk;
      break;
   case 1:
      ld_ret_4 = NormalizeDouble(Lots * risk * MathPow(gd_252, CountTrades()), gd_364);
      break;
   case 2:
      datetime_12 = 0;
      ld_ret_4 = Lots * risk;
      for (int pos_20 = OrdersHistoryTotal() - 1; pos_20 >= 0; pos_20--) {
         if (OrderSelect(pos_20, SELECT_BY_POS, MODE_HISTORY)) {
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260) {
               if (datetime_12 < OrderCloseTime()) {
                  datetime_12 = OrderCloseTime();
                  if (OrderProfit() < 0.0) {
                     ld_ret_4 = NormalizeDouble(OrderLots() * gd_252, gd_364);
                     continue;
                  }
                  ld_ret_4 = Lots * risk;
               }
            }
         } else return (-3);
      }
   }
   if (AccountFreeMarginCheck(Symbol(), a_cmd_0, ld_ret_4) <= 0.0) return (-1);
   if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) return (-2);
   return (ld_ret_4);
}

int CountTrades() {
   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_260) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260)
         if (OrderType() == OP_SELL || OrderType() == OP_BUY) count_0++;
   }
   return (count_0);
}

int CountTradesB() {
   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() == 51401 || OrderMagicNumber() == 51402)
         if (OrderType() == OP_BUY) count_0++;
   }
   return (count_0);
}

int CountTradesS() {
   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() == 51401 || OrderMagicNumber() == 51402)
         if (OrderType() == OP_SELL) count_0++;
   }
   return (count_0);
}

int OpenPendingOrder(int ai_0, double a_lots_4, double ad_unused_12, int a_slippage_20, double ad_unused_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;
   double istochastic_76 = iStochastic(NULL, PERIOD_H4, 14, 6, 7, MODE_EMA, 0, MODE_MAIN, 0);
   double istochastic_84 = iStochastic(NULL, PERIOD_H4, 14, 6, 7, MODE_EMA, 0, MODE_SIGNAL, 0);
   switch (ai_0) {
   case 0:
      for (count_68 = 0; count_68 < li_72; count_68++) {
         RefreshRates();
         g_ichimoku_232 = iIchimoku(Symbol(), 0, 9, 26, 52, MODE_TENKANSEN, 0);
         g_ima_192 = iMA(Symbol(), 0, 1, 0, MODE_SMA, PRICE_CLOSE, 0);
         g_ienvelopes_208 = iEnvelopes(Symbol(), 0, 99, MODE_EMA, 0, PRICE_CLOSE, 0.03, MODE_LOWER, 1);
         g_ienvelopes_208 = iEnvelopes(Symbol(), 0, 99, MODE_EMA, 0, PRICE_CLOSE, 0.05, MODE_LOWER, 1);
         if (istochastic_76 < 30.0 && istochastic_76 > istochastic_84) {
            if (CountTrades() == 2) {
               g_ienvelopes_224 = iEnvelopes(Symbol(), 0, 99, MODE_EMA, 0, PRICE_CLOSE, 0.15, MODE_LOWER, 1);
               if (Ask < g_ienvelopes_224) {
                  ticket_60 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, a_slippage_20, StopLong(Bid, ai_32), TakeLong(Ask, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
                  break;
               }
            }
            if (CountTrades() == 3) {
               g_ienvelopes_224 = iEnvelopes(Symbol(), 0, 99, MODE_EMA, 0, PRICE_CLOSE, 0.2, MODE_LOWER, 1);
               if (Ask < g_ienvelopes_224) {
                  ticket_60 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, a_slippage_20, StopLong(Bid, ai_32), TakeLong(Ask, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
                  break;
               }
            }
            if (CountTrades() > 3) {
               g_ienvelopes_224 = iEnvelopes(Symbol(), 0, 99, MODE_EMA, 0, PRICE_CLOSE, 0.2, MODE_LOWER, 1);
               if (Ask < g_ienvelopes_224) {
                  ticket_60 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, a_slippage_20, StopLong(Bid, ai_32), TakeLong(Ask, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
                  break;
               }
            }
         }
         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++) {
         RefreshRates();
         g_ienvelopes_200 = iEnvelopes(Symbol(), 0, 99, MODE_EMA, 0, PRICE_CLOSE, 0.05, MODE_UPPER, 1);
         if (istochastic_76 > 70.0 && istochastic_76 < istochastic_84) {
            if (CountTrades() == 2) {
               g_ienvelopes_216 = iEnvelopes(Symbol(), 0, 99, MODE_EMA, 0, PRICE_CLOSE, 0.2, MODE_UPPER, 1);
               if (Bid > g_ienvelopes_216) {
                  if (High[0] < High[1] && High[1] < High[2] && High[2] < High[3] && Open[0] < Open[1] && Open[1] < Open[2] && Open[2] < Open[3]) {
                     ticket_60 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, a_slippage_20, StopShort(Ask, ai_32), TakeShort(Bid, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
                     break;
                  }
               }
            }
            if (CountTrades() == 3) {
               g_ienvelopes_216 = iEnvelopes(Symbol(), 0, 99, MODE_EMA, 0, PRICE_CLOSE, 0.2, MODE_UPPER, 1);
               if (Bid > g_ienvelopes_216) {
                  if (High[0] < High[1] && High[1] < High[2] && High[2] < High[3] && Open[0] < Open[1] && Open[1] < Open[2] && Open[2] < Open[3]) {
                     ticket_60 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, a_slippage_20, StopShort(Ask, ai_32), TakeShort(Bid, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
                     break;
                  }
               }
            }
            if (CountTrades() > 3) {
               g_ienvelopes_216 = iEnvelopes(Symbol(), 0, 99, MODE_EMA, 0, PRICE_CLOSE, 0.2, MODE_UPPER, 1);
               if (Bid > g_ienvelopes_216) {
                  if (High[0] < High[1] && High[1] < High[2] && High[2] < High[3] && Open[0] < Open[1] && Open[1] < Open[2] && Open[2] < Open[3]) {
                     ticket_60 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, a_slippage_20, StopShort(Ask, ai_32), TakeShort(Bid, ai_36), a_comment_40, a_magic_48, a_datetime_52, a_color_56);
                     break;
                  }
               }
            }
         }
         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);
}

double StopLong(double ad_0, int ai_8) {
   if (ai_8 == 0) return (0);
   return (ad_0 - ai_8 * Point);
}

double StopShort(double ad_0, int ai_8) {
   if (ai_8 == 0) return (0);
   return (ad_0 + ai_8 * Point);
}

double TakeLong(double ad_0, int ai_8) {
   if (ai_8 == 0) return (0);
   return (ad_0 + ai_8 * Point);
}

double TakeShort(double ad_0, int ai_8) {
   if (ai_8 == 0) return (0);
   return (ad_0 - ai_8 * Point);
}

double CalculateProfit() {
   double ld_ret_0 = 0;
   for (g_pos_424 = OrdersTotal() - 1; g_pos_424 >= 0; g_pos_424--) {
      OrderSelect(g_pos_424, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() != Symbol() || OrderMagicNumber() != g_magic_260) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260)
         if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_0 += OrderProfit();
   }
   return (ld_ret_0);
}

double LastBuyPrice() {
   double ord_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_260) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260 && OrderType() == OP_BUY) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            ord_open_price_0 = OrderOpenPrice();
            ld_unused_12 = ord_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (ord_open_price_0);
}

double LastSellPrice() {
   double ord_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_260) continue;
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_260 && OrderType() == OP_SELL) {
         ticket_8 = OrderTicket();
         if (ticket_8 > ticket_20) {
            ord_open_price_0 = OrderOpenPrice();
            ld_unused_12 = ord_open_price_0;
            ticket_20 = ticket_8;
         }
      }
   }
   return (ord_open_price_0);
}