#property copyright "Copyright © 2013, Forex Overdrive Team"
#property link      "http://www.forexoverdrive.com H1"

extern string Product_Name = "Forex Overdrive";
extern string Creator = "Copyright © 2013, Forex Overdrive Team";
extern int MagicNo = 567;
bool gi_96 = FALSE;
extern bool MM = TRUE;
extern double RiskPercent = 15.0;
extern double LotSize = 0.1;
extern double Max_Lot_Size = 100.0;
extern int MaxOrder = 1;
double gd_132 = 0.0;
extern double TakeProfit = 25.0;
extern double StopLoss = 328.0;
double gslippage_156 = 3.0;
extern double TrailingStop = 15.0;
bool gi_unused_172 = TRUE;
int gi_176 = 5;
bool gi_180 = FALSE;
bool gi_184 = FALSE;
double gd_188 = 10.0;
bool gi_196 = FALSE;
bool gi_200 = FALSE;
bool gi_204 = FALSE;
int gi_208;
int gi_212;
int gi_216;
int gi_220;
int gperiod_224 = 10;
double gd_228 = 10.0;
double gd_unused_236 = 5.0;
double gd_unused_244 = 10.0;
double gd_unused_252 = 22.0;
double gd_unused_260 = 20.0;
double gd_unused_268 = 26.0;
double gd_unused_276 = 13.0;
double gd_unused_284 = 15.0;
double gd_unused_292 = 10.0;
double gd_300;
double gd_308;
double glotstep_316;
double gd_324;
int gi_332;
double gprice_336;
double gd_344;
double gpoint_352;
int gslippage_360;
bool gi_unused_364 = FALSE;
int gi_368 = 25;
int gi_372 = 33;
int gi_376 = 100;
int gi_380 = 0;
int gi_384 = 0;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   if (Point == 0.00001) gpoint_352 = 0.0001;
   else {
      if (Point == 0.001) gpoint_352 = 0.01;
      else gpoint_352 = Point;
      if (IsDemo() == TRUE) return (1);
   }
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   return (0);
}

// 23709652CEEDF22AAD4BBB6A355B83E2
int f0_1(double ad_0, double ad_8) {
   if (ad_0 > ad_8) gi_384 = 1;
   if (ad_0 < ad_8) gi_384 = 2;
   if (gi_384 != gi_380) {
      gi_380 = gi_384;
      return (gi_380);
   }
   return (0);
}

// 76801FC396F13051B0AFD9F8DB4EADCC
double f0_3() {
   double ima_0;
   double ima_8;
   double ima_16;
   double istddev_24;
   double ld_ret_32;
   double ld_40 = 0;
   double ld_48 = 0;
   double ld_56 = 0;
   double ld_64 = 0;
   double ld_unused_72 = 0;
   double ld_unused_80 = 0;
   double ld_88 = 0;
   double ld_96 = 0;
   double ld_104 = 0;
   double ld_112 = 0;
   double ld_120 = 0;
   double ld_unused_128 = 0;
   double ld_136 = 0;
   double ld_144 = 0;
   double ld_152 = 0;
   double ld_160 = 0;
   double ima_168 = iMA(NULL, 0, gperiod_224, 0, MODE_SMA, PRICE_CLOSE, 0);
   for (int li_176 = 1; li_176 <= gperiod_224; li_176++) {
      ima_0 = iMA(NULL, 0, gperiod_224, 0, MODE_SMA, PRICE_CLOSE, li_176);
      ima_8 = iMA(NULL, 0, gperiod_224, 0, MODE_SMA, PRICE_HIGH, li_176);
      ima_16 = iMA(NULL, 0, gperiod_224, 0, MODE_SMA, PRICE_LOW, li_176);
      istddev_24 = iStdDev(NULL, 0, gperiod_224, 0, MODE_SMA, PRICE_CLOSE, li_176);
      ld_40 += (High[li_176] + Low[li_176]) / 2.0;
      ld_48 += Close[li_176];
      ld_56 += ld_40 - ld_48;
      ld_64 += ima_0;
      ld_112 += istddev_24;
      ld_136 += Close[li_176] - Open[li_176] - (Close[li_176 - 1] - (Open[li_176 - 1]));
      ld_160 = ld_160 + (ima_8 - ima_0) + (ima_16 - ima_0);
   }
   ld_88 = ld_40 / gperiod_224;
   ld_96 = ld_48 / gperiod_224;
   ld_104 = ld_64 / gperiod_224;
   ld_120 = ld_112 / gperiod_224;
   ld_152 = ld_56 / gperiod_224;
   ld_144 = ld_136 / gperiod_224;
   if (ld_152 > 0.0 && ima_168 > ld_104 && ld_144 > 0.0 && Open[0] < ima_168 + ld_120 && Open[0] > ima_168) {
      ld_ret_32 = 1;
      gd_344 = 10000.0 * (2.0 * ld_120) + gd_228;
   }
   if (ld_152 < 0.0 && ima_168 < ld_104 && ld_144 < 0.0 && Open[0] > ima_168 - ld_120 && Open[0] < ima_168) {
      ld_ret_32 = 2;
      gd_344 = 10000.0 * (2.0 * ld_120) + gd_228;
   }
   if (ld_152 > 0.0 && ima_168 > ld_104 && ld_144 > 0.0 && Open[0] < ima_168 - ld_120) {
      ld_ret_32 = 3;
      gd_344 = 10000.0 * (2.0 * ld_120) + 10.0;
   }
   if (ld_152 < 0.0 && ima_168 < ld_104 && ld_144 < 0.0 && Open[0] > ima_168 + ld_120) {
      ld_ret_32 = 4;
      gd_344 = 10000.0 * (2.0 * ld_120) + 10.0;
   }
   return (ld_ret_32);
}

