#property copyright "Copyright © 2009, PowerUp Capital, License Until 2099.12.31"
#property link      "http://www.metaquotes.net"

#import "Europe Waves_sgr.dll"
   int VerifyKey(string a0, int a1, string a2, string a3, string a4, int& a5[], int& a6[], int& a7[], int& a8[], int& a9[], int& a10[], int& a11[], int& a12[], int& a13[], int& a14[], int& a15[], int& a16[], int& a17[], int& a18[], int& a19[], int& a20[], int& a21[], int& a22[], int& a23[], int& a24[], int& a25[], int& a26[], int& a27[], int& a28[], int& a29[], int& a30[]);
   int VerifyKey2(string a0, int a1, string a2, string a3, double& a4[], double& a5[], double& a6[], double& a7[], double& a8[], double& a9[], double& a10[], double& a11[], double& a12[], double& a13[], double& a14[], double& a15[], double& a16[], double& a17[], double& a18[], double& a19[], double& a20[]);
   double ReturnPoint(string a0, int a1, string a2, string a3, double a4, double a5, int a6, int& a7[], int& a8[], int& a9[]);
   double MoneyManagement(string a0, int a1, string a2, string a3, double a4, double a5, double a6, double a7, double a8, double a9);
#import

extern string ____FX___________ = "-------- Europe Waves EURCHF | EURGPB M15 --------";
extern int GMT_Offset = 0;
extern bool SafeMode = FALSE;
extern bool AutoRiskMgmt = TRUE;
extern double Risk_Percentage = 10.0;
extern double Fixed_Lots = 0.1;
extern double Max_Lots = 50.0;
extern double MaxSpread = 8.0;
extern int MagicNumber = 7384410;
extern string License_Key = "13283809";
extern string Order_Comment = "PowerUP Europe Waves";
int gi_148 = 0;
int gi_152 = 0;
int gi_156 = 0;
int gi_160 = 0;
int gi_164 = 0;
double gd_168 = 0.0;
double gd_176 = 0.0;
double gd_184 = 0.0;
bool gi_192 = TRUE;
bool gi_196 = TRUE;
bool gi_200 = TRUE;
bool gi_204 = TRUE;
bool gi_208 = TRUE;
bool gi_212 = TRUE;
bool gi_216 = TRUE;
bool gi_220 = TRUE;
int g_magic_224 = 7384410;
int g_magic_228 = 7384411;
int g_magic_232 = 7384412;
int g_magic_236 = 7384413;
bool gi_240 = TRUE;
bool gi_244 = TRUE;
bool gi_248 = TRUE;
bool gi_252 = TRUE;
bool gi_256 = TRUE;
bool gi_260 = TRUE;
bool gi_264 = TRUE;
bool gi_268 = TRUE;
int gi_272 = 0;
double gd_276;
double g_lots_284;
int g_count_292 = 0;
int g_count_296 = 0;
int g_count_300 = 0;
int g_count_304 = 0;
int g_count_308 = 0;
int gi_312 = 0;
int gi_316 = 0;
int gi_320 = 0;
int gi_324 = 0;
int gi_328 = 0;
int gi_332 = 0;
int gi_336 = 0;
int gi_340 = 0;
int gi_344 = 0;
int gi_348 = 0;
double g_ord_open_price_352 = 0.0;
double g_ord_open_price_360 = 0.0;
double g_ord_open_price_368 = 0.0;
double g_ord_open_price_376 = 0.0;
double g_ord_open_price_384 = 0.0;
double g_ord_open_price_392 = 0.0;
double g_ord_open_price_400 = 0.0;
double g_ord_open_price_408 = 0.0;
double g_ord_open_price_416 = 0.0;
double g_ord_open_price_424 = 0.0;
double g_price_432 = 0.0;
double g_price_440 = 0.0;
double g_ifractals_448;
double g_ifractals_456;
double g_ifractals_464;
double g_ifractals_472;
int gi_480 = 0;
double gd_484 = 0.0;
int gi_492 = 0;
string gs_496;
int gi_504;
int g_datetime_508;
int g_day_512;
int g_day_of_week_516;
int g_hour_520;
double gd_524;
int g_slippage_532;
int g_slippage_536;
int gia_540[1];
int gia_544[1];
int gia_548[1];
int gia_552[1];
int gia_556[1];
int gia_560[1];
int gia_564[1];
int gia_568[1];
int gia_572[1];
int gia_576[1];
int gia_580[1];
int gia_584[1];
int gia_588[1];
int gia_592[1];
int gia_596[1];
int gia_600[1];
int gia_604[1];
int gia_608[1];
int gia_612[1];
int gia_616[1];
int gia_620[1];
int gia_624[1];
int gia_628[1];
int gia_632[1];
int gia_636[1];
int gia_640[1];
double gda_644[1];
double gda_648[1];
double gda_652[1];
double gda_656[1];
double gda_660[1];
double gda_664[1];
double gda_668[1];
double gda_672[1];
double gda_676[1];
double gda_680[1];
double gda_684[1];
double gda_688[1];
double gda_692[1];
double gda_696[1];
double gda_700[1];
double gda_704[1];
double gda_708[1];
int gia_712[1];
int gia_716[1];
int gia_720[1];
int gi_724;
int gi_728;

