Navigation:Home > Content >

IrisFx_EA_v0.1.mq4

Time: 2010-11-25 | Download file:IrisFx_EA_v0.1.mq4

#import "IrisFx.dll"
   int InitDll(int a0);
   double Proc1(int a0, int a1, double a2, double a3, int a4, int a5, double a6, double a7, double a8, double a9);
   double Proc2(int a0, int a1, double a2, double a3, int a4, int a5, double a6, double a7, double a8, double a9);
   double Proc3(double a0, double a1, int a2, int a3, double a4, int a5, int a6, int a7, int a8, int a9, double a10, double a11, double a12, double a13);
   double Proc4(double a0, double a1, int a2, int a3, double a4, int a5, int a6, int a7, int a8, int a9, double a10, double a11, double a12, double a13);
#import

extern string Strategy1 = "EURUSD_H1";
extern string Strategy2 = "EURUSD_H1";
extern string Strategy3 = "EURUSD_H4";
extern int strategy = 1;
extern double lot_percent = 10.0;
extern double lot_fixed = 0.0;
extern bool show_orders = TRUE;
bool gbool124 = FALSE;
datetime gtime_128;
double gihigh_132;
double gilow_140;
double gprice_148;
double gprice_156;
double gprice_164;
double gprice_172;
double gprice_180;
double gprice_188;
double gticksize_196;
double gd_204;
double glots_212;
double glots_220;
double gmarginrequired_228;
double gtickvalue_236;
double gd_244;
double gd_252;
double gd_260;
double gd_268;
int gspread_276;
int gi280;
int gi284;
int giunused_288;
int gi292;
int giunused_296;
double gihigh_300;
double gilow_308;
int gdatetime_316;
int gdatetime_320;
int gi324;
int gi328;
bool gi332 = TRUE;
bool gi336 = FALSE;
double gd_340;
int gdatetime_348;
bool gi352 = TRUE;
bool gi356 = TRUE;
bool gi360 = TRUE;
bool gi364 = TRUE;
bool gi368 = TRUE;
bool gi372 = TRUE;
bool gi376 = TRUE;
int gticket_380;
int gticket_384;
double gord_open_price_388;
double gord_open_price_396;
double gbid_404;
datetime gtime_412;
double giao_416;
double giao_424;
double gialligator_432;
double gialligator_440;
double gialligator_448;
double gprice_456;
double gprice_464;
double gprice_472;
double gprice_480;
double gprice_488;
double gprice_496;
double gticksize_504;
double gd_512;
double glots_520;
double glots_528;
double gmarginrequired_536;
double gtickvalue_544;
double ghigh_552;
double glow_560;
double ghigh_568;
double glow_576;
int gspread_584;
int gi588;
int gi592;
int giunused_596;
int gi600;
int giunused_604;
int gi608;
int gi612;
int gi616;
int gi620;
datetime gtime_624;
datetime gtime_628;
bool gi632 = TRUE;
bool gi636 = FALSE;
double gd_640;
int gdatetime_648;
bool gi652 = TRUE;
bool gi656 = TRUE;
bool gi660 = TRUE;
bool gi664 = TRUE;
bool gi668 = TRUE;
int gticket_672;
int gticket_676;
datetime gtime_680;
double giao_684;
double giao_692;
double gialligator_700;
double gialligator_708;
double gialligator_716;
double gprice_724;
double gprice_732;
double gprice_740;
double gprice_748;
double gprice_756;
double gprice_764;
double gticksize_772;
double gd_780;
double glots_788;
double glots_796;
double gmarginrequired_804;
double gtickvalue_812;
double ghigh_820;
double glow_828;
double ghigh_836;
double glow_844;
int gspread_852;
int gi856;
int gi860;
int giunused_864;
int gi868;
int giunused_872;
int gi876;
int gi880;
int gi884;
int gi888;
datetime gtime_892;
datetime gtime_896;
bool gi900 = TRUE;
bool gi904 = FALSE;
double gd_908;
int gdatetime_916;
bool gi920 = TRUE;
bool gi924 = TRUE;
bool gi928 = TRUE;
bool gi932 = TRUE;
bool gi936 = TRUE;
int gticket_940;
int gticket_944;
int LotDecimal = 1;

int init() {
   gbool124 = InitDll(WindowHandle(Symbol(), Period())) == 1;
   //if (!gbool124) Alert("IrisFx can\'t run on this account#");
   if (MarketInfo(Symbol(),MODE_MINLOT)<0.1) LotDecimal=2;
   else if (MarketInfo(Symbol(),MODE_MINLOT)>=1.0) LotDecimal=0;
   return (0);
}

int start() {
   //if (!gbool124) return (0);
   if (strategy > 3 || strategy <= 0) Alert("Strategy should be = either 1, 2 or 3");
   if (strategy == 1) {
      func1();
      return/*(WARN)*/;
   }
   if (strategy == 2) {
      func2();
      return/*(WARN)*/;
   }
   if (strategy == 3) {
      func3();
      return/*(WARN)*/;
   }
}