// CD29AE9802F0B3728424022A8E03913B
double f0_4() {
   double ld_ret_0;
   double ld_8 = 0;
   double ld_16 = 0;
   double ld_24 = 0;
   double ld_32 = 0;
   double ld_40 = 0;
   double ld_48 = 0;
   double ld_56 = 0;
   double ld_64 = 0;
   double ld_72 = 0;
   double istddev_80 = 0;
   double ld_88 = 0;
   double ld_96 = 0;
   double ld_104 = 0;
   istddev_80 = iStdDev(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, 0);
   double istddev_112 = iStdDev(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 0);
   double ima_120 = iMA(NULL, PERIOD_M30, 10, 0, MODE_SMA, PRICE_CLOSE, 0);
   double ima_128 = iMA(NULL, PERIOD_M30, 10, 0, MODE_SMA, PRICE_CLOSE, 1);
   double ima_136 = iMA(NULL, PERIOD_M30, 10, 0, MODE_SMA, PRICE_CLOSE, 2);
   for (int li_144 = 1; li_144 <= 20; li_144++) {
      ld_8 += Close[li_144];
      ld_16 += High[li_144] - Low[li_144];
      ld_24 += Close[li_144] - Open[li_144];
      if (li_144 <= 10) {
         ld_88 += Close[li_144];
         ld_96 += High[li_144] - Low[li_144];
         ld_104 += Close[li_144] - Open[li_144];
      }
   }
   ld_32 = ld_8 / 20.0;
   ld_40 = ld_16 / 20.0;
   ld_48 = ld_24 / 20.0;
   double ld_148 = ld_88 / 10.0;
   double ld_156 = ld_96 / 10.0;
   double ld_164 = ld_104 / 10.0;
   ld_72 = (Open[0] - ld_148) / istddev_80;
   double ld_172 = (Open[0] - ld_32) / istddev_112;
   ld_56 = ld_148 + 0.308 * ld_156;
   double ld_180 = ld_32 + 0.18 * ld_40;
   ld_64 = ld_148 - 0.308 * ld_156;
   double ld_188 = ld_32 - 0.18 * ld_40;
   if ((ima_120 - ima_136 > ima_128 - ima_136 + 0.0002 && ld_164 > 0.0 && ld_104 > 0.0 && Open[0] > ld_64 && Open[0] <= ld_148 + ld_72 * ld_164 && ld_72 < 0.0 && High[1] - Low[1] < 1.777 * ld_156) ||
      (ima_120 - ima_136 > ima_128 - ima_136 + 0.0002 && ld_48 > 0.0 && ld_24 > 0.0 && Open[0] > ld_188 && Open[0] <= ld_32 + ld_72 * ld_48 && ld_172 < 0.0 && High[1] - Low[1] < 1.586 * ld_156)) {
      ld_ret_0 = 1;
      gd_344 = 10000.0 * istddev_112 + 10.0;
   }
   if ((ima_120 - ima_136 < ima_128 - ima_136 - 0.0002 && ld_164 < 0.0 && ld_104 < 0.0 && Open[0] < ld_56 && Open[0] >= ld_148 + ld_72 * ld_164 && ld_72 > 0.0 && High[1] - Low[1] < 1.777 * ld_156) ||
      (ima_120 - ima_136 < ima_128 - ima_136 - 0.0002 && ld_48 < 0.0 && ld_24 < 0.0 && Open[0] < ld_180 && Open[0] >= ld_32 + ld_72 * ld_48 && ld_172 > 0.0 && High[1] - Low[1] < 1.586 * ld_156)) {
      ld_ret_0 = 2;
      gd_344 = 10000.0 * istddev_112 + 10.0;
   }
   if (ima_120 - ima_136 > ima_128 - ima_136 + 0.0002 && ld_48 > 0.0 && ld_24 > 0.0 && Open[0] > ld_188 && Open[0] <= ld_32 + ld_72 * ld_48 && ld_172 < 0.0 && High[1] - Low[1] > 1.586 * ld_156) {
      ld_ret_0 = 3;
      gprice_336 = 10000.0 * istddev_112 + 10.0;
   }
   if (ima_120 - ima_136 < ima_128 - ima_136 - 0.0002 && ld_48 < 0.0 && ld_24 < 0.0 && Open[0] < ld_180 && Open[0] >= ld_32 + ld_72 * ld_48 && ld_172 > 0.0 && High[1] - Low[1] > 1.586 * ld_156) {
      ld_ret_0 = 4;
      gprice_336 = 10000.0 * istddev_112 + 10.0;
   }
   return (ld_ret_0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int ticket_0;
   double price_4;
   bool li_12;
   bool li_16;
   bool li_20;
   bool li_24;
   bool li_28;
   bool li_32;
   bool li_36;
   bool li_40;
   bool li_44;
   bool li_48;
   bool li_52;
   bool li_56;
   double price_60;
   int hour_68 = TimeHour(TimeCurrent());
   int count_72 = 0;
   int count_76 = 0;
   double high_80 = High[iHighest(NULL, 0, MODE_HIGH, gi_376, 0)];
   double low_88 = Low[iLowest(NULL, 0, MODE_LOW, gi_376, 0)];
   double imacd_96 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
   double imacd_104 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 1);
   double imacd_112 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 0);
   double imacd_120 = iMACD(NULL, 0, 12, 26, 9, PRICE_CLOSE, MODE_SIGNAL, 1);
   double ima_128 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_HIGH, 0);
   double ima_136 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_HIGH, 1);
   double ima_144 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_LOW, 0);
   double ima_152 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_LOW, 1);
   double ima_160 = iMA(NULL, 0, 22, 0, MODE_SMA, PRICE_CLOSE, 0);
   double ima_168 = iMA(NULL, 0, 22, 0, MODE_SMA, PRICE_CLOSE, 5);
   double ima_176 = iMA(NULL, 0, 22, 0, MODE_SMA, PRICE_CLOSE, 1);
   double ima_184 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 0);
   double ima_192 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 1);
   double ima_200 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 2);
   double ima_208 = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, 1);
   double ima_216 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, 5);
   double ima_224 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, 0);
   double ima_232 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, 1);
   int li_240 = f0_1(ima_232, ima_176);
   double ima_244 = iMA(NULL, 0, gi_376, 0, MODE_SMA, PRICE_CLOSE, 0);
   double istddev_252 = iStdDev(NULL, 0, gi_376, 0, MODE_SMA, PRICE_CLOSE, 0);
   double istddev_260 = iStdDev(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 0);
   double istddev_268 = iStdDev(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 1);
   double iwpr_276 = iWPR(NULL, 0, 26, 0);
   double iwpr_284 = iWPR(NULL, 0, 26, 1);
   double iwpr_292 = iWPR(NULL, 0, 26, 2);
   double iwpr_300 = iWPR(NULL, 0, 114, 0);
   double iwpr_308 = iWPR(NULL, 0, 114, 1);
   double idemarker_316 = iDeMarker(NULL, 0, 13, 0);
   double idemarker_324 = iDeMarker(NULL, 0, 13, 1);
   double idemarker_332 = iDeMarker(NULL, 0, 13, 2);
   double istochastic_340 = iStochastic(NULL, 0, 15, 6, 7, MODE_EMA, 0, MODE_MAIN, 0);
   double istochastic_348 = iStochastic(NULL, 0, 15, 6, 7, MODE_EMA, 0, MODE_MAIN, 1);
   double istochastic_356 = iStochastic(NULL, 0, 15, 6, 7, MODE_EMA, 0, MODE_SIGNAL, 0);
   double istochastic_364 = iStochastic(NULL, 0, 15, 6, 7, MODE_EMA, 0, MODE_SIGNAL, 1);
   if (istochastic_348 < istochastic_364 - 5.0 && istochastic_340 >= istochastic_356) li_20 = TRUE;
   if (istochastic_348 > istochastic_364 + 5.0 && istochastic_340 <= istochastic_356) li_24 = TRUE;
   if (istochastic_348 > istochastic_364 && istochastic_340 > istochastic_356) li_28 = TRUE;
   if (istochastic_348 < istochastic_364 && istochastic_340 < istochastic_356) li_32 = TRUE;
   double istochastic_372 = iStochastic(NULL, 0, 10, 5, 5, MODE_SMA, 0, MODE_MAIN, 0);
   double istochastic_380 = iStochastic(NULL, 0, 10, 5, 5, MODE_SMA, 0, MODE_MAIN, 1);
   double istochastic_388 = iStochastic(NULL, 0, 10, 5, 5, MODE_SMA, 0, MODE_SIGNAL, 0);
   double istochastic_396 = iStochastic(NULL, 0, 10, 5, 5, MODE_SMA, 0, MODE_SIGNAL, 1);
   if (istochastic_380 < istochastic_396 - 5.0 && istochastic_372 >= istochastic_388) li_36 = TRUE;
   if (istochastic_380 > istochastic_396 + 5.0 && istochastic_372 <= istochastic_388) li_40 = TRUE;
   if (istochastic_380 < istochastic_396 && istochastic_372 >= istochastic_388) li_44 = TRUE;
   if (istochastic_380 > istochastic_396 && istochastic_372 <= istochastic_388) li_48 = TRUE;
   if (istochastic_380 > istochastic_396 && istochastic_372 > istochastic_388) li_52 = TRUE;
   if (istochastic_380 < istochastic_396 && istochastic_372 < istochastic_388) li_56 = TRUE;
   double irsi_404 = iRSI(NULL, 0, 14, PRICE_CLOSE, 0);
   double irsi_412 = iRSI(NULL, 0, 14, PRICE_CLOSE, 1);
   double irsi_420 = iRSI(NULL, 0, 14, PRICE_CLOSE, 2);
   double ld_unused_428 = 0;
   if (irsi_404 < 30.0) ld_unused_428 = 1;
   if (irsi_404 > 70.0) ld_unused_428 = 2;
   double ibands_436 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_LOWER, 1);
   double ibands_444 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_LOWER, 2);
   double ibands_452 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_UPPER, 1);
   double ibands_460 = iBands(NULL, 0, 20, 2, 0, PRICE_CLOSE, MODE_UPPER, 2);
   double iadx_468 = iADX(NULL, 0, 14, PRICE_HIGH, MODE_MAIN, 0);
   double iadx_476 = iADX(NULL, 0, 14, PRICE_HIGH, MODE_PLUSDI, 0);
   double iadx_484 = iADX(NULL, 0, 14, PRICE_HIGH, MODE_PLUSDI, 1);
   double iadx_492 = iADX(NULL, 0, 14, PRICE_HIGH, MODE_MINUSDI, 0);
   double iadx_500 = iADX(NULL, 0, 14, PRICE_HIGH, MODE_MINUSDI, 1);
   if (iadx_476 > iadx_492) li_16 = TRUE;
   if (iadx_492 > iadx_476) li_12 = TRUE;
   if (iadx_468 < 30.0) {
      li_12 = FALSE;
      li_16 = FALSE;
   }
   gd_300 = MarketInfo(Symbol(), MODE_MAXLOT);
   gd_308 = MarketInfo(Symbol(), MODE_MINLOT);
   glotstep_316 = MarketInfo(Symbol(), MODE_LOTSTEP);
   gd_324 = MarketInfo(Symbol(), MODE_MARGINREQUIRED) * glotstep_316;
   gi_332 = 3600 * gi_368 + 60 * gi_372;
   int li_unused_508 = MarketInfo(Symbol(), MODE_STOPLEVEL);
   gslippage_360 = gslippage_156;
   Comment("\n", "    Copyright © 2013 - Forex Overdrive Team", 
      "\n", "    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+", 
      "\n", "     Time      : ", TimeToStr(TimeCurrent()), 
      "\n", 
      "\n", "     Total Profit/Loss    : ", AccountProfit(), 
   "\n");
   if (DayOfWeek() == 5 && gi_96 == FALSE && gi_204) return (0);
   if (!f0_0()) return (0);
   if (Bars < 100) {
      Print("bars less than 100");
      return (0);
   }
   if (!IsConnected()) {
      Print("Error 1");
      Sleep(5000);
      return (0);
   }
   double price_512 = StopLoss;
   if (price_512 <= 0.0) price_512 = 0;
   bool li_520 = FALSE;
   bool li_524 = FALSE;
   int order_total_528 = OrdersTotal();
   if (order_total_528 > 0) {
      for (int pos_532 = 0; pos_532 < order_total_528; pos_532++) {
         OrderSelect(pos_532, SELECT_BY_POS);
         if (OrderMagicNumber() == MagicNo) {
            if (OrderType() <= OP_SELL && OrderSymbol() == Symbol()) count_72++;
            else count_76++;
         }
         if (OrderType() == OP_BUY) li_520 = TRUE;
         if (OrderType() == OP_SELL) li_524 = TRUE;
      }
   }
   if (count_72 < MaxOrder) {
      if (count_72 > 0) {
         OrderSelect(count_72 - 1, SELECT_BY_POS, MODE_TRADES);
         if (OrderMagicNumber() == MagicNo)
            if (TimeCurrent() - OrderOpenTime() <= 60.0 * gd_132) return (0);
      }
      if (AccountFreeMargin() < 100.0 * f0_5()) {
         Print("You do not have enough money to trade! You have = ", AccountFreeMargin());
         return (0);
      }
      if (!IsTradeAllowed()) {
         Print("Wait...");
         Sleep(1000);
         return (0);
      }
      if (gi_200) {
         li_520 = FALSE;
         li_524 = FALSE;
      }
      if (li_524 == FALSE) {
         if (f0_3() == 3.0 && ((iwpr_276 > iwpr_284 + 9.0 && li_52) || (iwpr_276 > iwpr_284 + 9.0 && li_28) && idemarker_316 > idemarker_324 + 0.05 && ima_192 < ima_176) ||
            (istochastic_340 < 40.0 && Open[1] < ima_152 && ima_160 > ima_216) || (istochastic_380 < 40.0 && ima_160 > ima_176 && ima_208 > ima_192) || (Open[2] > ima_192 && Open[1] < Close[1] &&
            Open[0] > Close[1] && li_28 && iwpr_276 > iwpr_284 + 7.0 && idemarker_316 > idemarker_324 + 0.05)) {
            ticket_0 = OrderSend(Symbol(), OP_BUY, f0_5(), Ask, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Green);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Buy order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Ask - StopLoss * gpoint_352;
               gprice_336 = Ask + gd_344 * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Buy order : ", GetLastError());
            return (0);
         }
         if (f0_3() == 1.0 && ((iwpr_276 > iwpr_284 + 9.0 && istochastic_372 < 60.0 && li_52) || (iwpr_276 > iwpr_284 + 18.0 && istochastic_340 < 70.0 && li_28) && iwpr_276 < -15.0 &&
            idemarker_316 > idemarker_324 && ima_192 > ima_176 && ima_160 > ima_176) || (istochastic_340 < 40.0 && Open[1] > ima_152 && ima_184 < ima_216) || (istochastic_380 < 40.0 && ima_160 > ima_176 && ima_208 > ima_192) ||
            (Open[2] > ima_192 && Open[1] < Close[1] && Open[0] > Close[1] && li_28 && iwpr_276 > iwpr_284 + 7.0 && idemarker_316 > idemarker_324 + 0.1)) {
            ticket_0 = OrderSend(Symbol(), OP_BUY, f0_5(), Ask, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Green);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Ask - StopLoss * gpoint_352;
               gprice_336 = Ask + gd_344 * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Buy order : ", GetLastError());
            return (0);
         }
         if ((f0_4() == 1.0 && (istochastic_340 < 50.0 && Open[1] > ima_152 && ima_184 < ima_216 && li_28 && Open[0] > Close[1] && Open[1] > Close[1])) || (f0_4() == 1.0 &&
            istochastic_340 < 50.0 && li_28 && iwpr_276 > iwpr_284 + 7.0 && Open[2] < Close[2] && Open[0] > Close[1] && Open[1] > Close[1]) || (f0_4() == 3.0 && Open[0] > Close[1] && Open[1] < Close[1])) {
            ticket_0 = OrderSend(Symbol(), OP_BUY, f0_5(), Ask, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Green);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Buy order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Ask - StopLoss * gpoint_352;
               gprice_336 = Ask + gd_344 * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Buy order : ", GetLastError());
            return (0);
         }
         if ((ima_224 > ima_232 && ima_160 > ima_176 + 0.0002 && Open[0] < ima_160 + istddev_260 && (istochastic_372 > istochastic_380 && istochastic_388 > istochastic_396) ||
            (istochastic_340 > istochastic_348 && istochastic_356 > istochastic_364) && iwpr_276 < -15.0 && iwpr_276 > iwpr_284 + 3.0 && li_28 && ima_184 > ima_160 && Open[0] > ima_224) ||
            (iwpr_300 > iwpr_308 && iwpr_300 > -20.0 && iwpr_308 > -20.0 && iwpr_276 > iwpr_284 + 25.0 && iwpr_276 < -15.0 && iwpr_284 < iwpr_292 && istddev_260 > istddev_268 &&
            idemarker_316 > idemarker_324 && ima_160 > ima_168 && li_28 && iadx_468 > 20.0) || (Low[1] < ima_160 - 3.2 * istddev_268 && iwpr_276 > iwpr_284 + 7.0 && iwpr_276 < -75.0 && li_28 && (istochastic_340 >= 20.0 && istddev_260 > istddev_268) ||
            iwpr_284 < iwpr_292) || (ima_128 > ima_184 && ima_128 > ima_136 && ima_136 < ima_184 && ima_160 > ima_168 + 0.0002 && Open[1] < Close[1] && li_28 && iwpr_276 > iwpr_284 + 7.0 && idemarker_316 > idemarker_324 && iadx_476 > iadx_492) ||
            (imacd_96 > imacd_104 && imacd_96 < -0.0003 && imacd_96 > imacd_112 && imacd_104 < imacd_120 && li_28 && iwpr_276 > iwpr_284 && li_16 && ima_208 > ima_192 && Close[1] < Open[0] &&
            Close[1] > Open[1] && istddev_260 > istddev_268) || (iwpr_276 >= -75.0 && iwpr_276 > iwpr_284 + 9.0 && iwpr_284 < iwpr_292 - 5.0 && Open[2] < Close[2] && Open[1] > Close[2] && Open[1] < Close[1] && li_28 && ima_184 > ima_192 + 0.0005 && iadx_468 > 25.0 && iadx_476 > 25.0 && ima_208 > ima_192) ||
            (li_240 == 1 && iadx_476 > 25.0 && iwpr_276 > iwpr_284 + 12.0 && iadx_468 > 25.0 && iadx_476 > iadx_484 || ima_208 > ima_192 && ima_160 >= ima_176 && ima_232 < ima_216 &&
            li_28) || (Close[1] > ima_192 && Open[1] < ima_192 && ima_208 > ima_192 && iadx_468 > 30.0 && iadx_476 > 25.0 && ima_160 > ima_168 + 0.0003 && li_28 && iwpr_276 > iwpr_284 + 18.0 && iwpr_284 > iwpr_292 + 7.0) ||
            (ima_224 > ima_232 && ima_184 > ima_192 && ima_160 > ima_176 && ima_160 > ima_168 + 0.0005 && ima_184 - ima_192 > ima_160 - ima_176 && ima_224 - ima_160 > ima_232 - ima_176 &&
            li_28 && iwpr_276 < -15.0 && iwpr_276 > iwpr_284 + 15.0 && ima_224 > ima_184 && ima_184 > ima_160 && Open[0] > ima_224)) {
            ticket_0 = OrderSend(Symbol(), OP_BUY, f0_5(), Ask, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Green);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Buy order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Ask - StopLoss * gpoint_352;
               gprice_336 = Ask + TakeProfit * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Buy order : ", GetLastError());
            return (0);
         }
         if ((li_20 && imacd_96 > imacd_104 && imacd_96 > imacd_112 && ima_208 > ima_192 && li_16 && iwpr_276 > iwpr_284 + 7.0 && istochastic_340 > istochastic_348 && istochastic_356 > istochastic_364 +
            1.0) || (li_20 && imacd_96 > imacd_104 && imacd_96 > imacd_112 && Open[0] > Close[1] && ima_184 < ima_192 && iwpr_276 > iwpr_284 + 9.0 && li_16 && ima_208 > ima_192) ||
            (li_20 && istochastic_340 < 30.0 && Open[1] > ima_152 && Close[1] > ima_216 && Open[0] > ima_128 && ima_184 < ima_216 && ima_184 < ima_192) || (li_20 && Open[1] > ima_152 &&
            Open[0] > ima_128 && Open[1] < Close[1] && iwpr_276 > iwpr_284 + 7.0 && idemarker_316 > idemarker_324 + 0.08 && istddev_260 > istddev_268)) {
            ticket_0 = OrderSend(Symbol(), OP_BUY, f0_5(), Ask, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Green);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Buy order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Ask - StopLoss * gpoint_352;
               gprice_336 = Ask + TakeProfit * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Buy order : ", GetLastError());
            return (0);
         }
         if ((Close[4] < Close[3] && Close[3] > Close[2] && Close[2] > Close[1] && Open[0] > Close[1] && High[1] - Close[1] < Open[1] - Low[1] && ima_184 > ima_216 + 0.0005 &&
            iwpr_276 > iwpr_284 + 9.0 && iadx_468 > 25.0 && iadx_476 > 25.0 && iwpr_284 > iwpr_292) || (Open[1] < Close[1] && Close[2] < ima_160 && Close[1] > ima_160 && Open[1] > ima_224 && Open[0] > ima_128 && ima_160 > ima_168 + 0.0005 && iwpr_276 < -5.0 && iwpr_276 > iwpr_284 + 7.0 && idemarker_316 > idemarker_324 && idemarker_324 > idemarker_332) ||
            (iadx_476 > iadx_484 && iadx_484 < iadx_500 && iadx_476 >= iadx_492 && iadx_468 >= 35.0 && iadx_476 > 25.0 && iwpr_276 > iwpr_284 + 15.0 && li_28) || (irsi_412 < irsi_420 &&
            irsi_404 > irsi_412 + 5.0 && irsi_412 < 30.0 && ima_208 > ima_192 && iadx_468 > 25.0 && iadx_476 > 25.0)) {
            ticket_0 = OrderSend(Symbol(), OP_BUY, f0_5(), Ask, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Green);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Ask - StopLoss * gpoint_352;
               gprice_336 = Ask + TakeProfit * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Buy order : ", GetLastError());
            return (0);
         }
         if ((li_36 && Open[1] > ima_152 && Open[0] > ima_128 && Open[1] < Close[1] && ima_160 > ima_176 + 0.0002 && iadx_468 > 25.0 && iadx_476 > 25.0 && iwpr_276 > iwpr_284 +
            9.0 && ima_208 > ima_192) || (li_36 && imacd_96 > imacd_104 && imacd_96 < 0.0 && imacd_96 > imacd_112 && iadx_468 > 25.0 && iadx_476 > 25.0 && iwpr_276 > iwpr_284 + 7.0 && istochastic_372 > istochastic_380 && istochastic_388 > istochastic_396 + 1.0) ||
            ((li_44 && istochastic_380 < 25.0) || (li_36 && istochastic_380 < 30.0) && ima_160 > ima_176 + 0.0002 && ima_208 > ima_192)) {
            ticket_0 = OrderSend(Symbol(), OP_BUY, f0_5(), Ask, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Green);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Buy order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Ask - StopLoss * gpoint_352;
               gprice_336 = Ask + TakeProfit * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Buy order : ", GetLastError());
            return (0);
         }
         if ((Close[2] < ibands_444 && Open[1] > ibands_436 && Open[0] > Close[1] && Open[1] < Close[1] && li_52 && iwpr_276 > iwpr_284 + 12.0 && istochastic_372 > istochastic_380 +
            3.0 && istochastic_388 > istochastic_396 && ima_208 > ima_192 && ima_184 > ima_192) || (Close[3] > ima_216 && Open[2] > ima_192 && Open[1] < Close[1] && Open[1] > Close[2] && Close[1] > ima_160 + 2.2 * istddev_268 && Open[0] > Close[1] && istddev_260 > istddev_268 && li_28 && iwpr_276 > iwpr_284 + 7.0 && iwpr_276 < -15.0) ||
            (ima_192 < ima_200 - 0.0001 && ima_184 > ima_192 + 0.0002 && ima_184 > ima_200 + 0.0001 && ima_192 < ima_176 && li_28 || li_52 && Open[0] > Close[1]) || (ima_176 - ima_244 < ima_160 - ima_244 &&
            ima_244 < (high_80 + low_88) / 2.0 - 2.0 * istddev_252 && ima_160 - ima_244 > istddev_252 && Open[0] > Close[1] && li_28) || (iSAR(NULL, 0, 0.02, 0.2, 1) > Close[1] && iSAR(NULL,
            0, 0.02, 0.2, 0) < Open[0] && iSAR(NULL, PERIOD_M15, 0.02, 0.2, 1) > iClose(NULL, PERIOD_M15, 1) && iSAR(NULL, PERIOD_M15, 0.02, 0.2, 0) < iOpen(NULL, PERIOD_M15,
            0) && iSAR(NULL, PERIOD_M30, 0.02, 0.2, 1) > iClose(NULL, PERIOD_M30, 1) && iSAR(NULL, PERIOD_M30, 0.02, 0.2, 0) < iOpen(NULL, PERIOD_M30, 0) && (Open[0] < Close[0] && Open[0] > Close[1] && Ask > ima_160) ||
            (ima_224 > ima_232 && imacd_96 > imacd_104 && imacd_96 < 0.0))) {
            ticket_0 = OrderSend(Symbol(), OP_BUY, f0_5(), Ask, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Green);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Buy order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Ask - StopLoss * gpoint_352;
               gprice_336 = Ask + TakeProfit * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Buy order : ", GetLastError());
            return (0);
         }
         if (f0_3() == 1.0 || f0_4() == 1.0 && Ask < (high_80 + low_88) / 2.0 && li_28 && istochastic_340 < 45.0) {
            ticket_0 = OrderSend(Symbol(), OP_BUY, f0_5(), Ask, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Green);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Buy order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Ask - StopLoss * gpoint_352;
               gprice_336 = Ask + 10.0 * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Buy order : ", GetLastError());
            return (0);
         }
      }
      if (li_520 == FALSE) {
         if (f0_3() == 4.0 && ((iwpr_276 < iwpr_284 - 9.0 && li_56) || (iwpr_276 < iwpr_284 - 9.0 && li_32) && idemarker_316 < idemarker_324 - 0.05 && ima_192 > ima_176) ||
            (istochastic_340 > 60.0 && Open[1] > ima_136 && ima_160 < ima_216) || (istochastic_380 > 60.0 && ima_160 < ima_176 && ima_208 < ima_192) || (Open[2] < ima_192 && Open[1] > Close[1] &&
            Open[0] < Close[1] && li_32 && iwpr_276 < iwpr_284 - 7.0 && idemarker_316 < idemarker_324 - 0.05)) {
            ticket_0 = OrderSend(Symbol(), OP_SELL, f0_5(), Bid, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Red);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Sell order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Bid + StopLoss * gpoint_352;
               gprice_336 = Bid - gd_344 * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Sell order : ", GetLastError());
            return (0);
         }
         if (f0_3() == 2.0 && ((iwpr_276 < iwpr_284 - 9.0 && istochastic_372 > 40.0 && li_56) || (iwpr_276 < iwpr_284 - 18.0 && istochastic_340 > 30.0 && li_32) && iwpr_276 > -85.0 &&
            idemarker_316 < idemarker_324 && ima_192 < ima_176 && ima_160 < ima_176) || (istochastic_340 > 60.0 && Open[1] < ima_136 && ima_184 > ima_216) || (istochastic_380 > 60.0 && ima_160 < ima_176 && ima_208 < ima_192) ||
            (Open[2] < ima_192 && Open[1] > Close[1] && Open[0] < Close[1] && li_32 && iwpr_276 < iwpr_284 - 7.0 && idemarker_316 < idemarker_324 - 0.1)) {
            ticket_0 = OrderSend(Symbol(), OP_SELL, f0_5(), Bid, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Red);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Sell order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Bid + StopLoss * gpoint_352;
               gprice_336 = Bid - gd_344 * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Sell order : ", GetLastError());
            return (0);
         }
         if ((f0_4() == 2.0 && (istochastic_340 > 50.0 && Open[1] < ima_136 && ima_184 > ima_216 && li_32 && Open[0] < Close[1] && Open[1] < Close[1])) || (f0_4() == 2.0 &&
            li_32 && istochastic_340 > 50.0 && iwpr_276 < iwpr_284 - 7.0 && Open[2] > Close[2] && Open[0] < Close[1] && Open[1] < Close[1]) || (f0_4() == 4.0 && Open[0] < Close[1] && Open[1] > Close[1])) {
            ticket_0 = OrderSend(Symbol(), OP_SELL, f0_5(), Bid, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Red);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Sell order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Bid + StopLoss * gpoint_352;
               gprice_336 = Bid - gd_344 * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Sell order : ", GetLastError());
            return (0);
         }
         if ((ima_224 < ima_232 && ima_160 < ima_176 - 0.0002 && Open[0] >= ima_160 - istddev_260 && (istochastic_372 < istochastic_380 && istochastic_388 < istochastic_396) ||
            (istochastic_340 < istochastic_348 && istochastic_356 < istochastic_364) && iwpr_276 > -85.0 && iwpr_276 < iwpr_284 - 3.0 && li_32 && ima_184 < ima_160 && Open[0] < ima_224) ||
            (iwpr_300 < iwpr_308 && iwpr_300 < -80.0 && iwpr_308 < -80.0 && iwpr_276 < iwpr_284 - 25.0 && iwpr_276 > -85.0 && iwpr_284 > iwpr_292 && istddev_260 > istddev_268 &&
            idemarker_316 < idemarker_324 && ima_160 < ima_168 && li_32 && iadx_468 > 20.0) || (High[1] > ima_160 + 3.2 * istddev_268 && iwpr_276 < iwpr_284 - 7.0 && iwpr_276 > -25.0 && li_32 && (istochastic_340 <= 80.0 && istddev_260 > istddev_268) ||
            iwpr_284 > iwpr_292) || (ima_144 < ima_184 && ima_144 < ima_152 && ima_152 > ima_184 && ima_160 < ima_168 - 0.0002 && Open[1] > Close[1] && li_32 && iwpr_276 < iwpr_284 - 7.0 && idemarker_316 < idemarker_324 && iadx_492 > iadx_476) ||
            (imacd_96 < imacd_104 && imacd_96 > 0.0003 && imacd_96 < imacd_112 && imacd_104 > imacd_120 && li_32 && iwpr_276 < iwpr_284 && li_12 && ima_208 < ima_192 && Close[1] > Open[0] &&
            Close[1] < Open[1] && istddev_260 > istddev_268) || (iwpr_276 <= -25.0 && iwpr_276 < iwpr_284 - 9.0 && iwpr_284 > iwpr_292 + 5.0 && Open[2] > Close[2] && Open[1] < Close[2] && Open[1] > Close[1] && li_32 && ima_184 < ima_192 - 0.0005 && iadx_468 > 25.0 && iadx_492 > 25.0 && ima_208 < ima_192) ||
            (li_240 == 2 && iadx_492 > 25.0 && iwpr_276 < iwpr_284 - 12.0 && iadx_468 > 25.0 && iadx_492 > iadx_500 || ima_208 < ima_192 && ima_160 <= ima_176 && ima_232 > ima_216 &&
            li_32) || (Close[1] < ima_192 && Open[1] > ima_192 && ima_208 < ima_192 && iadx_468 > 30.0 && iadx_492 > 25.0 && ima_160 < ima_168 - 0.0003 && li_32 && iwpr_276 < iwpr_284 - 18.0 && iwpr_284 < iwpr_292 - 7.0) ||
            (ima_224 < ima_232 && ima_184 < ima_192 && ima_160 < ima_176 && ima_160 < ima_168 - 0.0005 && ima_192 - ima_184 > ima_176 - ima_160 && ima_160 - ima_224 > ima_176 - ima_232 &&
            li_32 && iwpr_276 > -85.0 && iwpr_276 < iwpr_284 - 15.0 && ima_224 < ima_184 && ima_184 < ima_160 && Open[0] < ima_224)) {
            ticket_0 = OrderSend(Symbol(), OP_SELL, f0_5(), Bid, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Red);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Sell order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Bid + StopLoss * gpoint_352;
               gprice_336 = Bid - TakeProfit * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening SELL order : ", GetLastError());
            return (0);
         }
         if ((li_24 && imacd_96 < imacd_104 && imacd_96 < imacd_112 && ima_208 < ima_192 && li_12 && iwpr_276 < iwpr_284 - 7.0 && istochastic_340 < istochastic_348 && istochastic_356 < istochastic_364 - 1.0) ||
            (li_24 && imacd_96 < imacd_104 && imacd_96 < imacd_112 && Open[0] < Close[1] && ima_184 > ima_192 && iwpr_276 < iwpr_284 - 9.0 && li_12 && ima_208 < ima_192) || (li_24 &&
            istochastic_340 > 70.0 && Open[1] < ima_136 && Close[1] < ima_216 && Open[0] < ima_144 && ima_184 > ima_216 && ima_184 > ima_192) || (li_24 && Open[1] < ima_136 && Open[0] < ima_144 && Open[1] > Close[1] && iwpr_276 < iwpr_284 - 7.0 && idemarker_316 < idemarker_324 - 0.08 && istddev_260 > istddev_268)) {
            ticket_0 = OrderSend(Symbol(), OP_SELL, f0_5(), Bid, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Red);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Sell order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Bid + StopLoss * gpoint_352;
               gprice_336 = Bid - TakeProfit * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Sell order : ", GetLastError());
            return (0);
         }
         if ((Close[4] > Close[3] && Close[3] < Close[2] && Close[2] < Close[1] && Open[0] > Close[1] && Close[1] - Low[1] < High[1] - Open[1] && ima_184 < ima_216 - 0.0005 &&
            iwpr_276 < iwpr_284 - 9.0 && iadx_468 > 25.0 && iadx_492 > 25.0 && iwpr_284 < iwpr_292) || (Open[1] > Close[1] && Close[2] > ima_160 && Close[1] < ima_160 && Open[1] < ima_224 && Open[0] < ima_144 && ima_160 < ima_168 - 0.0005 && iwpr_276 > -95.0 && iwpr_276 < iwpr_284 - 7.0 && idemarker_316 < idemarker_324 && idemarker_324 < idemarker_332) ||
            (iadx_492 > iadx_500 && iadx_484 > iadx_500 && iadx_476 <= iadx_492 && iadx_468 >= 35.0 && iadx_492 > 25.0 && iwpr_276 < iwpr_284 - 15.0 && li_32) || (irsi_412 > irsi_420 &&
            irsi_404 < irsi_412 - 5.0 && irsi_412 > 70.0 && ima_208 < ima_192 && iadx_468 > 25.0 && iadx_492 > 25.0)) {
            ticket_0 = OrderSend(Symbol(), OP_SELL, f0_5(), Bid, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Red);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Sell order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Bid + StopLoss * gpoint_352;
               gprice_336 = Bid - TakeProfit * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening Sell order : ", GetLastError());
            return (0);
         }
         if ((li_40 && Open[1] < ima_136 && Open[0] < ima_144 && Open[1] > Close[1] && ima_160 < ima_176 - 0.0002 && iadx_468 > 25.0 && iadx_492 > 25.0 && iwpr_276 < iwpr_284 - 9.0 &&
            ima_208 < ima_192) || (li_40 && imacd_96 < imacd_104 && imacd_96 > 0.0 && imacd_96 < imacd_112 && iadx_468 > 25.0 && iadx_492 > 25.0 && iwpr_276 < iwpr_284 - 7.0 && istochastic_372 < istochastic_380 && istochastic_388 < istochastic_396 - 1.0) ||
            ((li_48 && istochastic_380 > 75.0) || (li_40 && istochastic_380 > 705.0) && ima_160 < ima_176 - 0.0002 && ima_208 < ima_192)) {
            ticket_0 = OrderSend(Symbol(), OP_SELL, f0_5(), Bid, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Red);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Sell order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Bid + StopLoss * gpoint_352;
               gprice_336 = Bid - TakeProfit * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening SELL order : ", GetLastError());
            return (0);
         }
         if ((Close[2] > ibands_460 && Open[1] < ibands_452 && Open[0] < Close[1] && Open[1] > Close[1] && li_56 && iwpr_276 < iwpr_284 - 12.0 && istochastic_372 < istochastic_380 - 3.0 &&
            istochastic_388 < istochastic_396 && ima_208 < ima_192 && ima_184 < ima_192) || (Close[3] < ima_216 && Open[2] < ima_192 && Open[1] > Close[1] && Open[1] < Close[2] && Close[1] < ima_160 - 2.2 * istddev_268 && Open[0] < Close[1] && istddev_260 > istddev_268 && li_32 && iwpr_276 < iwpr_284 - 7.0 && iwpr_276 > -85.0) ||
            (ima_192 > ima_200 + 0.0001 && ima_184 < ima_192 - 0.0002 && ima_184 < ima_200 - 0.0001 && ima_192 > ima_176 && li_32 || li_56 && Open[0] < Close[1]) || (ima_176 - ima_244 > ima_160 - ima_244 &&
            ima_244 > (high_80 + low_88) / 2.0 + 2.0 * istddev_252 && ima_244 - ima_160 > istddev_252 && Open[0] < Close[1] && li_32) || (iSAR(NULL, 0, 0.02, 0.2, 1) < Close[1] && iSAR(NULL,
            0, 0.02, 0.2, 0) > Open[0] && iSAR(NULL, PERIOD_M15, 0.02, 0.2, 1) < iClose(NULL, PERIOD_M15, 1) && iSAR(NULL, PERIOD_M15, 0.02, 0.2, 0) > iOpen(NULL, PERIOD_M15,
            0) && iSAR(NULL, PERIOD_M30, 0.02, 0.2, 1) < iClose(NULL, PERIOD_M30, 1) && iSAR(NULL, PERIOD_M30, 0.02, 0.2, 0) > iOpen(NULL, PERIOD_M30, 0) && (Open[0] > Close[0] && Open[0] < Close[1] && Bid < ima_160) ||
            (ima_224 < ima_232 && imacd_96 < imacd_104 && imacd_96 > 0.0))) {
            ticket_0 = OrderSend(Symbol(), OP_SELL, f0_5(), Bid, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Red);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Sell order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Bid + StopLoss * gpoint_352;
               gprice_336 = Bid - TakeProfit * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening SELL order : ", GetLastError());
            return (0);
         }
         if (f0_3() == 2.0 || f0_4() == 2.0 && Bid > (high_80 + low_88) / 2.0 && li_32 && istochastic_340 > 55.0) {
            ticket_0 = OrderSend(Symbol(), OP_SELL, f0_5(), Bid, gslippage_360, 0, 0, "Forex Overdrive", MagicNo, 0, Red);
            if (ticket_0 > 0) {
               if (OrderSelect(ticket_0, SELECT_BY_TICKET, MODE_TRADES)) Print("Sell order opened : ", OrderOpenPrice());
               RefreshRates();
               if (price_512 > 0.0) price_512 = Bid + StopLoss * gpoint_352;
               gprice_336 = Bid - 10.0 * gpoint_352;
               OrderModify(OrderTicket(), OrderOpenPrice(), price_512, gprice_336, 0, CLR_NONE);
            } else Print("Error opening SELL order : ", GetLastError());
            return (0);
         }
      }
   }
   if (gi_180 && AccountEquity() > AccountBalance() * (gd_188 / 100.0 + 1.0)) f0_2();
   for (int pos_536 = 0; pos_536 < count_72; pos_536++) {
      OrderSelect(pos_536, SELECT_BY_POS, MODE_TRADES);
      if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNo) {
         price_60 = OrderStopLoss();
         if (OrderType() == OP_BUY) {
            if (AccountFreeMargin() <= 0.0 || (gi_196 && AccountEquity() + AccountMargin() < AccountBalance() * (1 - RiskPercent / 50.0))) {
               OrderClose(OrderTicket(), OrderLots(), Bid, gslippage_156, Violet);
               return (0);
            }
            if (TrailingStop <= 0.0) continue;
            if (Bid - OrderOpenPrice() <= gpoint_352 * TrailingStop) continue;
            if (price_60 >= Bid - gpoint_352 * TrailingStop) continue;
            price_60 = Bid - gpoint_352 * TrailingStop;
            price_4 = OrderTakeProfit();
            if (iwpr_276 > iwpr_284 + 7.0 && li_28) price_4 = OrderTakeProfit() + gi_176 * gpoint_352;
            OrderModify(OrderTicket(), OrderOpenPrice(), price_60, price_4, 0, Blue);
            return (0);
         }
         if (AccountFreeMargin() <= 0.0 || (gi_196 && AccountEquity() + AccountMargin() < AccountBalance() * (1 - RiskPercent / 50.0))) {
            OrderClose(OrderTicket(), OrderLots(), Ask, gslippage_156, Violet);
            return (0);
         }
         if (TrailingStop > 0.0) {
            if (OrderOpenPrice() - Ask > gpoint_352 * TrailingStop) {
               if (price_60 > Ask + gpoint_352 * TrailingStop || price_60 == 0.0) {
                  price_60 = Ask + gpoint_352 * TrailingStop;
                  price_4 = OrderTakeProfit();
                  if (iwpr_276 < iwpr_284 - 7.0 && li_32) price_4 = OrderTakeProfit() - gi_176 * gpoint_352;
                  OrderModify(OrderTicket(), OrderOpenPrice(), price_60, price_4, 0, Red);
                  return (0);
               }
            }
         }
      }
   }
   return (0);
}