int init() {
   Comment("");
   gi_724 = VerifyKey(AccountCompany(), AccountNumber(), AccountName(), License_Key, TimeToStr(TimeCurrent(), TIME_DATE), gia_540, gia_544, gia_548, gia_552, gia_556, gia_560, gia_564, gia_568, gia_572, gia_576, gia_580, gia_584, gia_588, gia_592, gia_596, gia_600, gia_604, gia_608, gia_612, gia_616, gia_620, gia_624, gia_628, gia_632, gia_636, gia_640);
   if (gi_724 == 0) {
      Alert("Your EA is not activated. Please activate your copy." 
      + "\n");
      Comment("Your EA is not activated. Please activate your copy." 
      + "\n");
      return (0);
   }
   if (gi_724 == -1) {
      Alert("Your EA license has expired. Please renew your copy." 
      + "\n");
      Comment("Your EA license has expired. Please renew your copy." 
      + "\n");
      return (0);
   }
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   Comment("");
   gs_496 = Symbol();
   if (gs_496 != "EURGBPm" && gs_496 != "EURCHFm" && gs_496 != "EURCHF" && gs_496 != "EURGBP" && gs_496 != "EURCHFFXF" && gs_496 != "EURGBPFXF" && gs_496 != "EURCHF-fx" && gs_496 != "EURGBP-fx" && gs_496 != "EURCHF.usd" &&
      gs_496 != "EURGBP.usd") {
      Alert("only on EURCHF or EURGPB M15." 
      + "\n");
      Comment("only on EURCHF or EURGPB M15." 
      + "\n");
      return (0);
   }
   gi_724 = VerifyKey(AccountCompany(), AccountNumber(), AccountName(), License_Key, TimeToStr(TimeCurrent(), TIME_DATE), gia_540, gia_544, gia_548, gia_552, gia_556, gia_560, gia_564, gia_568, gia_572, gia_576, gia_580, gia_584, gia_588, gia_592, gia_596, gia_600, gia_604, gia_608, gia_612, gia_616, gia_620, gia_624, gia_628, gia_632, gia_636, gia_640);
   if (gi_724 == 0) {
      Alert("Your EA is not activated. Please activate your copy." 
      + "\n");
      Comment("Your EA is not activated. Please activate your copy." 
      + "\n");
      return (0);
   }
   if (gi_724 == -1) {
      Alert("Your EA license has expired. Please renew your copy." 
      + "\n");
      Comment("Your EA license has expired. Please renew your copy." 
      + "\n");
      return (0);
   }
   gi_724 = VerifyKey2(AccountCompany(), AccountNumber(), AccountName(), License_Key, gda_644, gda_648, gda_652, gda_656, gda_660, gda_664, gda_668, gda_672, gda_676, gda_680, gda_684, gda_688, gda_692, gda_696, gda_700, gda_704, gda_708);
   g_datetime_508 = TimeCurrent();
   g_day_512 = TimeDay(g_datetime_508 - gia_540[0] * GMT_Offset);
   g_day_of_week_516 = TimeDayOfWeek(g_datetime_508 - gia_540[0] * GMT_Offset);
   g_hour_520 = TimeHour(g_datetime_508 - gia_540[0] * GMT_Offset);
   g_magic_224 = MagicNumber;
   g_magic_228 = g_magic_224 + 3;
   g_magic_232 = g_magic_228 + 3;
   g_magic_236 = g_magic_232 + 3;
   gd_524 = ReturnPoint(AccountCompany(), AccountNumber(), AccountName(), License_Key, MarketInfo(Symbol(), MODE_LOTSTEP), Point, Digits, gia_712, gia_716, gia_720);
   gi_504 = gia_712[0];
   g_slippage_532 = gia_716[0];
   g_slippage_536 = gia_720[0];
   if (Digits < 4) gi_728 = 2;
   else gi_728 = 4;
   gd_184 = gda_656[0];
   gi_152 = gia_548[0] - 10;
   gi_156 = gia_552[0];
   gi_160 = gia_608[0];
   gi_164 = gia_560[0];
   if (gs_496 == "EURCHFm" || gs_496 == "EURCHF" || gs_496 == "EURCHFFXF" || gs_496 == "EURCHF-fx" || gs_496 == "EURCHF.usd") {
      gd_168 = gia_544[0];
      gd_176 = gia_548[0];
      gi_156 = gia_552[0];
      if (SafeMode) gi_148 = gia_556[0];
      else gi_148 = gia_560[0];
   }
   if (gs_496 == "EURGBPm" || gs_496 == "EURGBP" || gs_496 == "EURGBPFXF" || gs_496 == "EURGBP-fx" || gs_496 == "EURGBP.usd") {
      gd_168 = gia_564[0];
      gd_176 = gia_568[0];
      gi_156 = gia_572[0];
      if (SafeMode) gi_148 = gia_576[0];
      else gi_148 = gia_580[0];
   }
   HideTestIndicators(TRUE);
   DisplayInfo();
   if (IsCloseTradeTime()) {
      ClosePosition();
      return (0);
   }
   if (IsRepositioningeTime()) Repositioning();
   g_price_432 = gd_184;
   g_price_440 = 0;
   for (int li_0 = 1; li_0 < Bars; li_0++) {
      if (iFractals(NULL, PERIOD_M15, MODE_UPPER, li_0) != 0.0) {
         g_ifractals_448 = iFractals(NULL, PERIOD_M15, MODE_UPPER, li_0);
         break;
      }
   }
   for (int li_4 = 1; li_4 < Bars; li_4++) {
      if (iFractals(NULL, PERIOD_M15, MODE_LOWER, li_4) != 0.0) {
         g_ifractals_456 = iFractals(NULL, PERIOD_M15, MODE_LOWER, li_4);
         break;
      }
   }
   for (int li_8 = 1; li_8 < Bars; li_8++) {
      if (iFractals(NULL, PERIOD_H1, MODE_UPPER, li_8) != 0.0) {
         g_ifractals_464 = iFractals(NULL, PERIOD_H1, MODE_UPPER, li_8);
         break;
      }
   }
   for (int li_12 = 1; li_12 < Bars; li_12++) {
      if (iFractals(NULL, PERIOD_H1, MODE_LOWER, li_12) != 0.0) {
         g_ifractals_472 = iFractals(NULL, PERIOD_H1, MODE_LOWER, li_12);
         break;
      }
   }
   gi_480 = MathRound((g_ifractals_448 - g_ifractals_456) / gd_524);
   gd_484 = 0;
   gd_484 = g_ifractals_448 - (g_ifractals_448 - g_ifractals_456) / 2.0;
   gi_492 = MathRound(iATR(Symbol(), PERIOD_M15, gia_584[0], 0) / gd_524);
   bool li_16 = FALSE;
   if (Close[0] <= g_ifractals_464 && Close[0] >= g_ifractals_472) li_16 = TRUE;
   g_count_292 = 0;
   g_count_296 = 0;
   g_count_300 = 0;
   g_count_304 = 0;
   g_count_308 = 0;
   gi_312 = 0.0;
   gi_316 = 0.0;
   gi_320 = 0.0;
   gi_324 = 0.0;
   gi_328 = 0.0;
   gi_332 = 0.0;
   gi_336 = 0.0;
   gi_340 = 0.0;
   gi_344 = 0.0;
   gi_348 = 0.0;
   g_ord_open_price_352 = 0.0;
   g_ord_open_price_360 = 0.0;
   g_ord_open_price_368 = 0.0;
   g_ord_open_price_376 = 0.0;
   g_ord_open_price_384 = 0.0;
   g_ord_open_price_392 = 0.0;
   g_ord_open_price_400 = 0.0;
   g_ord_open_price_408 = 0.0;
   g_ord_open_price_416 = 0.0;
   g_ord_open_price_424 = 0.0;
   for (int l_pos_20 = 0; l_pos_20 < OrdersTotal(); l_pos_20++) {
      OrderSelect(l_pos_20, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_224 || OrderMagicNumber() == g_magic_228 || OrderMagicNumber() == g_magic_232 || OrderMagicNumber() == g_magic_236) {
         g_count_292++;
         if (OrderType() == OP_BUY) {
            gi_332++;
            g_ord_open_price_392 = OrderOpenPrice();
         }
         if (OrderType() == OP_SELL) {
            gi_312++;
            g_ord_open_price_352 = OrderOpenPrice();
         }
      } else {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_224) {
            g_count_296++;
            if (OrderType() == OP_BUY) {
               gi_336++;
               g_ord_open_price_400 = OrderOpenPrice();
            }
            if (OrderType() == OP_SELL) {
               gi_316++;
               g_ord_open_price_360 = OrderOpenPrice();
            }
         } else {
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_228) {
               g_count_300++;
               if (OrderType() == OP_BUY) {
                  gi_340++;
                  g_ord_open_price_408 = OrderOpenPrice();
               }
               if (OrderType() == OP_SELL) {
                  gi_320++;
                  g_ord_open_price_368 = OrderOpenPrice();
               }
            } else {
               if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_232) {
                  g_count_304++;
                  if (OrderType() == OP_BUY) {
                     gi_344++;
                     g_ord_open_price_416 = OrderOpenPrice();
                  }
                  if (OrderType() == OP_SELL) {
                     gi_324++;
                     g_ord_open_price_376 = OrderOpenPrice();
                  }
               } else {
                  if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236) {
                     g_count_308++;
                     if (OrderType() == OP_BUY) {
                        gi_348++;
                        g_ord_open_price_424 = OrderOpenPrice();
                     }
                     if (OrderType() == OP_SELL) {
                        gi_328++;
                        g_ord_open_price_384 = OrderOpenPrice();
                     }
                  }
               }
            }
         }
      }
   }
   if (gi_192 == TRUE) {
      for (int l_pos_24 = 0; l_pos_24 < OrdersTotal(); l_pos_24++) {
         OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES);
         if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_224) {
            if (Bid >= OrderOpenPrice() + gd_184 * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Orange);
            }
         }
         if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_228) {
            if (Bid >= OrderOpenPrice() + (gd_184 - 2.0) * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Orange);
            }
         }
         if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_232) {
            if (Bid >= OrderOpenPrice() + (gd_184 - 1.0) * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Orange);
            }
         }
         if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_236) {
            if (Bid >= OrderOpenPrice() + (gd_184 - 2.0) * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Orange);
            }
         }
         if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_224) {
            if (Ask <= OrderOpenPrice() - gd_184 * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Orange);
            }
         }
         if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_228) {
            if (Ask <= OrderOpenPrice() - (gd_184 - 2.0) * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Orange);
            }
         }
         if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_232) {
            if (Ask <= OrderOpenPrice() - (gd_184 - 1.0) * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Orange);
            }
         }
         if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_236) {
            if (Ask <= OrderOpenPrice() - (gd_184 - 2.0) * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Orange);
            }
         }
      }
   }
   if (gi_200 == TRUE) {
      for (int l_pos_28 = 0; l_pos_28 < OrdersTotal(); l_pos_28++) {
         OrderSelect(l_pos_28, SELECT_BY_POS, MODE_TRADES);
         if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_224 || OrderMagicNumber() == g_magic_228 || OrderMagicNumber() == g_magic_232 || OrderMagicNumber() == g_magic_236) {
            if (TimeCurrent() - OrderOpenTime() > 60 * gia_588[0] && TimeCurrent() - OrderOpenTime() < 60 * gia_596[0] && Bid >= OrderOpenPrice() + gia_592[0] * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Orange);
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * gia_596[0] && TimeCurrent() - OrderOpenTime() < 60 * gia_604[0] && Bid >= OrderOpenPrice() + gia_600[0] * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Orange);
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * gia_604[0] && TimeCurrent() - OrderOpenTime() < 60 * gia_612[0] && Bid >= OrderOpenPrice() + gia_608[0] * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Orange);
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * gia_612[0] && TimeCurrent() - OrderOpenTime() < 60 * gia_620[0] && Bid >= OrderOpenPrice() - gia_616[0] * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Orange);
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * gia_620[0] && Bid >= OrderOpenPrice() - gia_624[0] * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Orange);
            }
            if (DayOfWeek() == 5 && Hour() >= 19) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Orange);
            }
         }
         if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_224 || OrderMagicNumber() == g_magic_228 || OrderMagicNumber() == g_magic_232 || OrderMagicNumber() == g_magic_236) {
            if (TimeCurrent() - OrderOpenTime() > 60 * gia_588[0] && TimeCurrent() - OrderOpenTime() < 60 * gia_596[0] && Ask <= OrderOpenPrice() - gia_592[0] * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Orange);
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * gia_596[0] && TimeCurrent() - OrderOpenTime() < 60 * gia_604[0] && Ask <= OrderOpenPrice() - gia_600[0] * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Orange);
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * gia_604[0] && TimeCurrent() - OrderOpenTime() < 60 * gia_612[0] && Ask <= OrderOpenPrice() - gia_608[0] * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Orange);
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * gia_612[0] && TimeCurrent() - OrderOpenTime() < 60 * gia_620[0] && Ask <= OrderOpenPrice() + gia_616[0] * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Orange);
            }
            if (TimeCurrent() - OrderOpenTime() > 60 * gia_620[0] && Ask <= OrderOpenPrice() + gia_624[0] * gd_524) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Orange);
            }
            if (DayOfWeek() == 5 && Hour() >= 19) {
               RefreshRates();
               OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Orange);
            }
         }
      }
   }
   if (gi_220 == TRUE) {
      if (iOpen(Symbol(), PERIOD_M5, 0) >= Ask + gda_644[0]) return;
      if (iOpen(Symbol(), PERIOD_M5, 0) <= Bid - gda_644[0]) return;
      if (iOpen(Symbol(), PERIOD_M5, 1) >= Ask + gda_648[0]) return;
      if (iOpen(Symbol(), PERIOD_M5, 1) <= Bid - gda_648[0]) return;
      if (iOpen(Symbol(), PERIOD_M5, 2) >= Ask + gda_652[0]) return;
      if (iOpen(Symbol(), PERIOD_M5, 2) <= Bid - gda_652[0]) return;
   }
   if (Ask - Bid > MaxSpread * gd_524) return (0);
   gd_276 = Fixed_Lots;
   if (AutoRiskMgmt) gd_276 = MoneyManagement(AccountCompany(), AccountNumber(), AccountName(), License_Key, AccountEquity(), AccountLeverage(), MarketInfo(Symbol(), MODE_MAXLOT), MarketInfo(Symbol(), MODE_MINLOT), Max_Lots, Risk_Percentage);
   g_lots_284 = NormalizeDouble(gd_276, gi_504);
   gi_272 = NormalizeDouble(gi_148 / 2, 0);
   double l_iclose_32 = iClose(Symbol(), PERIOD_M15, 0);
   double l_iopen_40 = iOpen(Symbol(), PERIOD_M15, 0);
   double l_ilow_48 = iLow(Symbol(), PERIOD_M15, 0);
   double l_ihigh_56 = iHigh(Symbol(), PERIOD_M15, 0);
   double l_irsi_64 = iRSI(NULL, PERIOD_M15, 6, PRICE_CLOSE, 0);
   double l_irsi_72 = iRSI(NULL, PERIOD_M1, 20, PRICE_CLOSE, 0);
   double ld_80 = NormalizeDouble(iMA(NULL, 0, 8, 0, MODE_SMA, PRICE_WEIGHTED, 1), 4);
   double ld_88 = NormalizeDouble(iMA(NULL, 0, 8, 0, MODE_SMA, PRICE_WEIGHTED, 1), 4);
   double l_icci_96 = iCCI(Symbol(), PERIOD_M15, 14, PRICE_CLOSE, 0);
   double l_icci_104 = iCCI(Symbol(), PERIOD_M5, 42, PRICE_CLOSE, 0);
   double l_icci_112 = iCCI(Symbol(), PERIOD_M1, 210, PRICE_CLOSE, 0);
   double l_icci_120 = iCCI(Symbol(), PERIOD_M1, 80, PRICE_CLOSE, 0);
   double l_imomentum_128 = iMomentum(Symbol(), PERIOD_M1, 60, PRICE_CLOSE, 0);
   double l_imomentum_136 = iMomentum(Symbol(), PERIOD_M5, 4, PRICE_CLOSE, 0);
   double l_imomentum_144 = iMomentum(Symbol(), PERIOD_M15, 14, PRICE_CLOSE, 0);
   double l_iwpr_152 = iWPR(Symbol(), PERIOD_M1, 14, 0);
   double l_iwpr_160 = iWPR(Symbol(), PERIOD_M5, 14, 0);
   double l_iwpr_168 = iWPR(Symbol(), PERIOD_M15, 14, 0);
   double l_iforce_176 = iForce(Symbol(), PERIOD_M5, 13, MODE_SMA, PRICE_CLOSE, 0);
   double l_ibands_184 = iBands(Symbol(), PERIOD_M5, 20, 2, 0, PRICE_WEIGHTED, MODE_UPPER, 1);
   double l_ibands_192 = iBands(Symbol(), PERIOD_M5, 20, 2, 0, PRICE_WEIGHTED, MODE_BASE, 1);
   double l_ibands_200 = iBands(Symbol(), PERIOD_M5, 20, 2, 0, PRICE_WEIGHTED, MODE_LOWER, 1);
   double l_ima_208 = iMA(Symbol(), PERIOD_M5, 1, 0, MODE_EMA, PRICE_HIGH, 0);
   double l_ima_216 = iMA(Symbol(), PERIOD_M5, 1, 0, MODE_EMA, PRICE_MEDIAN, 0);
   double l_ima_224 = iMA(Symbol(), PERIOD_M5, 1, 0, MODE_EMA, PRICE_LOW, 0);
   double l_ibands_232 = iBands(Symbol(), PERIOD_M5, 20, 2, 0, PRICE_WEIGHTED, MODE_UPPER, 0);
   double l_ibands_240 = iBands(Symbol(), PERIOD_M5, 20, 2, 0, PRICE_WEIGHTED, MODE_BASE, 0);
   double l_ibands_248 = iBands(Symbol(), PERIOD_M5, 20, 2, 0, PRICE_WEIGHTED, MODE_LOWER, 0);
   double l_ima_256 = iMA(Symbol(), PERIOD_M1, 1, 0, MODE_EMA, PRICE_HIGH, 0);
   double l_ima_264 = iMA(Symbol(), PERIOD_M1, 1, 0, MODE_EMA, PRICE_MEDIAN, 0);
   double l_ima_272 = iMA(Symbol(), PERIOD_M1, 1, 0, MODE_EMA, PRICE_LOW, 0);
   if (IsTradeTime() && g_count_292 < gi_148 && li_16) {
      if (!ExistPosition1() && gi_204 == TRUE) {
         if (g_day_of_week_516 == 0 || g_day_of_week_516 == 5 && g_hour_520 >= 14) return (0);
         if (l_irsi_64 < gda_660[0] || l_irsi_72 < gda_664[0] && ld_80 >= Ask + gda_668[0] * gd_524) {
            if (gi_336 < 1 && gi_240) {
               g_price_432 = 0;
               g_price_440 = 0;
               if (!gi_192) g_price_432 = Ask + gd_184 * gd_524;
               g_price_440 = Ask - gd_168 * gd_524;
               OrderSend(Symbol(), OP_BUY, g_lots_284, Ask, g_slippage_532, g_price_440, g_price_432, Order_Comment, g_magic_224, 0, Green);
               gi_240 = FALSE;
               gi_244 = TRUE;
            }
         }
         if (l_irsi_64 > gda_672[0] || l_irsi_72 > gda_676[0] && ld_88 <= Bid - gda_668[0] * gd_524) {
            if (gi_316 < 1 && gi_244) {
               g_price_432 = 0;
               g_price_440 = 0;
               if (!gi_192) g_price_432 = Bid - gd_184 * gd_524;
               g_price_440 = Bid + gd_168 * gd_524;
               OrderSend(Symbol(), OP_SELL, g_lots_284, Bid, g_slippage_532, g_price_440, g_price_432, Order_Comment, g_magic_224, 0, Red);
               gi_244 = FALSE;
               gi_240 = TRUE;
            }
         }
         if (l_irsi_64 < 60.0 && l_irsi_64 > 40.0) {
            gi_244 = TRUE;
            gi_240 = TRUE;
         }
      }
   }
   if (IsTradeTime() && gi_480 < gia_628[0] && gi_492 < gia_632[0] && g_count_292 < gi_148 && li_16) {
      if (!ExistPosition2() && gi_208 == TRUE) {
         if (g_day_of_week_516 == 0 || g_day_of_week_516 == 5 && g_hour_520 >= 14) return (0);
         if (l_icci_104 <= gda_680[0] && l_icci_112 <= gda_684[0] || l_icci_96 <= gda_680[0] && l_icci_112 <= gda_684[0] && Bid <= gd_484 - gia_636[0] * gd_524) {
            if (gi_340 < gi_272 && gi_248) {
               g_price_432 = 0;
               g_price_440 = 0;
               if (gi_192) g_price_432 = g_ifractals_448;
               g_price_440 = Ask - gd_168 * gd_524;
               OrderSend(Symbol(), OP_BUY, g_lots_284, Ask, g_slippage_532, g_price_440, g_price_432, Order_Comment, g_magic_228, 0, Green);
               gi_248 = FALSE;
               gi_252 = TRUE;
            }
         }
         if (l_icci_104 >= gda_688[0] && l_icci_112 >= gda_692[0] || l_icci_96 >= gda_688[0] && l_icci_112 >= gda_692[0] && Ask >= gd_484 + gia_636[0] * gd_524) {
            if (gi_320 < gi_272 && gi_252) {
               g_price_432 = 0;
               g_price_440 = 0;
               if (gi_192) g_price_432 = g_ifractals_456;
               g_price_440 = Bid + gd_168 * gd_524;
               OrderSend(Symbol(), OP_SELL, g_lots_284, Bid, g_slippage_532, g_price_440, g_price_432, Order_Comment, g_magic_228, 0, Red);
               gi_252 = FALSE;
               gi_248 = TRUE;
            }
         }
         if (l_icci_96 < gda_696[0] && l_icci_96 > gda_700[0]) {
            gi_252 = TRUE;
            gi_248 = TRUE;
         }
      }
      if (!ExistPosition3() && gi_212 == TRUE) {
         if (g_day_of_week_516 == 0 || g_day_of_week_516 == 5 && g_hour_520 >= 14) return (0);
         if (l_imomentum_136 >= gda_704[0] && l_icci_120 <= gda_708[0] && Bid <= gd_484 - gia_636[0] * gd_524) {
            if (gi_344 < gi_272 && gi_256) {
               g_price_432 = 0;
               g_price_440 = 0;
               if (gi_192) g_price_432 = g_ifractals_448;
               if (gi_196) g_price_440 = g_ifractals_456 - gd_168 * gd_524;
               else g_price_440 = Ask - gd_168 * gd_524;
               OrderSend(Symbol(), OP_BUY, g_lots_284, Ask, g_slippage_532, g_price_440, g_price_432, Order_Comment, g_magic_232, 0, Green);
               gi_256 = FALSE;
               gi_260 = TRUE;
            }
         }
         if (l_imomentum_136 <= 100.15 && l_icci_120 >= 200.0 && Ask >= gd_484 + gia_636[0] * gd_524) {
            if (gi_324 < gi_272 && gi_260) {
               g_price_432 = 0;
               g_price_440 = 0;
               if (gi_192) g_price_432 = g_ifractals_456;
               if (gi_196) g_price_440 = g_ifractals_448 + gd_168 * gd_524;
               else g_price_440 = Bid + gd_168 * gd_524;
               OrderSend(Symbol(), OP_SELL, g_lots_284, Bid, g_slippage_532, g_price_440, g_price_432, Order_Comment, g_magic_228, 0, Red);
               gi_260 = FALSE;
               gi_256 = TRUE;
            }
         }
         if (l_icci_120 >= gda_700[0] && l_icci_120 <= gda_696[0]) {
            gi_260 = TRUE;
            gi_256 = TRUE;
         }
      }
      if (!ExistPosition4() && gi_216 == TRUE) {
         if (g_day_of_week_516 == 0 || g_day_of_week_516 == 5 && g_hour_520 >= 14) return (0);
         if (l_iwpr_160 <= -90.0 && l_ima_224 < l_ibands_200 && Ask <= gd_484 - gia_636[0] * gd_524) {
            if (gi_348 < gi_272 && gi_264) {
               g_price_432 = 0;
               g_price_440 = 0;
               if (gi_192) g_price_432 = g_ifractals_448;
               if (gi_196) g_price_440 = Ask - gia_628[0] * gd_524;
               else g_price_440 = Ask - gd_168 * gd_524;
               OrderSend(Symbol(), OP_BUY, g_lots_284, Ask, g_slippage_532, g_price_440, g_price_432, Order_Comment, g_magic_236, 0, Green);
               gi_264 = FALSE;
               gi_268 = TRUE;
            }
         }
         if (l_iwpr_160 >= -10.0 && l_ima_208 > l_ibands_184 && Bid >= gd_484 + gia_636[0] * gd_524) {
            if (gi_328 < gi_272 && gi_268) {
               g_price_432 = 0;
               g_price_440 = 0;
               if (gi_192) g_price_432 = g_ifractals_456;
               if (gi_196) g_price_440 = Bid + gia_628[0] * gd_524;
               else g_price_440 = Bid + gd_168 * gd_524;
               OrderSend(Symbol(), OP_SELL, g_lots_284, Bid, g_slippage_532, g_price_440, g_price_432, Order_Comment, g_magic_228, 0, Red);
               gi_268 = FALSE;
               gi_264 = TRUE;
            }
         }
         if (l_irsi_64 < 60.0 && l_irsi_64 > 40.0) {
            gi_268 = TRUE;
            gi_264 = TRUE;
         }
      }
   }
   return (0);
}

