/*
   Generated by EX4-TO-MQ4 decompiler V4.0.438.1 [-]
   Website: https://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "http://www.ea4u.info"
#property link      "http://www.ea4u.info"

extern int Parol = 17965;
extern bool IsECNBroker = TRUE;
extern double Lots = 0.01;
extern int TakeProfit = 50;
extern int StopLoss = 500;
extern bool ConstantStop = TRUE;
extern int Step1 = 50;
extern int TP1 = 50;
extern int Step2 = 50;
extern int TP2 = 50;
extern int Step3 = 50;
extern int TP3 = 50;
extern int Step4 = 50;
extern int TP4 = 50;
extern int Step5 = 100;
extern int TP5 = 80;
extern int Step6 = 100;
extern int TP6 = 80;
extern int Step7 = 100;
extern int TP7 = 80;
extern int Step8 = 50;
extern int TP8 = 50;
extern int Step9 = 50;
extern int TP9 = 50;
extern int Step10 = 50;
extern int TP10 = 50;
extern int Step11 = 50;
extern int TP11 = 50;
extern int Step12 = 50;
extern int TP12 = 50;
extern int Step13 = 50;
extern int TP13 = 50;
extern int Step14 = 50;
extern int TP14 = 50;
extern int Step15 = 50;
extern int TP15 = 50;
extern int Step16 = 50;
extern int TP16 = 50;
extern int Step17 = 50;
extern int TP17 = 50;
extern int Step18 = 50;
extern int TP18 = 50;
extern int Step19 = 50;
extern int TP19 = 50;
extern int Step20 = 50;
extern int TP20 = 50;
extern int Step21 = 50;
extern int TP21 = 50;
extern int Step22 = 50;
extern int TP22 = 50;
extern int Step23 = 50;
extern int TP23 = 50;
extern int Step24 = 50;
extern int TP24 = 50;
extern int Step25 = 50;
extern int TP25 = 50;
extern int Step_over25 = 50;
extern int TP_over25 = 50;
extern bool UseManualLot = TRUE;
extern double Lot01 = 0.02;
extern double Lot02 = 0.04;
extern double Lot03 = 0.08;
extern double Lot04 = 0.16;
extern double Lot05 = 0.32;
extern double Lot06 = 0.64;
extern double Lot07 = 1.28;
extern double Lot08 = 2.56;
extern double Lot09 = 2.57;
extern double Lot10 = 2.58;
extern double Lot11 = 2.59;
extern double Lot12 = 2.6;
extern double Lot13 = 2.61;
extern double Lot14 = 2.62;
extern double Lot15 = 2.63;
extern double Lot16 = 2.64;
extern double Lot17 = 2.65;
extern double Lot18 = 2.66;
extern double Lot19 = 2.67;
extern double Lot20 = 2.68;
extern double Lot21 = 2.69;
extern double Lot22 = 2.7;
extern double Lot23 = 2.71;
extern double Lot24 = 2.72;
extern double Lot25 = 2.73;
extern double Lot_over25 = 2.74;
int g_slippage_524 = 3;
int gi_528 = 2;
extern int StartHour = 0;
extern int EndHour = 24;
extern int Magic = 111;
int gi_544;

int init() {
   int digits_0 = MarketInfo(Symbol(), MODE_DIGITS);
   if (digits_0 == 2 || digits_0 == 4) gi_544 = 1;
   if (digits_0 == 3 || digits_0 == 5) gi_544 = 10;
   f0_3();
   return (0);
}

int start() {
   double price_0;
   double price_8;
   double price_16;
   double lots_24;
   double pips_32;
   double pips_40;
   int ticket_48;
   int ticket_52;
   int ticket_56;
   int ticket_60;
   int ticket_64;
   int ticket_68;
   int ticket_72;
   double order_lots_76;
   double order_lots_84;
   double order_open_price_92;
   double order_open_price_100;
   double ld_108;
   double ld_116;
   double order_lots_124;
   double order_lots_132;
   double order_lots_140;
   double order_lots_148;
   double ld_156;
   double ld_164;
   string ls_172;
   string ls_180;
   if (f0_0() != 0) {
      ticket_48 = 0;
      ticket_52 = 0;
      ticket_56 = 0;
      ticket_60 = 0;
      ticket_64 = 0;
      ticket_68 = 0;
      order_lots_76 = 0;
      order_lots_84 = 0;
      order_open_price_92 = 0;
      order_open_price_100 = 0;
      ld_108 = 0;
      ld_116 = 0;
      order_lots_124 = 0;
      order_lots_132 = 0;
      order_lots_140 = 0;
      order_lots_148 = 0;
      ld_156 = 0;
      ld_164 = 0;
      for (int pos_188 = 0; pos_188 < OrdersTotal(); pos_188++) {
         OrderSelect(pos_188, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) {
            if (OrderType() == OP_BUY && ticket_48 < OrderTicket()) {
               order_lots_76 = OrderLots();
               order_open_price_92 = OrderOpenPrice();
               ticket_48 = OrderTicket();
               ld_116 = OrderTakeProfit();
               ls_172 = OrderComment();
               if (OrderLots() == Lots) ld_156 = OrderOpenPrice() - StopLoss * Point;
            }
            if (OrderType() == OP_SELL && ticket_52 < OrderTicket()) {
               order_lots_84 = OrderLots();
               order_open_price_100 = OrderOpenPrice();
               ticket_52 = OrderTicket();
               ld_108 = OrderTakeProfit();
               ls_180 = OrderComment();
               if (OrderLots() == Lots) ld_164 = OrderOpenPrice() + StopLoss * Point;
            }
            if (OrderType() == OP_BUYLIMIT) {
               ticket_56 = OrderTicket();
               order_lots_140 = OrderLots();
            }
            if (OrderType() == OP_SELLLIMIT) {
               ticket_60 = OrderTicket();
               order_lots_148 = OrderLots();
            }
            if (OrderType() == OP_BUYSTOP) {
               ticket_64 = OrderTicket();
               order_lots_124 = OrderLots();
            }
            if (OrderType() == OP_SELLSTOP) {
               ticket_68 = OrderTicket();
               order_lots_132 = OrderLots();
            }
         }
      }
      if (ticket_48 == 0) {
         if (ticket_56 != 0) OrderDelete(ticket_56);
         if (ticket_64 != 0) OrderDelete(ticket_64);
         price_8 = Ask - StopLoss * Point;
         if (StopLoss <= 0) price_8 = 0;
         price_16 = Ask + TakeProfit * Point;
         if (TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) {
            if (!IsECNBroker) OrderSend(Symbol(), OP_BUY, Lots, Ask, g_slippage_524, price_8, price_16, "00", Magic, 0, CLR_NONE);
            else {
               ticket_72 = OrderSend(Symbol(), OP_BUY, Lots, Ask, g_slippage_524, 0, 0, "00", Magic, 0, CLR_NONE);
               if (ticket_72 > 0) {
                  OrderSelect(ticket_72, SELECT_BY_TICKET);
                  OrderModify(OrderTicket(), OrderOpenPrice(), price_8, price_16, 0, Black);
               }
            }
         }
      }
      if (ticket_52 == 0) {
         if (ticket_60 != 0) OrderDelete(ticket_60);
         if (ticket_68 != 0) OrderDelete(ticket_68);
         price_8 = Bid + StopLoss * Point;
         if (StopLoss <= 0) price_8 = 0;
         price_16 = Bid - TakeProfit * Point;
         if (TimeHour(TimeCurrent()) >= StartHour && TimeHour(TimeCurrent()) < EndHour) {
            if (!IsECNBroker) OrderSend(Symbol(), OP_SELL, Lots, Bid, g_slippage_524, price_8, price_16, "00", Magic, 0, CLR_NONE);
            else {
               ticket_72 = OrderSend(Symbol(), OP_SELL, Lots, Bid, g_slippage_524, 0, 0, "00", Magic, 0, CLR_NONE);
               if (ticket_72 > 0) {
                  OrderSelect(ticket_72, SELECT_BY_TICKET);
                  OrderModify(OrderTicket(), OrderOpenPrice(), price_8, price_16, 0, Black);
               }
            }
         }
      }
      if (ticket_48 != 0 && ticket_56 == 0) {
         pips_40 = f0_2(ls_172);
         pips_32 = f0_1(ls_172);
         price_0 = order_open_price_92 - pips_40 * Point;
         if (ConstantStop == FALSE) price_8 = price_0 - StopLoss * Point;
         else price_8 = ld_156;
         if (StopLoss <= 0) price_8 = 0;
         price_16 = price_0 + pips_32 * Point;
         if (UseManualLot) lots_24 = NormalizeDouble(f0_4(ls_172), gi_528);
         else lots_24 = NormalizeDouble(2.0 * order_lots_76, gi_528);
         OrderSend(Symbol(), OP_BUYLIMIT, lots_24, price_0, g_slippage_524, price_8, price_16, f0_5(ls_172), Magic, 0, CLR_NONE);
      }
      if (ticket_52 != 0 && ticket_60 == 0) {
         pips_40 = f0_2(ls_180);
         pips_32 = f0_1(ls_180);
         price_0 = order_open_price_100 + pips_40 * Point;
         if (ConstantStop == FALSE) price_8 = price_0 + StopLoss * Point;
         else price_8 = ld_164;
         if (StopLoss <= 0) price_8 = 0;
         price_16 = price_0 - pips_32 * Point;
         if (UseManualLot) lots_24 = NormalizeDouble(f0_4(ls_180), gi_528);
         else lots_24 = NormalizeDouble(2.0 * order_lots_84, gi_528);
         OrderSend(Symbol(), OP_SELLLIMIT, lots_24, price_0, g_slippage_524, price_8, price_16, f0_5(ls_180), Magic, 0, CLR_NONE);
      }
      for (pos_188 = 0; pos_188 < OrdersTotal(); pos_188++) {
         OrderSelect(pos_188, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() == Symbol() && OrderType() == OP_BUY && ticket_48 != 0 && OrderMagicNumber() == Magic) {
            if (ConstantStop == FALSE) price_8 = order_open_price_92 - StopLoss * Point;
            else price_8 = ld_156;
            if (StopLoss <= 0) price_8 = 0;
            if (ticket_48 != OrderTicket()) price_16 = ld_116;
            else price_16 = OrderTakeProfit();
            if (price_16 != OrderTakeProfit() || price_8 != OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), price_8, price_16, 0, CLR_NONE);
         }
         if (OrderSymbol() == Symbol() && OrderType() == OP_SELL && ticket_52 != 0 && OrderMagicNumber() == Magic) {
            if (ConstantStop == FALSE) price_8 = order_open_price_100 + StopLoss * Point;
            else price_8 = ld_164;
            if (StopLoss <= 0) price_8 = 0;
            if (ticket_52 != OrderTicket()) price_16 = ld_108;
            else price_16 = OrderTakeProfit();
            if (price_16 != OrderTakeProfit() || price_8 != OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), price_8, price_16, 0, CLR_NONE);
         }
      }
   }
   return (0);
}

int f0_2(string as_0) {
   if (as_0 == "00") return (Step1);
   if (as_0 == "01") return (Step2);
   if (as_0 == "02") return (Step3);
   if (as_0 == "03") return (Step4);
   if (as_0 == "04") return (Step5);
   if (as_0 == "05") return (Step6);
   if (as_0 == "06") return (Step7);
   if (as_0 == "07") return (Step8);
   if (as_0 == "08") return (Step9);
   if (as_0 == "09") return (Step10);
   if (as_0 == "10") return (Step11);
   if (as_0 == "11") return (Step12);
   if (as_0 == "12") return (Step13);
   if (as_0 == "13") return (Step14);
   if (as_0 == "14") return (Step15);
   if (as_0 == "15") return (Step16);
   if (as_0 == "16") return (Step17);
   if (as_0 == "17") return (Step18);
   if (as_0 == "18") return (Step19);
   if (as_0 == "19") return (Step20);
   if (as_0 == "20") return (Step21);
   if (as_0 == "21") return (Step22);
   if (as_0 == "22") return (Step23);
   if (as_0 == "23") return (Step24);
   if (as_0 == "24") return (Step25);
   return (Step_over25);
}

int f0_1(string as_0) {
   if (as_0 == "00") return (TP1);
   if (as_0 == "01") return (TP2);
   if (as_0 == "02") return (TP3);
   if (as_0 == "03") return (TP4);
   if (as_0 == "04") return (TP5);
   if (as_0 == "05") return (TP6);
   if (as_0 == "06") return (TP7);
   if (as_0 == "07") return (TP8);
   if (as_0 == "08") return (TP9);
   if (as_0 == "09") return (TP10);
   if (as_0 == "10") return (TP11);
   if (as_0 == "11") return (TP12);
   if (as_0 == "12") return (TP13);
   if (as_0 == "13") return (TP14);
   if (as_0 == "14") return (TP15);
   if (as_0 == "15") return (TP16);
   if (as_0 == "16") return (TP17);
   if (as_0 == "17") return (TP18);
   if (as_0 == "18") return (TP19);
   if (as_0 == "19") return (TP20);
   if (as_0 == "20") return (TP21);
   if (as_0 == "21") return (TP22);
   if (as_0 == "22") return (TP23);
   if (as_0 == "23") return (TP24);
   if (as_0 == "24") return (TP25);
   return (TP_over25);
}

double f0_4(string as_0) {
   if (as_0 == "00") return (Lot01);
   if (as_0 == "01") return (Lot02);
   if (as_0 == "02") return (Lot03);
   if (as_0 == "03") return (Lot04);
   if (as_0 == "04") return (Lot05);
   if (as_0 == "05") return (Lot06);
   if (as_0 == "06") return (Lot07);
   if (as_0 == "07") return (Lot08);
   if (as_0 == "08") return (Lot09);
   if (as_0 == "09") return (Lot10);
   if (as_0 == "10") return (Lot11);
   if (as_0 == "11") return (Lot12);
   if (as_0 == "12") return (Lot13);
   if (as_0 == "13") return (Lot14);
   if (as_0 == "14") return (Lot15);
   if (as_0 == "15") return (Lot16);
   if (as_0 == "16") return (Lot17);
   if (as_0 == "17") return (Lot18);
   if (as_0 == "18") return (Lot19);
   if (as_0 == "19") return (Lot20);
   if (as_0 == "20") return (Lot21);
   if (as_0 == "21") return (Lot22);
   if (as_0 == "22") return (Lot23);
   if (as_0 == "23") return (Lot24);
   if (as_0 == "24") return (Lot25);
   return (Lot_over25);
}

string f0_5(string as_0) {
   if (as_0 == "00") return ("01");
   if (as_0 == "01") return ("02");
   if (as_0 == "02") return ("03");
   if (as_0 == "03") return ("04");
   if (as_0 == "04") return ("05");
   if (as_0 == "05") return ("06");
   if (as_0 == "06") return ("07");
   if (as_0 == "07") return ("08");
   if (as_0 == "08") return ("09");
   if (as_0 == "09") return ("10");
   if (as_0 == "10") return ("11");
   if (as_0 == "11") return ("12");
   if (as_0 == "12") return ("13");
   if (as_0 == "13") return ("14");
   if (as_0 == "14") return ("15");
   if (as_0 == "15") return ("16");
   if (as_0 == "16") return ("17");
   if (as_0 == "17") return ("18");
   if (as_0 == "18") return ("19");
   if (as_0 == "19") return ("20");
   if (as_0 == "20") return ("21");
   if (as_0 == "21") return ("22");
   if (as_0 == "22") return ("23");
   if (as_0 == "23") return ("24");
   if (as_0 == "24") return ("25");
   return ("25");
}

void f0_3() {
   TakeProfit *= gi_544;
   StopLoss *= gi_544;
   Step1 *= gi_544;
   TP1 *= gi_544;
   Step2 *= gi_544;
   TP2 *= gi_544;
   Step3 *= gi_544;
   TP3 *= gi_544;
   Step4 *= gi_544;
   TP4 *= gi_544;
   Step5 *= gi_544;
   TP5 *= gi_544;
   Step6 *= gi_544;
   TP6 *= gi_544;
   Step7 *= gi_544;
   TP7 *= gi_544;
   Step8 *= gi_544;
   TP8 *= gi_544;
   Step9 *= gi_544;
   TP9 *= gi_544;
   Step10 *= gi_544;
   TP10 *= gi_544;
   Step11 *= gi_544;
   TP11 *= gi_544;
   Step12 *= gi_544;
   TP12 *= gi_544;
   Step13 *= gi_544;
   TP13 *= gi_544;
   Step14 *= gi_544;
   TP14 *= gi_544;
   Step15 *= gi_544;
   TP15 *= gi_544;
   Step16 *= gi_544;
   TP16 *= gi_544;
   Step17 *= gi_544;
   TP17 *= gi_544;
   Step18 *= gi_544;
   TP18 *= gi_544;
   Step19 *= gi_544;
   TP19 *= gi_544;
   Step20 *= gi_544;
   TP20 *= gi_544;
   Step21 *= gi_544;
   TP21 *= gi_544;
   Step22 *= gi_544;
   TP22 *= gi_544;
   Step23 *= gi_544;
   TP23 *= gi_544;
   Step24 *= gi_544;
   TP24 *= gi_544;
   Step25 *= gi_544;
   TP25 = Step25 * gi_544;
   Step_over25 *= gi_544;
   TP_over25 *= gi_544;
   g_slippage_524 *= gi_544;
}

int f0_0() {
   return (1);
   /*
   if (IsDemo() == TRUE) return (1);
   if (AccountCompany() == "EA4U Software Corp") return (1);
   int li_0 = AccountNumber() * 2 + 1000101;
   if (Parol == li_0) return (1);
   Alert("Demo version just for demo account.");
   return (0);*/
}