// EBFE91FAEB07FF5788FD1001AD46AE29
double f0_5() {
   if (!MM) return (LotSize);
   if (Max_Lot_Size > 0.0) gd_300 = Max_Lot_Size;
   double ld_ret_0 = AccountFreeMargin() * RiskPercent / 400.0;
   ld_ret_0 = NormalizeDouble(MathFloor(ld_ret_0 / gd_324) * glotstep_316, 2);
   if (ld_ret_0 < gd_308) ld_ret_0 = gd_308;
   if (ld_ret_0 > gd_300) ld_ret_0 = gd_300;
   return (ld_ret_0);
}

// 420C4F4EC427E24D9AD73DCA83CAD3FC
void f0_2() {
   int cmd_0;
   bool is_closed_4;
   for (int li_8 = OrdersTotal() - 1; li_8 >= 0; li_8--) {
      cmd_0 = OrderType();
      is_closed_4 = FALSE;
      if (OrderMagicNumber() == MagicNo || (OrderMagicNumber() != MagicNo && gi_184)) {
         switch (cmd_0) {
         case OP_BUY:
            is_closed_4 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), gslippage_360, Pink);
            break;
         case OP_SELL:
            is_closed_4 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), gslippage_360, Pink);
         }
         if (is_closed_4 == 0) Sleep(1000);
      }
   }
   Print("Since Profit Protection is on, all trades have been closed.");
}

// 1CE2E8CA7E236621500591EC05B08E80
bool f0_0() {
   int str2time_0;
   int str2time_4;
   int datetime_8 = TimeCurrent();
   if (gi_204) {
      str2time_0 = StrToTime(gi_208 + ":" + gi_212);
      str2time_4 = StrToTime(gi_216 + ":" + gi_220);
      if (str2time_0 < str2time_4 && datetime_8 < str2time_0 || datetime_8 >= str2time_4) return (FALSE);
      if (str2time_0 > str2time_4 && (datetime_8 < str2time_0 && datetime_8 >= str2time_4)) return (FALSE);
   }
   return (TRUE);
}