int IsTradeTime() {
   int li_0 = gi_156;
   if (gi_152 < li_0 && g_hour_520 < gi_152 || g_hour_520 >= li_0) return (0);
   if (gi_152 > li_0 && (g_hour_520 < gi_152 && g_hour_520 >= li_0)) return (0);
   if (li_0 == 0) li_0 = 24;
   if (g_hour_520 == li_0 - 1 && Minute() >= gia_640[0]) return (0);
   return (1);
}

bool IsCloseTradeTime() {
   int li_0 = gi_164;
   if (gi_152 < li_0 && g_hour_520 < gi_152 || g_hour_520 > li_0) return (TRUE);
   if (gi_152 > li_0 && (g_hour_520 < gi_152 && g_hour_520 > li_0)) return (TRUE);
   if (li_0 == 0) li_0 = 24;
   if (g_hour_520 == li_0 && Minute() <= 5) return (TRUE);
   return (FALSE);
}

bool IsRepositioningeTime() {
   int li_0 = gi_160;
   if (gi_152 < li_0 && g_hour_520 < gi_152 || g_hour_520 > li_0) return (TRUE);
   if (gi_152 > li_0 && (g_hour_520 < gi_152 && g_hour_520 > li_0)) return (TRUE);
   if (li_0 == 0) li_0 = 24;
   if (g_hour_520 == li_0 && Minute() <= 5) return (TRUE);
   return (FALSE);
}