void func1() {
   int li184;
   int li188;
   double lprice_252;
   double lprice_260;
   double ld_0 = lot_percent / 10000.0;
   double ld_8 = lot_fixed;
   double ld_16 = 12;
   double ld_24 = 20;
   double ld_32 = 75;
   bool li40 = TRUE;
   bool li44 = TRUE;
   bool li48 = TRUE;
   bool li52 = FALSE;
   bool li56 = FALSE;
   int li60 = 75;
   bool li64 = TRUE;
   int li68 = 45;
   bool li72 = TRUE;
   bool li76 = TRUE;
   bool li80 = TRUE;
   bool li84 = FALSE;
   int li88 = 20;
   int li92 = 180;
   double ld_96 = 1;
   double lpips_104 = 1;
   int li112 = 2;
   int li116 = 0;
   int li120 = 0;
   bool li124 = FALSE;
   bool li128 = true;
   bool li132 = FALSE;
   int lmagic_136 = 777;
   int li140 = 1;
   if (ld_16 < 1.0 || ld_32 < 1.0) {
      Print("stop level below the requested soluble");
      return;
   }
   bool li144 = FALSE;
   if (gtime_128 == 0) gtime_128 = Time[0];
   if (gtime_128 != Time[0]) {
      li144 = TRUE;
      gtime_128 = Time[0];
   }
   gihigh_300 = iHigh(NULL, PERIOD_D1, 1);
   gilow_308 = iLow(NULL, PERIOD_D1, 1);
   if (DayOfWeek() == 1) {
      if (li144) Print("Today is Monday");
      for (int li148 = 1; li148 < 7; li148++) {
         if (TimeDayOfWeek(iTime(NULL, PERIOD_D1, li148)) == 5) {
            gihigh_300 = iHigh(NULL, PERIOD_D1, li148);
            gilow_308 = iLow(NULL, PERIOD_D1, li148);
            if (!(li144)) break;
            Print("Maximum price on Friday is ", DoubleToStr(gihigh_300, Digits));
            Print("Minimum price on Friday is ", DoubleToStr(gilow_308, Digits));
            break;
         }
      }
   }
   bool li152 = TRUE;
   bool li156 = TRUE;
   gihigh_132 = iHigh(NULL, PERIOD_D1, 0);
   gilow_140 = iLow(NULL, PERIOD_D1, 0);
   if (gihigh_132 - gihigh_300 >= li88 * Point || gihigh_132 < gihigh_300 || li84 == FALSE) li152 = FALSE;
   if (gilow_308 - gilow_140 >= li88 * Point || gilow_140 > gilow_308 || li84 == FALSE) li156 = FALSE;
   int lstoplevel160 = MarketInfo(Symbol(), MODE_STOPLEVEL);
   if (lstoplevel160 < 20 && Digits == 5) lstoplevel160 = 20;
   if (lstoplevel160 < 2 && Digits == 4) lstoplevel160 = 2;
   if (li152 || li156 || li144 || gihigh_132 == 0.0 || gilow_140 == 0.0 || glots_212 == 0.0 || glots_220 == 0.0 || gprice_148 == 0.0 || gprice_156 == 0.0 || gprice_164 == 0.0 ||
      gprice_172 == 0.0 || gprice_180 == 0.0 || gprice_188 == 0.0 || gticksize_196 == 0.0 || gd_204 == 0.0) {
      gspread_276 = MarketInfo(Symbol(), MODE_SPREAD);
      if (li128) Print("spread = ", gspread_276, " ", Symbol());
      gticksize_196 = MarketInfo(Symbol(), MODE_TICKSIZE);
      gtickvalue_236 = MarketInfo(Symbol(), MODE_TICKVALUE);
      gmarginrequired_228 = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
      if (Digits == 5) {
         gd_204 = 10.0 * gticksize_196;
         gi280 = 4;
      } else gd_204 = gticksize_196;
      for (int li164 = 3; li164 < 100; li164++) {
         if (High[li164] >= High[li164 + 1] && High[li164] > High[li164 + 2] && High[li164] >= High[li164 - 1] && High[li164] > High[li164 - 2]) {
            gd_244 = NormalizeDouble(High[li164], Digits);
            gi284 = li164;
            break;
         }
      }
      for (li164 = gi284 + 1; li164 < 100; li164++) {
         if (High[li164] >= High[li164 + 1] && High[li164] > High[li164 + 2] && High[li164] >= High[li164 - 1] && High[li164] > High[li164 - 2]) {
            gd_260 = NormalizeDouble(High[li164], Digits);
            giunused_288 = li164;
            break;
         }
      }
      for (li164 = 3; li164 < 100; li164++) {
         if (Low[li164] <= Low[li164 + 1] && Low[li164] < Low[li164 + 2] && Low[li164] <= Low[li164 - 1] && Low[li164] < Low[li164 - 2]) {
            gd_252 = NormalizeDouble(Low[li164], Digits);
            gi292 = li164;
            break;
         }
      }
      for (li164 = gi292 + 1; li164 < 100; li164++) {
         if (Low[li164] <= Low[li164 + 1] && Low[li164] < Low[li164 + 2] && Low[li164] <= Low[li164 - 1] && Low[li164] < Low[li164 - 2]) {
            gd_268 = NormalizeDouble(Low[li164], Digits);
            giunused_296 = li164;
            break;
         }
      }
      for (int li168 = 1; li168 < 150; li168++) {
         if (NormalizeDouble(iHigh(NULL, PERIOD_H1, li168), gi280) == NormalizeDouble(gihigh_300, gi280) && DayOfWeek() != TimeDayOfWeek(iTime(NULL, PERIOD_H1, li168))) {
            gdatetime_316 = iTime(NULL, PERIOD_H1, li168);
            gi324 = li168;
            break;
         }
      }
      for (li168 = 1; li168 < 150; li168++) {
         if (NormalizeDouble(iLow(NULL, PERIOD_H1, li168), gi280) == NormalizeDouble(gilow_308, gi280) && DayOfWeek() != TimeDayOfWeek(iTime(NULL, PERIOD_H1, li168))) {
            gdatetime_320 = iTime(NULL, PERIOD_H1, li168);
            gi328 = li168;
            break;
         }
      }
      if (li128) Print("time_high = ", TimeHour(gdatetime_316), " time_low= ", TimeHour(gdatetime_320));
      if (li128) Print("bar_high = ", gi324, " bar_low= ", gi328);
      if (li128) Print("high_yesterday = ", DoubleToStr(gihigh_300, Digits), " low_yesterday= ", DoubleToStr(gilow_308, Digits));
      if (li152) gprice_148=NormalizeDouble((gspread_276+li140)*Point+gihigh_132,Digits);
      else gprice_148=NormalizeDouble((gspread_276+li140)*Point+gihigh_300,Digits);
      //gprice_148 = NormalizeDouble(Proc1(li152, li156, gihigh_300, gihigh_132, gspread_276, li140, Point, ld_16, gilow_308, gilow_140), Digits);
      if (li128) Print("PRICE_BUY = ", gprice_148, " high_day= ", DoubleToStr(gihigh_132, Digits), " ", Symbol());
      if (li112 == 1) {
         gprice_180 = NormalizeDouble(gprice_148 - ld_16 * lstoplevel160 * Point, Digits);
         if (li128) Print("SlBUY = ", gprice_180, " ", Symbol());
      }
      if (li112 == 2) {
         gprice_180 = NormalizeDouble(Low[iLowest(NULL, 0, MODE_LOW, 2, 0)] - gd_204, Digits);
         if ((gprice_148 - gprice_180) / Point > ld_24 * lstoplevel160) gprice_180 = NormalizeDouble(gprice_148 - ld_24 * lstoplevel160 * Point, Digits);
      }
      if (li112 == 3) {
         gprice_180 = NormalizeDouble(MathMin(gd_268, gd_252) - gd_204, Digits);
         if ((gprice_148 - gprice_180) / Point > ld_24 * lstoplevel160) gprice_180 = NormalizeDouble(gprice_148 - ld_24 * lstoplevel160 * Point, Digits);
      }
      if (li128) Print("SlBUY = ", gprice_180, " ", Symbol());
      gprice_164 = NormalizeDouble(gprice_148 + ld_32 * lstoplevel160 * Point, Digits);
      if (li128) Print("TP_BUY = ", gprice_164, " ", Symbol());
      if (li156) gprice_156=NormalizeDouble(gilow_140-(gspread_276)*Point,Digits);
      else gprice_156=NormalizeDouble(gilow_308-(gspread_276)*Point,Digits);
      //gprice_156 = NormalizeDouble(Proc2(li152, li156, gihigh_300, gihigh_132, gspread_276, li140, Point, ld_16, gilow_308, gilow_140), Digits);
      if (li128) Print("PRICE_SELL = ", gprice_156, " low_day= ", DoubleToStr(gilow_140, Digits), " ", Symbol());
      if (li112 == 1) gprice_188 = NormalizeDouble(gprice_156 + (ld_16 * lstoplevel160 + gspread_276) * Point, Digits);
      if (li112 == 2) {
         gprice_188 = NormalizeDouble(High[iHighest(NULL, 0, MODE_HIGH, 2, 0)] + gspread_276 * Point + gd_204, Digits);
         if ((gprice_188 - gprice_156) / Point > ld_24 * lstoplevel160) gprice_188 = NormalizeDouble(gprice_156 + (ld_24 * lstoplevel160 + gspread_276) * Point, Digits);
      }
      if (li112 == 3) {
         gprice_188 = NormalizeDouble(MathMax(gd_244, gd_260) + gspread_276 * Point + gd_204, Digits);
         if ((gprice_188 - gprice_156) / Point > ld_24 * lstoplevel160) gprice_188 = NormalizeDouble(gprice_156 + (ld_24 * lstoplevel160 + gspread_276) * Point, Digits);
      }
      if (li128) Print("SlSELL = ", gprice_188, " ", Symbol());
      gprice_172 = NormalizeDouble(gprice_156 - ld_32 * lstoplevel160 * Point, Digits);
      if (li128) Print("TP_SELL = ", gprice_172, " ", Symbol());
      glots_220 = GetLots(gprice_148,gprice_180);//0.1;
      glots_212 = GetLots(gprice_156,gprice_188);//0.1;
      /*if (AccountBalance() > 500.0) {
         glots_220 = NormalizeDouble(AccountBalance() * ld_0, LotDecimal);
         glots_212 = NormalizeDouble(AccountBalance() * ld_0, LotDecimal);
         for (li148 = OrdersHistoryTotal() - 1; li148 >= 0; li148--) {
            if (OrderSelect(li148, SELECT_BY_POS, MODE_HISTORY) == FALSE) break;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_136) {
               if (OrderLots() <= NormalizeDouble(AccountBalance() * ld_0,LotDecimal)) {
                  glots_220 = NormalizeDouble(AccountBalance() * ld_0, LotDecimal);
                  glots_212 = NormalizeDouble(AccountBalance() * ld_0, LotDecimal);
                  break;
               }
               glots_220 = NormalizeDouble(OrderLots(), LotDecimal);
               glots_212 = NormalizeDouble(OrderLots(), LotDecimal);
               break;
            }
         }
      }
      if (ld_8 > 0.0) {
         glots_220 = NormalizeDouble(ld_8, LotDecimal);
         glots_212 = NormalizeDouble(ld_8, LotDecimal);
      }
      if (glots_220 > NormalizeDouble(AccountFreeMargin() / (1.05 * gmarginrequired_228), LotDecimal) || glots_212 > NormalizeDouble(AccountFreeMargin() / (1.05 * gmarginrequired_228), LotDecimal)) {
         glots_220 = NormalizeDouble(AccountFreeMargin() / (1.05 * gmarginrequired_228), LotDecimal);
         glots_212 = NormalizeDouble(AccountFreeMargin() / (1.05 * gmarginrequired_228), LotDecimal);
      }*/
   }
   bool li172 = TRUE;
   /*if (AccountFreeMargin() < MarketInfo(Symbol(), MODE_MARGINREQUIRED) / 10.0) {
      li172 = FALSE;
      Print("No money");
   }*/
   int li176 = 15;
   if (li144) gi352 = TRUE;
   if (MathAbs((gd_340 - Close[0]) / Point) > li60 && gd_340 != 0.0 && li56) {
      gi336 = TRUE;
      gdatetime_348 = TimeCurrent();
      if (gi352 == TRUE) {
         if (li128) Print("The price shock for ", (gd_340 - Close[0]) / Point, " pips.", Symbol());
         if (li128) Print("last_price ", DoubleToStr(gd_340, Digits), ", curent_price ", DoubleToStr(Close[0], Digits));
         gi352 = FALSE;
      }
   }
   gd_340 = Close[0];
   bool li180 = TRUE;
   if (li116 != 0) {
      li184 = 60 * li116 + li120;
      li188 = 60 * TimeHour(TimeCurrent()) + TimeMinute(TimeCurrent());
      if (li184 - li188 <= 20 && li188 - li184 <= 15) li180 = FALSE;
   }
   if (li144) gi356 = TRUE;
   if (li180 == TRUE) {
      if (DayOfWeek() == 5 && TimeCurrent() - iTime(NULL, PERIOD_D1, 0) > 79200) {
         li180 = FALSE;
         if (gi356 == TRUE) {
            if (li128) Print("Friday, ending trading.");
            gi356 = FALSE;
         }
      }
   }
   if (li144) gi360 = TRUE;
   if (li180 == TRUE) {
      if (DayOfWeek() == 1 && TimeCurrent() - iTime(NULL, PERIOD_D1, 0) < 3900) {
         li180 = FALSE;
         if (gi360 == TRUE) {
            if (li128) Print("Monday, prior to 1-00 in the morning do not trade. Or off.");
            gi360 = FALSE;
         }
      }
   }
   if (li144) gi364 = TRUE;
   bool li192 = TRUE;
   if ((TimeHour(TimeCurrent()) <= 2 && gi324 <= 8) || TimeHour(gdatetime_316) == 0) {
      li192 = FALSE;
      if (gi364 == TRUE) {
         if (li128) Print("Нет 8 баров до экстремума. Не торгуем.");
         gi364 = FALSE;
      }
   }
   if (li144) gi368 = TRUE;
   bool li196 = TRUE;
   if ((TimeHour(TimeCurrent()) <= 2 && gi328 <= 8) || TimeHour(gdatetime_320) == 0) {
      li196 = FALSE;
      if (gi368 == TRUE) {
         if (li128) Print("Нет 8 баров до экстремума. Не торгуем.");
         gi368 = FALSE;
      }
   }
   if (li144) gi372 = TRUE;
   bool li200 = TRUE;
   if (lstoplevel160 > 50) {
      li200 = FALSE;
      if (gi372 == TRUE) {
         if (li128) Print("Stop > 50. Stop trade.");
         gi372 = FALSE;
      }
   }
   if (li144) gi376 = TRUE;
   bool li204 = TRUE;
   if (li132 && gspread_276 > 20 && Symbol() == "EURUSD") {
      li204 = FALSE;
      if (gi376 == TRUE) {
         if (li128) Print("Spread > 20. Stop trade.");
         gi376 = FALSE;
      }
   }
   bool li208 = TRUE;
   bool li212 = TRUE;
   bool li216 = TRUE;
   bool li220 = TRUE;
   for (li148 = 0; li148 < OrdersTotal(); li148++) {
      if (OrderSelect(li148, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
      if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_136) {
         if (OrderTicket() == gticket_380 && li124) {
            PlaySound("alert.wav");
            gticket_380 = 0;
         }
         if (OrderOpenTime() >= Time[0]) {
            li208 = FALSE;
            continue;
         }
      }
      if (OrderType() == OP_BUYSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_136) {
         li216 = FALSE;
         gord_open_price_388 = OrderOpenPrice();
         gticket_380 = OrderTicket();
         if (li200 == FALSE) {
            OrderDelete(OrderTicket());
            if (!(li128)) continue;
            Print("Delete order  ", OrderTicket(), " GOOD_STOP=false");
            continue;
         }
         if (gi336 && OrderOpenPrice() - Ask < lstoplevel160 << 2 * Point) {
            OrderDelete(OrderTicket());
            gi332 = FALSE;
            if (!(li128)) continue;
            Print("Delete order  ", OrderTicket(), " due to the price shock");
            continue;
         }
         if (li180 == FALSE || li192 == FALSE) {
            OrderDelete(OrderTicket());
            if (!(li128)) continue;
            Print("Delete order ", OrderTicket(), "PERMIS_TRADE=", li180, " PERMIS_BUY1=", li192);
            continue;
         }
         if (show_orders == FALSE && OrderOpenPrice() - Close[0] > 300.0 * Point) {
            OrderDelete(OrderTicket());
            if (!(li128)) continue;
            Print("Order ", OrderTicket(), " delited because price far");
            continue;
         }
         if (OrderOpenPrice() - gprice_148 >= 50.0 * Point || gprice_148 - OrderOpenPrice() >= 50.0 * Point && Ask <= OrderOpenPrice() - lstoplevel160 * Point) OrderModify(OrderTicket(), gprice_148, gprice_180, gprice_164, 0, Blue);
         else
            if (OrderOpenPrice() - gprice_148 < 50.0 * Point || gprice_148 - OrderOpenPrice() < 50.0 * Point && Ask <= OrderOpenPrice() - lstoplevel160 * Point && NormalizeDouble(OrderOpenPrice(), gi280) != NormalizeDouble(gprice_148, gi280)) OrderModify(OrderTicket(), gprice_148, gprice_180, gprice_164, 0, CLR_NONE);
         if (NormalizeDouble(OrderStopLoss(), gi280) != NormalizeDouble(gprice_180, gi280)) {
            if (li128) Print("modify StopLoss, order ", OrderTicket(), " from ", OrderStopLoss(), " to ", gprice_180);
            OrderModify(OrderTicket(), OrderOpenPrice(), gprice_180, OrderTakeProfit(), 0, CLR_NONE);
         }
         if (NormalizeDouble(OrderLots(), LotDecimal) != NormalizeDouble(glots_220, LotDecimal)) {
            if (li128) Print("modify lots, order ", OrderTicket(), " from ", OrderLots(), " to ", glots_220);
            OrderDelete(OrderTicket());
         }
      }
      if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_136) {
         if (OrderTicket() == gticket_384 && li124) {
            PlaySound("alert.wav");
            gticket_384 = 0;
         }
         if (OrderOpenTime() >= Time[0]) {
            li212 = FALSE;
            continue;
         }
      }
      if (OrderType() == OP_SELLSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_136) {
         li220 = FALSE;
         gord_open_price_396 = OrderOpenPrice();
         gticket_384 = OrderTicket();
         if (li200 == FALSE) {
            OrderDelete(OrderTicket());
            if (!(li128)) continue;
            Print("Delete order  ", OrderTicket(), " GOOD_STOP=false");
            continue;
         }
         if (gi336 && Bid - OrderOpenPrice() < lstoplevel160 << 2 * Point) {
            OrderDelete(OrderTicket());
            gi332 = FALSE;
            if (!(li128)) continue;
            Print("Delete order ", OrderTicket(), " due to the price shock");
            continue;
         }
         if (li180 == FALSE || li196 == FALSE) {
            OrderDelete(OrderTicket());
            if (!(li128)) continue;
            Print("Delete order ", OrderTicket(), "PERMIS_TRADE=", li180, " PERMIS_SELL1=", li196);
            continue;
         }
         if (show_orders == FALSE && Close[0] - OrderOpenPrice() > 300.0 * Point) {
            OrderDelete(OrderTicket());
            if (!(li128)) continue;
            Print("Order ", OrderTicket(), " delited because price far");
            continue;
         }
         if (OrderOpenPrice() - gprice_156 >= 50.0 * Point || gprice_156 - OrderOpenPrice() >= 50.0 * Point && Bid >= OrderOpenPrice() + lstoplevel160 * Point) OrderModify(OrderTicket(), gprice_156, gprice_188, gprice_172, 0, Red);
         else
            if (OrderOpenPrice() - gprice_156 < 50.0 * Point || gprice_156 - OrderOpenPrice() < 50.0 * Point && Bid >= OrderOpenPrice() + lstoplevel160 * Point && NormalizeDouble(OrderOpenPrice(), gi280) != NormalizeDouble(gprice_156, gi280)) OrderModify(OrderTicket(), gprice_156, gprice_188, gprice_172, 0, CLR_NONE);
         if (NormalizeDouble(OrderStopLoss(), gi280) != NormalizeDouble(gprice_188, gi280)) {
            if (li128) Print("modify StopLoss, order  ", OrderTicket(), " from ", OrderStopLoss(), " to ", gprice_188);
            OrderModify(OrderTicket(), OrderOpenPrice(), gprice_188, OrderTakeProfit(), 0, CLR_NONE);
         }
         if (NormalizeDouble(OrderLots(), LotDecimal) != NormalizeDouble(glots_212, LotDecimal)) {
            if (li128) Print("modify lots, order ", OrderTicket(), " from ", OrderLots(), " to ", glots_212);
            OrderDelete(OrderTicket());
         }
      }
      RefreshRates();
   }
   if ((TimeCurrent() - gdatetime_348) / 60 > li176) {
      gi332 = TRUE;
      gi336 = FALSE;
   }
   bool li224 = TRUE;
   bool li228 = TRUE;
   if (iHigh(NULL, PERIOD_D1, 0) + (gspread_276 + li140) * Point > gprice_148) li224 = FALSE;
   if (iLow(NULL, PERIOD_D1, 0) - li140 * Point < gprice_156) li228 = FALSE;
   bool li232 = TRUE;
   bool li236 = TRUE;
   if (show_orders == FALSE) {
      if (gprice_148 - Close[0] > 150.0 * Point) li232 = FALSE;
      if (Close[0] - gprice_156 > 150.0 * Point) li236 = FALSE;
   }
   if (li200 && li204 && li232 && li172 && gi332 && li180 && li224 && li192 && li208 && li216)
      if (Ask <= gprice_148 - lstoplevel160 * Point) OrderSend(Symbol(), OP_BUYSTOP, glots_220, gprice_148, 0, NormalizeDouble(gprice_180,Digits), NormalizeDouble(gprice_164,Digits), "Day Extremum", lmagic_136, 0, Blue);
   if (li200 && li204 && li236 && li172 && gi332 && li180 && li228 && li196 && li212 && li220)
      if (Bid >= gprice_156 + lstoplevel160 * Point) OrderSend(Symbol(), OP_SELLSTOP, glots_212, gprice_156, 0, NormalizeDouble(gprice_188,Digits), NormalizeDouble(gprice_172,Digits), "Day Extremum", lmagic_136, 0, Red);
   if (gbid_404 == 0.0) gbid_404 = Bid;
   double ld_240 = ld_96;
   if (ld_96 < 1.0) ld_240 = 1;
   int li248 = MarketInfo(Symbol(), MODE_STOPLEVEL);
   if (li112 == 1) {
      lprice_252 = NormalizeDouble(Bid - ld_16 * lstoplevel160 * Point, Digits);
      lprice_260 = NormalizeDouble(Ask + ld_16 * lstoplevel160 * Point, Digits);
   }
   if (li112 == 2) {
      lprice_252 = NormalizeDouble(Low[iLowest(NULL, 0, MODE_LOW, 2, 1)] - gd_204, Digits);
      lprice_260 = NormalizeDouble(High[iHighest(NULL, 0, MODE_HIGH, 2, 1)] + gd_204 + gspread_276 * Point, Digits);
   }
   if (li112 == 3) {
      lprice_252 = NormalizeDouble(MathMin(gd_268, gd_252) - gd_204, Digits);
      lprice_260 = NormalizeDouble(MathMax(gd_260, gd_244) + gd_204 + gspread_276 * Point, Digits);
   }
   for (li148 = 0; li148 <= OrdersTotal(); li148++) {
      if (OrderSelect(li148, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
      if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_136) {
         if (li80 && Close[0] < iLow(NULL, PERIOD_H1, 1)) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
            RefreshRates();
            if (!(li128)) continue;
            Print("Close Order ", OrderTicket(), " Close H1");
            continue;
         }
         if (li200 == FALSE && OrderStopLoss() < OrderOpenPrice() && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
            RefreshRates();
            if (!(li128)) continue;
            Print("Close Order ", OrderTicket(), " ---> stop>50");
            continue;
         }
         if ((TimeCurrent() - OrderOpenTime() > 60 * li92 && OrderStopLoss() < OrderOpenPrice() && Bid >= OrderOpenPrice()) || (li52 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0)) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
            RefreshRates();
            if (!(li128)) continue;
            Print("Close Order ", OrderTicket(), " ---> time_of_close");
            continue;
         }
         if (li56 && MathAbs((OrderOpenPrice() - gord_open_price_388) / Point) > li60 && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 10, Yellow);
            RefreshRates();
            if (li128) Print("Close Order ", OrderTicket(), " due to the price shock ", MathAbs((OrderOpenPrice() - gord_open_price_388) / Digits), " pips");
            if (!(li128)) continue;
            Print("OrderOpenPrise ", DoubleToStr(OrderOpenPrice(), Digits), ", PRICE_BUY1 ", DoubleToStr(gord_open_price_388, Digits));
            continue;
         }
         if (li64 && gihigh_132 - OrderOpenPrice() >= li68 * Point && Bid - OrderOpenPrice() < 5.0 * Point && Bid - OrderOpenPrice() >= 0.0 && Bid < gbid_404) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
            RefreshRates();
            Print("Закрываю ордер BUY ", OrderTicket(), ", ", (Bid - OrderOpenPrice()) / Point, " пунктов в профите, движение вниз ", DoubleToStr(Bid - gbid_404, Digits));
            Print("Текущая цена ", DoubleToStr(Bid, Digits), "  Предыдущая цена ", DoubleToStr(gbid_404, Digits));
            continue;
         }
         if (li72 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) >= 0.0 && iClose(NULL, PERIOD_M1, 0) < iOpen(NULL, PERIOD_M1, 0) && Close[0] < iLow(NULL, PERIOD_M1, 1) && iClose(NULL, PERIOD_M1, 1) < iOpen(NULL, PERIOD_M1, 1) ||
            iClose(NULL, PERIOD_M1, 1) < iLow(NULL, PERIOD_M1, 1) + (iHigh(NULL, PERIOD_M1, 1) - iLow(NULL, PERIOD_M1, 1)) / 3.0) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, Yellow);
            RefreshRates();
            if (!(li128)) continue;
            Print("Close Order ", OrderTicket(), " ---> minimum_risk_M1");
            continue;
         }
         if (li76 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) >= 0.0 && iClose(NULL, PERIOD_M5, 0) < iOpen(NULL, PERIOD_M5, 0) && Close[0] < iLow(NULL, PERIOD_M5, 1) && iClose(NULL, PERIOD_M5, 1) < iOpen(NULL, PERIOD_M5, 1) ||
            iClose(NULL, PERIOD_M5, 1) < iLow(NULL, PERIOD_M5, 1) + (iHigh(NULL, PERIOD_M5, 1) - iLow(NULL, PERIOD_M5, 1)) / 3.0) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, Yellow);
            RefreshRates();
            if (!(li128)) continue;
            Print("Close Order ", OrderTicket(), " ---> minimum_risk_M5");
            continue;
         }
         if (OrderStopLoss() < OrderOpenPrice()) {
            if (li248 < 50) {
               if (li44 == TRUE && Bid - OrderOpenPrice() >= MathCeil(lstoplevel160 * ld_96) * Point && Bid - OrderStopLoss() > MathCeil(lstoplevel160 * ld_96) * Point) {
                  OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - MathCeil(lstoplevel160 * ld_240) * Point, Digits), OrderTakeProfit(), 0, LightGreen);
                  Print("Ставлю в ноль BUY ордер ", OrderTicket());
                  RefreshRates();
                  continue;
               }
            } else {
               if (li44 == TRUE && Bid - OrderOpenPrice() >= MathCeil(lstoplevel160 * ld_96) * Point && Bid - OrderStopLoss() > MathCeil(lstoplevel160 * ld_96) * Point && OrderStopLoss() < NormalizeDouble(Bid - MathCeil(lstoplevel160 * ld_240 +
                  lstoplevel160 / 10.0) * Point, Digits)) {
                  OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - MathCeil(lstoplevel160 * ld_240 + lstoplevel160 / 10.0) * Point, Digits), OrderTakeProfit(), 0, LightGreen);
                  Print("Ставлю в ноль BUY ордер ", OrderTicket());
                  RefreshRates();
                  continue;
               }
            }
            if (li48 == TRUE && OrderStopLoss() < lprice_252 && Bid - lprice_252 >= lstoplevel160 * Point) {
               if (li128) Print("Reduce losses OP_BUY order ", OrderTicket(), " moved S/L from ", DoubleToStr(OrderStopLoss(), Digits), " to ", DoubleToStr(lprice_252, Digits), ". Methot S/L=", li112);
               OrderModify(OrderTicket(), OrderOpenPrice(), lprice_252, OrderTakeProfit(), 0, LightGreen);
               RefreshRates();
               continue;
            }
         }
         if (OrderStopLoss() >= OrderOpenPrice() && li40 == TRUE) {
            if (Bid - OrderStopLoss() > Point * lpips_104 * lstoplevel160) {
               OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - lpips_104 * lstoplevel160 * Point, Digits), OrderTakeProfit(), 0, LightGreen);
               RefreshRates();
               continue;
            }
         }
         if (OrderStopLoss() >= OrderOpenPrice() && li48 == TRUE && lprice_252 > OrderStopLoss() && Bid - lprice_252 >= lstoplevel160 * Point) {
            if (li128) Print("MovingS_L=true, Methot S/L=", li112, ". Increase Profit OP_BUY order ", OrderTicket(), " from ", DoubleToStr(OrderStopLoss(), Digits), " to ", DoubleToStr(lprice_252, Digits));
            OrderModify(OrderTicket(), OrderOpenPrice(), lprice_252, OrderTakeProfit(), 0, LightGreen);
            RefreshRates();
            continue;
         }
      }
      if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_136) {
         if (li80 && Close[0] > iHigh(NULL, PERIOD_H1, 1)) {
            OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
            RefreshRates();
            if (li128) Print("Close Order ", OrderTicket(), " Close H1");
         } else {
            if (li200 == FALSE && OrderStopLoss() > OrderOpenPrice() && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0) {
               OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
               RefreshRates();
               if (li128) Print("Close Order ", OrderTicket(), " ---> stop>50");
            } else {
               if ((TimeCurrent() - OrderOpenTime() > 60 * li92 && OrderStopLoss() > OrderOpenPrice() && Ask <= OrderOpenPrice()) || (li52 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0)) {
                  OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
                  RefreshRates();
               } else {
                  if (li56 && MathAbs((gord_open_price_396 - OrderOpenPrice()) / Point) > li60 && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0) {
                     OrderClose(OrderTicket(), OrderLots(), Ask, 10, Yellow);
                     RefreshRates();
                     if (li128) Print("Close Order ", OrderTicket(), " due to the price shock ", MathAbs((OrderOpenPrice() - gord_open_price_396) / Digits), " pips");
                     if (li128) Print("OrderOpenPrise ", DoubleToStr(OrderOpenPrice(), Digits), ", PRICE_SELL1 ", DoubleToStr(gord_open_price_396, Digits));
                  } else {
                     if (li64 && OrderOpenPrice() - gspread_276 * Point - gilow_140 >= li68 * Point && OrderOpenPrice() - Ask < 5.0 * Point && OrderOpenPrice() - Ask >= 0.0 && Bid > gbid_404) {
                        OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
                        RefreshRates();
                        Print("Закрываю ордер SELL ", OrderTicket(), ", ", (OrderOpenPrice() - Ask) / Point, " пунктов в профите, движение вверх ", DoubleToStr(Bid - gbid_404, Digits));
                     } else {
                        if (li72 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) >= 0.0 && iClose(NULL, PERIOD_M1, 0) > iOpen(NULL, PERIOD_M1, 0) && Close[0] > iHigh(NULL, PERIOD_M1, 1) && iClose(NULL, PERIOD_M1, 1) > iOpen(NULL, PERIOD_M1, 1) ||
                           iClose(NULL, PERIOD_M1, 1) > iHigh(NULL, PERIOD_M1, 1) - (iHigh(NULL, PERIOD_M1, 1) - iLow(NULL, PERIOD_M1, 1)) / 3.0) {
                           OrderClose(OrderTicket(), OrderLots(), Ask, 3, Yellow);
                           RefreshRates();
                           if (li128) Print("Close Order ", OrderTicket(), " ---> minimum_risk_M1");
                        } else {
                           if (li76 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) >= 0.0 && iClose(NULL, PERIOD_M5, 0) > iOpen(NULL, PERIOD_M5, 0) && Close[0] > iHigh(NULL, PERIOD_M5, 1) && iClose(NULL, PERIOD_M5, 1) > iOpen(NULL, PERIOD_M5, 1) ||
                              iClose(NULL, PERIOD_M5, 1) > iHigh(NULL, PERIOD_M5, 1) - (iHigh(NULL, PERIOD_M5, 1) - iLow(NULL, PERIOD_M5, 1)) / 3.0) {
                              OrderClose(OrderTicket(), OrderLots(), Ask, 3, Yellow);
                              RefreshRates();
                              if (li128) Print("Close Order ", OrderTicket(), " ---> minimum_risk_M5");
                           } else {
                              if (OrderStopLoss() > OrderOpenPrice()) {
                                 if (li248 < 50) {
                                    if (li44 == TRUE && OrderOpenPrice() - Ask >= Point * MathCeil(lstoplevel160 * ld_96) && OrderStopLoss() - Ask > MathCeil(lstoplevel160 * ld_96) * Point) {
                                       OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + MathCeil(lstoplevel160 * ld_240) * Point, Digits), OrderTakeProfit(), 0, Pink);
                                       RefreshRates();
                                       Print("Ставлю в ноль SELL ордер ", OrderTicket());
                                       continue;
                                    }
                                 } else {
                                    if (li44 == TRUE && OrderOpenPrice() - Ask >= Point * MathCeil(lstoplevel160 * ld_96) && OrderStopLoss() - Ask > MathCeil(lstoplevel160 * ld_96) * Point && OrderStopLoss() > NormalizeDouble(Ask +
                                       MathCeil(lstoplevel160 * ld_240 + lstoplevel160 / 10.0) * Point, Digits)) {
                                       OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + MathCeil(lstoplevel160 * ld_240 + lstoplevel160 / 10.0) * Point, Digits), OrderTakeProfit(), 0, Pink);
                                       RefreshRates();
                                       Print("Ставлю в ноль SELL ордер ", OrderTicket());
                                       continue;
                                    }
                                 }
                                 if (li48 == TRUE && OrderStopLoss() > lprice_260 && lprice_260 - Ask >= lstoplevel160 * Point) {
                                    if (li128) Print("Reduce losses OP_SELL order ", OrderTicket(), " moved S/L from", DoubleToStr(OrderStopLoss(), Digits), " to ", DoubleToStr(lprice_260, Digits), ". Methot S/L=", li112);
                                    OrderModify(OrderTicket(), OrderOpenPrice(), lprice_260, OrderTakeProfit(), 0, LightGreen);
                                    RefreshRates();
                                    continue;
                                 }
                              }
                              if (OrderStopLoss() <= OrderOpenPrice() && li40 == TRUE) {
                                 if (OrderStopLoss() - Ask > Point * lpips_104 * lstoplevel160) {
                                    OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + lpips_104 * lstoplevel160 * Point, Digits), OrderTakeProfit(), 0, Pink);
                                    RefreshRates();
                                    continue;
                                 }
                              }
                              if (OrderStopLoss() <= OrderOpenPrice() && li48 == TRUE && lprice_260 < OrderStopLoss() && lprice_260 - Ask >= lstoplevel160 * Point) {
                                 if (li128) Print("Tr.stop = false. Methot S/L=", li112, ". Increase Profit OP_SELL order ", OrderTicket(), " from ", DoubleToStr(OrderStopLoss(), Digits), " to ", DoubleToStr(lprice_260, Digits));
                                 OrderModify(OrderTicket(), OrderOpenPrice(), lprice_260, OrderTakeProfit(), 0, LightGreen);
                                 RefreshRates();
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      }
   }
   RefreshRates();
   gbid_404 = Bid;
}

void func2() {
   double lifractals_144;
   double lifractals_152;
   int li176;
   int li180;
   double lprice_256;
   double lprice_264;
   double ld_0 = lot_percent / 10000.0;
   double ld_8 = lot_fixed;
   double ld_16 = 12;
   double ld_24 = 22;
   double ld_32 = 75;
   int li40 = 20;
   bool li44 = TRUE;
   bool li48 = TRUE;
   bool li52 = TRUE;
   bool li56 = TRUE;
   bool li60 = FALSE;
   bool li64 = TRUE;
   int li68 = 75;
   bool li72 = TRUE;
   bool li76 = TRUE;
   int li80 = 180;
   double ld_84 = 1;
   double lpips_92 = 1;
   int li100 = 2;
   int li104 = 0;
   int li108 = 0;
   bool li112 = FALSE;
   bool li116 = FALSE;
   int lmagic_120 = 999;
   bool li124 = TRUE;
   bool li128 = TRUE;
   if (ld_16 < 1.0 || ld_32 < 1.0) {
      Print("stop level below the requested soluble");
      return;
   }
   bool li132 = FALSE;
   if (gtime_412 == 0) gtime_412 = Time[0];
   if (gtime_412 != Time[0]) {
      li132 = TRUE;
      gtime_412 = Time[0];
   }
   int lstoplevel136 = MarketInfo(Symbol(), MODE_STOPLEVEL);
   if (lstoplevel136 < li40 && Digits == 5) lstoplevel136 = li40;
   if (lstoplevel136 < 2 && Digits == 4) lstoplevel136 = 2;
   if (li132 || glots_520 == 0.0 || glots_528 == 0.0 || gprice_456 == 0.0 || gprice_464 == 0.0 || gprice_472 == 0.0 || gprice_480 == 0.0 || gprice_488 == 0.0 ||
      gprice_496 == 0.0 || gticksize_504 == 0.0 || gd_512 == 0.0) {
      gspread_584 = MarketInfo(Symbol(), MODE_SPREAD);
      if (li116) Print("spread = ", gspread_584, " ", Symbol());
      gticksize_504 = MarketInfo(Symbol(), MODE_TICKSIZE);
      gtickvalue_544 = MarketInfo(Symbol(), MODE_TICKVALUE);
      gmarginrequired_536 = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
      if (Digits == 5) {
         gd_512 = 10.0 * gticksize_504;
         gi588 = 4;
      } else gd_512 = gticksize_504;
      for (int li140 = 3; li140 < 100; li140++) {
         if (High[li140] >= High[li140 + 1] && High[li140] > High[li140 + 2] && High[li140] >= High[li140 - 1] && High[li140] > High[li140 - 2]) {
            ghigh_552 = High[li140];
            gi592 = li140;
            gtime_624 = Time[li140];
            break;
         }
      }
      for (li140 = gi592 + 1; li140 < 100; li140++) {
         if (High[li140] >= High[li140 + 1] && High[li140] > High[li140 + 2] && High[li140] >= High[li140 - 1] && High[li140] > High[li140 - 2]) {
            ghigh_568 = High[li140];
            giunused_596 = li140;
            break;
         }
      }
      for (li140 = 3; li140 < 100; li140++) {
         if (Low[li140] <= Low[li140 + 1] && Low[li140] < Low[li140 + 2] && Low[li140] <= Low[li140 - 1] && Low[li140] < Low[li140 - 2]) {
            glow_560 = Low[li140];
            gi600 = li140;
            gtime_628 = Time[li140];
            break;
         }
      }
      for (li140 = gi600 + 1; li140 < 100; li140++) {
         if (Low[li140] <= Low[li140 + 1] && Low[li140] < Low[li140 + 2] && Low[li140] <= Low[li140 - 1] && Low[li140] < Low[li140 - 2]) {
            glow_576 = Low[li140];
            giunused_604 = li140;
            break;
         }
      }
      lifractals_144 = iFractals(NULL, 0, MODE_UPPER, 0);
      lifractals_152 = iFractals(NULL, 0, MODE_LOWER, 0);
      gialligator_432 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORLIPS, 0);
      gialligator_440 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 0);
      gialligator_448 = iAlligator(NULL, 0, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, 0);
      giao_416 = iAO(NULL, 0, 1);
      giao_424 = iAO(NULL, 0, 2);
      for (int li160 = 1; li160 <= 1000; li160++) {
         if ((iAO(NULL, 0, li160 + 1) > 0.0 && iAO(NULL, 0, li160) > iAO(NULL, 0, li160 + 1) && iAO(NULL, 0, li160 + 1) < iAO(NULL, 0, li160 + 2)) || (iAO(NULL, 0, li160) > 0.0 &&
            iAO(NULL, 0, li160 + 1) < 0.0)) {
            gi608 = li160;
            gi616 = Time[li160];
            break;
         }
      }
      for (li160 = 1; li160 <= 1000; li160++) {
         if ((iAO(NULL, 0, li160 + 1) < 0.0 && iAO(NULL, 0, li160) < iAO(NULL, 0, li160 + 1) && iAO(NULL, 0, li160 + 1) > iAO(NULL, 0, li160 + 2)) || (iAO(NULL, 0, li160) < 0.0 &&
            iAO(NULL, 0, li160 + 1) > 0.0)) {
            gi612 = li160;
            gi620 = Time[li160];
            break;
         }
      }
      if (li116) Print("shift_ao_buy=", gi608, ", shift_ao_sell=", gi612);
      //if (li124 && ghigh_552<=High[iHighest(NULL, 0, MODE_HIGH, gi592 - 1, 1)] && ) gprice_456=NormalizeDouble(High[gi608]+(gspread_276+1)*Point,Digits);
      //else gprice_456=NormalizeDouble(ghigh_552+(gspread_276+1)*Point,Digits);
      gprice_456 = NormalizeDouble(Proc3(ghigh_552, glow_560, li128, gspread_584, Point, li124, gi616, gi620, gtime_624, gtime_628, High[iHighest(NULL, 0, MODE_HIGH, gi592 - 1, 1)], Low[iLowest(NULL, 0, MODE_LOW, gi600 - 1, 1)], High[gi608], Low[gi612]), Digits);
      if (li100 == 1) gprice_488 = NormalizeDouble(gprice_456 - ld_16 * lstoplevel136 * Point, Digits);
      if (li100 == 2) {
         gprice_488 = NormalizeDouble(Low[iLowest(NULL, 0, MODE_LOW, 2, 0)] - gd_512, Digits);
         if ((gprice_456 - gprice_488) / Point > ld_24 * lstoplevel136) gprice_488 = NormalizeDouble(gprice_456 - ld_24 * lstoplevel136 * Point, Digits);
      }
      if (li100 == 3) {
         gprice_488 = NormalizeDouble(MathMin(glow_576, glow_560) - gd_512, Digits);
         if ((gprice_456 - gprice_488) / Point > ld_24 * lstoplevel136) gprice_488 = NormalizeDouble(gprice_456 - ld_24 * lstoplevel136 * Point, Digits);
      }
      if (li116) Print("SlBUY = ", gprice_488, " ", Symbol());
      gprice_472 = NormalizeDouble(gprice_456 + ld_32 * lstoplevel136 * Point, Digits);
      if (li116) Print("TP_BUY = ", gprice_472, " ", Symbol());
      gprice_464 = NormalizeDouble(Proc4(ghigh_552, glow_560, li128, gspread_584, Point, li124, gi616, gi620, gtime_624, gtime_628, High[iHighest(NULL, 0, MODE_HIGH, gi592 - 1, 1)], Low[iLowest(NULL, 0, MODE_LOW, gi600 - 1, 1)], High[gi608], Low[gi612]), Digits);
      if (li100 == 1) gprice_496 = NormalizeDouble(gprice_464 + (ld_16 * lstoplevel136 + gspread_584) * Point, Digits);
      if (li100 == 2) {
         gprice_496 = NormalizeDouble(High[iHighest(NULL, 0, MODE_HIGH, 2, 0)] + gspread_584 * Point + gd_512, Digits);
         if ((gprice_496 - gprice_464) / Point > ld_24 * lstoplevel136) gprice_496 = NormalizeDouble(gprice_464 + (ld_24 * lstoplevel136 + gspread_584) * Point, Digits);
      }
      if (li100 == 3) {
         gprice_496 = NormalizeDouble(MathMax(ghigh_552, ghigh_568) + gspread_584 * Point + gd_512, Digits);
         if ((gprice_496 - gprice_464) / Point > ld_24 * lstoplevel136) gprice_496 = NormalizeDouble(gprice_464 + (ld_24 * lstoplevel136 + gspread_584) * Point, Digits);
      }
      if (li116) Print("SlSELL = ", gprice_496, " ", Symbol());
      gprice_480 = NormalizeDouble(gprice_464 - ld_32 * lstoplevel136 * Point, Digits);
      if (li116) Print("TP_SELL = ", gprice_480, " ", Symbol());
      glots_528 = GetLots(gprice_456,gprice_488);//0.1;
      glots_520 = GetLots(gprice_464,gprice_496);//0.1;
      /*if (AccountBalance() > 500.0) {
         glots_528 = NormalizeDouble(AccountBalance() * ld_0, LotDecimal);
         glots_520 = NormalizeDouble(AccountBalance() * ld_0, LotDecimal);
         for (li160 = OrdersHistoryTotal() - 1; li160 >= 0; li160--) {
            if (OrderSelect(li160, SELECT_BY_POS, MODE_HISTORY) == FALSE) break;
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_120) {
               if (OrderLots() <= NormalizeDouble(AccountBalance() * ld_0, LotDecimal)) {
                  glots_528 = NormalizeDouble(AccountBalance() * ld_0, LotDecimal);
                  glots_520 = NormalizeDouble(AccountBalance() * ld_0, LotDecimal);
                  break;
               }
               glots_528 = NormalizeDouble(OrderLots(), LotDecimal);
               glots_520 = NormalizeDouble(OrderLots(), LotDecimal);
               break;
            }
         }
      }
      if (ld_8 > 0.0) {
         glots_528 = NormalizeDouble(ld_8, LotDecimal);
         glots_520 = NormalizeDouble(ld_8, LotDecimal);
      }
      if (glots_528 > NormalizeDouble(AccountFreeMargin() / (1.05 * gmarginrequired_536), LotDecimal) || glots_520 > NormalizeDouble(AccountFreeMargin() / (1.05 * gmarginrequired_536), LotDecimal)) {
         glots_528 = NormalizeDouble(AccountFreeMargin() / (1.05 * gmarginrequired_536), LotDecimal);
         glots_520 = NormalizeDouble(AccountFreeMargin() / (1.05 * gmarginrequired_536), LotDecimal);
      }*/
   }
   bool li164 = TRUE;
   /*if (AccountFreeMargin() < MarketInfo(Symbol(), MODE_MARGINREQUIRED) / 10.0) {
      li164 = FALSE;
      Print("No money");
   }*/
   int li168 = 15;
   if (li132) gi652 = TRUE;
   if (MathAbs((gd_640 - Close[0]) / Point) > li68 && gd_640 != 0.0 && li64) {
      gi636 = TRUE;
      gdatetime_648 = TimeCurrent();
      if (gi652 == TRUE) {
         if (li116) Print("The price shock for ", (gd_640 - Close[0]) / Point, " pips.", Symbol());
         if (li116) Print("last_price ", DoubleToStr(gd_640, Digits), ", curent_price ", DoubleToStr(Close[0], Digits));
         gi652 = FALSE;
      }
   }
   gd_640 = Close[0];
   bool li172 = TRUE;
   if (li104 != 0) {
      li176 = 60 * li104 + li108;
      li180 = 60 * TimeHour(TimeCurrent()) + TimeMinute(TimeCurrent());
      if (li176 - li180 <= 20 && li180 - li176 <= 15) li172 = FALSE;
   }
   if (li132) gi656 = TRUE;
   if (li172 == TRUE) {
      if (DayOfWeek() == 5 && TimeCurrent() - iTime(NULL, PERIOD_D1, 0) > 79200) {
         li172 = FALSE;
         if (gi656 == TRUE) {
            if (li116) Print("Friday, ending trading.");
            gi656 = FALSE;
         }
      }
   }
   if (li132) gi660 = TRUE;
   if (li172 == TRUE) {
      if ((DayOfWeek() == 1 && TimeCurrent() - iTime(NULL, PERIOD_D1, 0) < 3900) || DayOfWeek() == 6 || DayOfWeek() == 7) {
         li172 = FALSE;
         if (gi660 == TRUE) {
            if (li116) Print("Monday, prior to 1-00 in the morning do not trade. Or off.");
            gi660 = FALSE;
         }
      }
   }
   double lord_open_price_184 = 0;
   double lord_open_price_192 = 0;
   for (li160 = 0; li160 < OrdersTotal(); li160++) {
      if (OrderSelect(li160, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
      if (OrderType() == OP_BUYSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == 777) lord_open_price_184 = OrderOpenPrice();
      if (OrderType() == OP_SELLSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == 777) lord_open_price_192 = OrderOpenPrice();
   }
   bool li200 = TRUE;
   bool li204 = TRUE;
   int lcount_208 = 0;
   int lcount_212 = 0;
   if (li132) {
      gi664 = TRUE;
      gi668 = TRUE;
   }
   for (li160 = 0; li160 < OrdersTotal(); li160++) {
      if (OrderSelect(li160, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
      if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_120) {
         if (OrderTicket() == gticket_672 && li112) {
            PlaySound("alert.wav");
            gticket_672 = 0;
         }
         if (OrderOpenTime() >= Time[0]) {
            gi664 = FALSE;
            continue;
         }
      }
      if (OrderType() == OP_BUYSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_120) {
         li200 = FALSE;
         gticket_672 = OrderTicket();
         lcount_208++;
         if (lcount_208 > 1) {
            OrderDelete(OrderTicket());
            continue;
         }
         if (gi636 && OrderOpenPrice() - Ask < lstoplevel136 << 2 * Point) {
            OrderDelete(OrderTicket());
            gi632 = FALSE;
            Print("Delete order ", OrderTicket(), " due to the price shock");
            continue;
         }
         if (li172 == FALSE) {
            OrderDelete(OrderTicket());
            if (!(li116)) continue;
            Print("Delete order ", OrderTicket(), "PERMIS_TRADE=", li172);
            continue;
         }
         if (li44 && MathAbs(OrderOpenPrice() - lord_open_price_184) / Point < lstoplevel136) {
            OrderDelete(OrderTicket());
            if (!(li116)) continue;
            Print("Order ", OrderTicket(), " deleted because of the similarity with a Day Extremum");
            continue;
         }
         if (show_orders == FALSE && OrderOpenPrice() - Close[0] > 300.0 * Point) {
            OrderDelete(OrderTicket());
            if (!(li116)) continue;
            Print("Order ", OrderTicket(), " deleted because price far");
            continue;
         }
         if (OrderOpenPrice() - gprice_456 >= 50.0 * Point || gprice_456 - OrderOpenPrice() >= 50.0 * Point && Ask <= OrderOpenPrice() - lstoplevel136 * Point) OrderModify(OrderTicket(), gprice_456, gprice_488, gprice_472, 0, Blue);
         else
            if (OrderOpenPrice() - gprice_456 < 50.0 * Point || gprice_456 - OrderOpenPrice() < 50.0 * Point && Ask <= OrderOpenPrice() - lstoplevel136 * Point && NormalizeDouble(OrderOpenPrice(), gi588) != NormalizeDouble(gprice_456, gi588)) OrderModify(OrderTicket(), gprice_456, gprice_488, gprice_472, 0, CLR_NONE);
         if (NormalizeDouble(OrderStopLoss(), gi588) != NormalizeDouble(gprice_488, gi588)) {
            if (li116) Print("modify StopLoss, order ", OrderTicket(), " from ", OrderStopLoss(), " to ", gprice_488);
            OrderModify(OrderTicket(), OrderOpenPrice(), gprice_488, OrderTakeProfit(), 0, CLR_NONE);
         }
         if (NormalizeDouble(OrderLots(), LotDecimal) != NormalizeDouble(glots_528, LotDecimal)) {
            if (li116) Print("modify lots, order ", OrderTicket(), " from ", OrderLots(), " to ", glots_528);
            OrderDelete(OrderTicket());
         }
      }
      if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_120) {
         if (OrderTicket() == gticket_676 && li112) {
            PlaySound("alert.wav");
            gticket_676 = 0;
         }
         if (OrderOpenTime() >= Time[0]) {
            gi668 = FALSE;
            continue;
         }
      }
      if (OrderType() == OP_SELLSTOP && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_120) {
         li204 = FALSE;
         gticket_676 = OrderTicket();
         lcount_212++;
         if (lcount_212 > 1) OrderDelete(OrderTicket());
         else {
            if (gi636 && Bid - OrderOpenPrice() < lstoplevel136 << 2 * Point) {
               OrderDelete(OrderTicket());
               gi632 = FALSE;
               if (li116) Print("Delete order ", OrderTicket(), " due to the price shock");
            } else {
               if (li172 == FALSE) OrderDelete(OrderTicket());
               else {
                  if (li44 && MathAbs(OrderOpenPrice() - lord_open_price_192) / Point < lstoplevel136) {
                     OrderDelete(OrderTicket());
                     if (li116) Print("Order ", OrderTicket(), " closed because of the similarity with a Day Extremum");
                  } else {
                     if (show_orders == FALSE && Close[0] - OrderOpenPrice() > 300.0 * Point) {
                        OrderDelete(OrderTicket());
                        if (li116) Print("Order ", OrderTicket(), " delited because price far");
                     } else {
                        if (OrderOpenPrice() - gprice_464 >= 50.0 * Point || gprice_464 - OrderOpenPrice() >= 50.0 * Point && Bid >= OrderOpenPrice() + lstoplevel136 * Point) OrderModify(OrderTicket(), gprice_464, gprice_496, gprice_480, 0, Red);
                        else
                           if (OrderOpenPrice() - gprice_464 < 50.0 * Point || gprice_464 - OrderOpenPrice() < 50.0 * Point && Bid >= OrderOpenPrice() + lstoplevel136 * Point && NormalizeDouble(OrderOpenPrice(), gi588) != NormalizeDouble(gprice_464, gi588)) OrderModify(OrderTicket(), gprice_464, gprice_496, gprice_480, 0, CLR_NONE);
                        if (NormalizeDouble(OrderStopLoss(), gi588) != NormalizeDouble(gprice_496, gi588)) OrderModify(OrderTicket(), OrderOpenPrice(), gprice_496, OrderTakeProfit(), 0, CLR_NONE);
                        if (NormalizeDouble(OrderLots(), LotDecimal) != NormalizeDouble(glots_520, LotDecimal)) OrderDelete(OrderTicket());
                     }
                  }
               }
            }
         }
      }
   }
   if ((TimeCurrent() - gdatetime_648) / 60 > li168) {
      gi632 = TRUE;
      gi636 = FALSE;
   }
   bool li216 = TRUE;
   bool li220 = TRUE;
   if (High[iHighest(NULL, 0, MODE_HIGH, gi592 - 1, 0)] >= High[gi592]) li216 = FALSE;
   if (Low[iLowest(NULL, 0, MODE_LOW, gi600 - 1, 0)] <= Low[gi600]) li220 = FALSE;
   bool li224 = TRUE;
   bool li228 = TRUE;
   if (li124 == FALSE || li216 || gi616 < gtime_624 || High[iHighest(NULL, 0, MODE_HIGH, gi608, 0)] >= High[gi608]) li224 = FALSE;
   if (li124 == FALSE || li220 || gi620 < gtime_628 || Low[iLowest(NULL, 0, MODE_LOW, gi612, 0)] <= Low[gi612]) li228 = FALSE;
   bool li232 = TRUE;
   bool li236 = TRUE;
   if (li44 && MathAbs(gprice_456 - lord_open_price_184) / Point < lstoplevel136) li232 = FALSE;
   if (li44 && MathAbs(gprice_464 - lord_open_price_192) / Point < lstoplevel136) li236 = FALSE;
   bool li240 = TRUE;
   bool li244 = TRUE;
   if (show_orders == FALSE) {
      if (gprice_456 - Close[0] > 150.0 * Point) li240 = FALSE;
      if (Close[0] - gprice_464 > 150.0 * Point) li244 = FALSE;
   }
   if ((li240 && li232 && li164 && gi632 && li172 && li216 && gi664 && li200 && Ask <= gprice_456 - lstoplevel136 * Point) || (li240 && li232 && li164 &&
      gi632 && li172 && li224 && gi664 && li200 && Ask <= gprice_456 - lstoplevel136 * Point)) OrderSend(Symbol(), OP_BUYSTOP, glots_528, gprice_456, 0, NormalizeDouble(gprice_488,Digits), NormalizeDouble(gprice_472,Digits), "Fractals_H1", lmagic_120, 0, Blue);
   if ((li244 && li236 && li164 && gi632 && li172 && li220 && gi668 && li204 && Bid >= gprice_464 + lstoplevel136 * Point) || (li244 && li236 && li164 &&
      gi632 && li172 && li228 && gi668 && li204 && Bid >= gprice_464 + lstoplevel136 * Point)) OrderSend(Symbol(), OP_SELLSTOP, glots_520, gprice_464, 0, NormalizeDouble(gprice_496,Digits), NormalizeDouble(gprice_480,Digits), "Fractals_H1", lmagic_120, 0, Red);
   double ld_248 = ld_84;
   if (ld_84 < 1.0) ld_248 = 1;
   if (li100 == 1) {
      lprice_256 = NormalizeDouble(Bid - ld_16 * lstoplevel136 * Point, Digits);
      lprice_264 = NormalizeDouble(Ask + ld_16 * lstoplevel136 * Point, Digits);
   }
   if (li100 == 2) {
      lprice_256 = NormalizeDouble(Low[iLowest(NULL, 0, MODE_LOW, 2, 1)] - gd_512, Digits);
      lprice_264 = NormalizeDouble(High[iHighest(NULL, 0, MODE_HIGH, 2, 1)] + gd_512 + gspread_584 * Point, Digits);
   }
   if (li100 == 3) {
      lprice_256 = NormalizeDouble(MathMin(glow_576, glow_560) - gd_512, Digits);
      lprice_264 = NormalizeDouble(MathMax(ghigh_568, ghigh_552) + gd_512 + gspread_584 * Point, Digits);
   }
   for (li160 = 0; li160 <= OrdersTotal(); li160++) {
      if (OrderSelect(li160, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
      if (OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_120) {
         if (lstoplevel136 > li40 && OrderStopLoss() < OrderOpenPrice() && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0 && (iHigh(NULL, PERIOD_H4, 0) - Close[0]) / Point >= li40) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
            RefreshRates();
            if (!(li116)) continue;
            Print("Close Order ", OrderTicket(), " ---> stop>min_stop");
            continue;
         }
         if ((TimeCurrent() - OrderOpenTime() > 60 * li80 && OrderStopLoss() < OrderOpenPrice() && Bid >= OrderOpenPrice()) || (li60 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0)) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, CLR_NONE);
            if (!(li116)) continue;
            Print("Close Order ", OrderTicket(), " ---> time_of_close");
            continue;
         }
         if (li64 && MathAbs((OrderOpenPrice() - gprice_456) / Point) > li68 && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 5, Yellow);
            if (li116) Print("Close Order ", OrderTicket(), " due to the price shock ", MathAbs((OrderOpenPrice() - gprice_456) / Digits), " pips");
            if (!(li116)) continue;
            Print("OrderOpenPrise ", DoubleToStr(OrderOpenPrice(), Digits), ", PRICE_BUY ", DoubleToStr(gprice_456, Digits));
            continue;
         }
         if (li72 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) >= 0.0 && iClose(NULL, PERIOD_M1, 0) < iOpen(NULL, PERIOD_M1, 0) && Close[0] < iLow(NULL, PERIOD_M1, 1) && iClose(NULL, PERIOD_M1, 1) < iOpen(NULL, PERIOD_M1, 1) ||
            iClose(NULL, PERIOD_M1, 1) < iLow(NULL, PERIOD_M1, 1) + (iHigh(NULL, PERIOD_M1, 1) - iLow(NULL, PERIOD_M1, 1)) / 3.0) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, Yellow);
            if (!(li116)) continue;
            Print("Close Order ", OrderTicket(), " ---> minimum_risk_M1");
            continue;
         }
         if (li76 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) >= 0.0 && iClose(NULL, PERIOD_M5, 0) < iOpen(NULL, PERIOD_M5, 0) && Close[0] < iLow(NULL, PERIOD_M5, 1) && iClose(NULL, PERIOD_M5, 1) < iOpen(NULL, PERIOD_M5, 1) ||
            iClose(NULL, PERIOD_M5, 1) < iLow(NULL, PERIOD_M5, 1) + (iHigh(NULL, PERIOD_M5, 1) - iLow(NULL, PERIOD_M5, 1)) / 3.0) {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, Yellow);
            if (!(li116)) continue;
            Print("Close Order ", OrderTicket(), " ---> minimum_risk_M5");
            continue;
         }
         if (OrderStopLoss() < OrderOpenPrice()) {
            if (li52 == TRUE && Bid - OrderOpenPrice() >= MathCeil(lstoplevel136 * ld_84) * Point && Bid - OrderStopLoss() > MathCeil(lstoplevel136 * ld_84) * Point) {
               OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - MathCeil(lstoplevel136 * ld_248) * Point, Digits), OrderTakeProfit(), 0, LightGreen);
               Print("Ставлю в ноль BUY ордер ", OrderTicket());
               continue;
            }
            if (li52 == TRUE && Bid - OrderOpenPrice() >= MathCeil(lstoplevel136 * ld_84) * Point && Bid - OrderStopLoss() > MathCeil(lstoplevel136 * ld_84) * Point && OrderStopLoss() < NormalizeDouble(Bid - MathCeil(lstoplevel136 * ld_248 +
               lstoplevel136 / 10.0) * Point, Digits)) {
               OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - MathCeil(lstoplevel136 * ld_248 + lstoplevel136 / 10.0) * Point, Digits), OrderTakeProfit(), 0, LightGreen);
               Print("Ставлю в ноль BUY ордер ", OrderTicket());
               continue;
            }
            if (li56 == TRUE && OrderStopLoss() < lprice_256 && Bid - lprice_256 >= lstoplevel136 * Point) {
               if (li116) Print("Reduce losses OP_BUY order ", OrderTicket(), " moved S/L from ", DoubleToStr(OrderStopLoss(), Digits), " to ", DoubleToStr(lprice_256, Digits), ". Methot S/L=", li100);
               OrderModify(OrderTicket(), OrderOpenPrice(), lprice_256, OrderTakeProfit(), 0, LightGreen);
               continue;
            }
         }
         if (OrderStopLoss() >= OrderOpenPrice() && li48 == TRUE) {
            if (Bid - OrderStopLoss() > Point * lpips_92 * lstoplevel136) {
               OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - lpips_92 * lstoplevel136 * Point, Digits), OrderTakeProfit(), 0, LightGreen);
               continue;
            }
         }
         if (OrderStopLoss() >= OrderOpenPrice() && li56 == TRUE && lprice_256 > OrderStopLoss() && Bid - lprice_256 >= lstoplevel136 * Point) {
            if (li116) Print("MovingS_L=true, Methot S/L=", li100, ". Increase Profit OP_BUY order ", OrderTicket(), " from ", DoubleToStr(OrderStopLoss(), Digits), " to ", DoubleToStr(lprice_256, Digits));
            OrderModify(OrderTicket(), OrderOpenPrice(), lprice_256, OrderTakeProfit(), 0, LightGreen);
            continue;
         }
      }
      if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == lmagic_120) {
         if (lstoplevel136 > li40 && OrderStopLoss() > OrderOpenPrice() && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0 && (Close[0] - iLow(NULL, PERIOD_H4, 0)) / Point >= li40) {
            OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
            RefreshRates();
            if (li116) Print("Close Order ", OrderTicket(), " ---> stop>min_stop");
         } else {
            if ((TimeCurrent() - OrderOpenTime() > 60 * li80 && OrderStopLoss() > OrderOpenPrice() && Ask <= OrderOpenPrice()) || (li60 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0)) OrderClose(OrderTicket(), OrderLots(), Ask, 3, CLR_NONE);
            else {
               if (li64 && MathAbs((gprice_464 - OrderOpenPrice()) / Point) > li68 && (OrderProfit()+OrderCommission()+OrderSwap()) > 0.0) {
                  OrderClose(OrderTicket(), OrderLots(), Ask, 5, Yellow);
                  if (li116) Print("Close Order ", OrderTicket(), " due to the price shock ", MathAbs((OrderOpenPrice() - gprice_464) / Digits), " pips");
                  if (li116) Print("OrderOpenPrise ", DoubleToStr(OrderOpenPrice(), Digits), ", PRICE_SELL ", DoubleToStr(gprice_464, Digits));
               } else {
                  if (li72 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) >= 0.0 && iClose(NULL, PERIOD_M1, 0) > iOpen(NULL, PERIOD_M1, 0) && Close[0] > iHigh(NULL, PERIOD_M1, 1) && iClose(NULL, PERIOD_M1, 1) > iOpen(NULL, PERIOD_M1, 1) ||
                     iClose(NULL, PERIOD_M1, 1) > iHigh(NULL, PERIOD_M1, 1) - (iHigh(NULL, PERIOD_M1, 1) - iLow(NULL, PERIOD_M1, 1)) / 3.0) {
                     OrderClose(OrderTicket(), OrderLots(), Ask, 3, Yellow);
                     if (li116) Print("Close Order ", OrderTicket(), " ---> minimum_risk_M1");
                  } else {
                     if (li76 == TRUE && (OrderProfit()+OrderCommission()+OrderSwap()) >= 0.0 && iClose(NULL, PERIOD_M5, 0) > iOpen(NULL, PERIOD_M5, 0) && Close[0] > iHigh(NULL, PERIOD_M5, 1) && iClose(NULL, PERIOD_M5, 1) > iOpen(NULL, PERIOD_M5, 1) ||
                        iClose(NULL, PERIOD_M5, 1) > iHigh(NULL, PERIOD_M5, 1) - (iHigh(NULL, PERIOD_M5, 1) - iLow(NULL, PERIOD_M5, 1)) / 3.0) {
                        OrderClose(OrderTicket(), OrderLots(), Ask, 3, Yellow);
                        if (li116) Print("Close Order ", OrderTicket(), " ---> minimum_risk_M5");
                     } else {
                        if (OrderStopLoss() > OrderOpenPrice()) {
                           if (li52 == TRUE && OrderOpenPrice() - Ask >= Point * MathCeil(lstoplevel136 * ld_84) && OrderStopLoss() - Ask > MathCeil(lstoplevel136 * ld_84) * Point) {
                              OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + MathCeil(lstoplevel136 * ld_248) * Point, Digits), OrderTakeProfit(), 0, Pink);
                              Print("Ставлю в ноль SELL ордер ", OrderTicket());
                              continue;
                           }
                           if (li52 == TRUE && OrderOpenPrice() - Ask >= Point * MathCeil(lstoplevel136 * ld_84) && OrderStopLoss() - Ask > MathCeil(lstoplevel136 * ld_84) * Point && OrderStopLoss() > NormalizeDouble(Ask +
                              MathCeil(lstoplevel136 * ld_248 + lstoplevel136 / 10.0) * Point, Digits)) {
                              OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + MathCeil(lstoplevel136 * ld_248 + lstoplevel136 / 10.0) * Point, Digits), OrderTakeProfit(),        

Recommend