bool ExistPosition1() {
   bool li_ret_0 = FALSE;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_224) {
            if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
               li_ret_0 = TRUE;
               break;
            }
         }
      }
   }
   return (li_ret_0);
}

bool ExistPosition2() {
   bool li_ret_0 = FALSE;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_228) {
            if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
               li_ret_0 = TRUE;
               break;
            }
         }
      }
   }
   return (li_ret_0);
}

bool ExistPosition3() {
   bool li_ret_0 = FALSE;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_232) {
            if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
               li_ret_0 = TRUE;
               break;
            }
         }
      }
   }
   return (li_ret_0);
}

bool ExistPosition4() {
   bool li_ret_0 = FALSE;
   for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
      if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_236) {
            if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
               li_ret_0 = TRUE;
               break;
            }
         }
      }
   }
   return (li_ret_0);
}

void DisplayInfo() {
   Comment("" 
      + "\n" 
      + "Europe Waves" 
      + "\n" 
      + "Current Spread:          " + DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD) / MathPow(10, Digits - gi_728), Digits - gi_728) 
      + "\n" 
      + "MaxSpread:                " + DoubleToStr(MaxSpread, Digits - gi_728) 
      + "\n" 
      + "------------------------------------------------" 
      + "\n" 
      + "BROKER INFORMATION:" 
      + "\n" 
      + "Broker Company:      " + AccountCompany() 
      + "\n" 
      + "------------------------------------------------" 
      + "\n" 
      + "ACCOUNT INFORMATION:" 
      + "\n" 
      + "Account Name:          " + AccountName() 
      + "\n" 
      + "Account Number:       " + AccountNumber() 
      + "\n" 
      + "Account Leverage:     " + DoubleToStr(AccountLeverage(), 0) 
      + "\n" 
      + "Account Balance:       " + DoubleToStr(AccountBalance(), 2) 
      + "\n" 
      + "Account Currency:     " + AccountCurrency() 
      + "\n" 
      + "Account Equity:         " + DoubleToStr(AccountEquity(), 2) 
      + "\n" 
      + "------------------------------------------------" 
      + "\n" 
      + "MARGIN INFORMATION:" 
      + "\n" 
      + "Free Margin:              " + DoubleToStr(AccountFreeMargin(), 2) 
      + "\n" 
      + "Used Margin:              " + DoubleToStr(AccountMargin(), 2) 
      + "\n" 
      + "------------------------------------------------" 
      + "\n" 
      + "Actual Server Time:    " + TimeToStr(TimeCurrent(), TIME_SECONDS) 
      + "\n" 
      + "Licensed Till:               " + TimeToStr(D'31.12.2030 08:00', TIME_DATE) 
      + "\n" 
   + "------------------------------------------------");
}

void Repositioning() {
   int l_ord_total_0 = OrdersTotal();
   for (int l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) {
      OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      RefreshRates();
      if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_224 || OrderMagicNumber() == g_magic_228 || OrderMagicNumber() == g_magic_232 ||
         OrderMagicNumber() == g_magic_236) {
         if (OrderType() == OP_BUY && OrderProfit() < 0.0 && OrderOpenPrice() - Bid < (gd_176 - 5.0) * gd_524 && OrderOpenPrice() - OrderStopLoss() > 40.0 * gd_524) {
            while (!IsTradeAllowed()) Sleep(1000);
            OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice() - gd_176 * gd_524, Digits), OrderTakeProfit(), 0, Green);
         } else {
            if (OrderType() == OP_SELL && OrderProfit() < 0.0 && Ask - OrderOpenPrice() < (gd_176 - 5.0) * gd_524 && OrderStopLoss() - OrderOpenPrice() > 40.0 * gd_524) {
               while (!IsTradeAllowed()) Sleep(1000);
               OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice() + gd_176 * gd_524, Digits), OrderTakeProfit(), 0, Green);
            }
         }
      }
   }
}

void ClosePosition() {
   int l_ord_total_0 = OrdersTotal();
   for (int l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) {
      OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
      RefreshRates();
      if (OrderType() == OP_BUY || OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_224 || OrderMagicNumber() == g_magic_228 || OrderMagicNumber() == g_magic_232 ||
         OrderMagicNumber() == g_magic_236) {
         if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_536, Violet);
         if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_536, Violet);
      }
   }
}