Код:
extern int TakeProfit = 3;
extern int StopLoss = 40;
extern int Change = 4;
extern int Deviation = 4;
extern int Cls = 20;
extern string TimesList = "15-16/17-9";
extern int Risk = 50;
extern string NewsList = "09:30/11:30/12:30/13:30/14:30";
extern bool ShowNews = TRUE;
extern color NewsColor = Red;
extern int MinutesBeforeNews = 30;
extern int MinutesAfterNews = 30;
extern int MaxSpread = 3;
extern int mn = 2008;
extern string name_expert = "EurUsd";
int gi_136 = 0;
int gia_140[];
int gia_144[][2];
int g_ticket_148;
int g_ticket_152;
int g_ord_total_156;
int gi_160 = 0;
int gi_164 = 0;
int gi_168 = 0;
int gi_172 = 0;
double g_price_176;
double gd_184;
double gd_192;
double gd_200;
double gd_208;
double gd_216;
double gd_224;
double gd_232;
double g_ima_240;
double gd_248;
double g_minlot_256;
double g_time_264 = 0.0;
int g_datetime_272 = 0;
int g_datetime_276 = 0;

void init() {
   string lsa_0[];
   string lsa_8[];
   ArrayResize(gia_140, 0);
   if (StringTrimLeft(StringTrimRight(NewsList)) != "") {
      fSplitStrToStr(NewsList, lsa_0, "/");
      ArrayResize(gia_140, ArraySize(lsa_0));
      for (int l_index_4 = 0; l_index_4 < ArraySize(lsa_0); l_index_4++) gia_140[l_index_4] = StrToTime(lsa_0[l_index_4]);
   }
   ArrayResize(gia_144, 0);
   TimesList = StringTrimLeft(StringTrimRight(TimesList));
   if (TimesList != "") {
      fSplitStrToStr(TimesList, lsa_0, "/");
      ArrayResize(gia_144, ArraySize(lsa_0));
      for (l_index_4 = 0; l_index_4 < ArraySize(lsa_0); l_index_4++) {
         fSplitStrToStr(lsa_0[l_index_4], lsa_8, "-");
         gia_144[l_index_4][0] = StrToInteger(lsa_8[0]);
         gia_144[l_index_4][1] = StrToInteger(lsa_8[1]);
      }
   }
   g_time_264 = 0;
}

int start() {
   if (ShowNews) fNews();
   if (Time[0] <= g_time_264) return (0);
   gd_208 = MarketInfo(Symbol(), MODE_STOPLEVEL);
   gd_208 = (gd_208 + 1.0) * Point;
   gd_184 = StopLoss * Point;
   gd_192 = TakeProfit * Point;
   gd_200 = Change * Point;
   gd_232 = Cls * Point;
   gd_248 = Ask - Bid;
   g_ord_total_156 = OrdersTotal();
   gi_160 = FALSE;
   gi_164 = FALSE;
   gi_168 = FALSE;
   gi_172 = FALSE;
   for (int l_pos_0 = g_ord_total_156 - 1; l_pos_0 >= 0; l_pos_0--) {
      if (OrderSelect(l_pos_0, SELECT_BY_POS, MODE_TRADES) == TRUE) {
         if (OrderSymbol() == Symbol()) {
            if (OrderType() == OP_BUY) {
               gi_168 = TRUE;
               if (!Close_B(OrderTicket(), OrderLots())) return (0);
               RefreshRates();
            }
            if (OrderType() == OP_SELL) {
               gi_172 = TRUE;
               if (!Close_S(OrderTicket(), OrderLots())) return (0);
               RefreshRates();
            }
            if (OrderType() == OP_BUYLIMIT) {
               gd_216 = NormalizeDouble(OrderOpenPrice(), Digits);
               g_ticket_148 = OrderTicket();
               gi_160 = TRUE;
            }
            if (OrderType() == OP_SELLLIMIT) {
               gd_224 = NormalizeDouble(OrderOpenPrice(), Digits);
               g_ticket_152 = OrderTicket();
               gi_164 = TRUE;
            }
         }
      } else return (0);
   }
   g_ima_240 = iMA(NULL, PERIOD_M1, Deviation, 0, MODE_LWMA, PRICE_TYPICAL, 0);
   bool li_4 = Modify_order();
   if (!TimeCanOpen()) {
      if (fOrderDeleteLimit(1, 1) != 0) return (0);
   } else {
      if (NewsCanOpen()) {
         if (NormalizeDouble(gd_248, Digits) <= NormalizeDouble(MaxSpread * Point, Digits)) {
            RefreshRates();
            Open_order();
         }
      } else
         if (fOrderDeleteLimit(1, 1) != 0) return (0);
   }
   if (li_4) g_time_264 = Time[0];
}

bool TimeCanOpen() {
   if (TimesList == "") return (TRUE);
   int l_hour_0 = TimeHour(TimeCurrent());
   for (int l_index_4 = 0; l_index_4 < ArraySize(gia_144) / 2; l_index_4++) {
      if (gia_144[l_index_4][0] < gia_144[l_index_4][1])
         if (l_hour_0 >= gia_144[l_index_4][0] && l_hour_0 < gia_144[l_index_4][1]) return (TRUE);
      if (gia_144[l_index_4][0] > gia_144[l_index_4][1])
         if (l_hour_0 >= gia_144[l_index_4][0] || l_hour_0 < gia_144[l_index_4][1]) return (TRUE);
   }
   return (FALSE);
}

int Open_order() {
   if (gi_168 == FALSE && gi_160 == FALSE) {
      switch (gi_136) {
      case 0:
         g_price_176 = g_ima_240 - gd_200;
         if (g_price_176 > Ask - gd_208) g_price_176 = Ask - gd_208;
         g_price_176 = NormalizeDouble(g_price_176, Digits);
         if (OrderSend(Symbol(), OP_BUYLIMIT, Lots(), g_price_176, 3, g_price_176 - gd_184, g_price_176 + gd_192, name_expert, mn, 0, Blue) > 0) gi_160 = TRUE;
         else
            if (GetLastError() != 4110/* LONGS__NOT_ALLOWED */) return (0);
      case 1:
         g_price_176 = Ask;
         g_price_176 = NormalizeDouble(g_price_176, Digits);
         if (OrderSend(Symbol(), OP_BUY, Lots(), g_price_176, 3, g_price_176 - gd_184, g_price_176 + gd_192, name_expert, mn, 0, Blue) > 0) gi_168 = TRUE;
         else
            if (GetLastError() != 4110/* LONGS__NOT_ALLOWED */) return (0);
      }
   }
   if (gi_172 == FALSE && gi_164 == FALSE) {
      switch (gi_136) {
      case 0:
         g_price_176 = g_ima_240 + gd_248 + gd_200;
         if (g_price_176 < Bid + gd_208) g_price_176 = Bid + gd_208;
         g_price_176 = NormalizeDouble(g_price_176, Digits);
         if (OrderSend(Symbol(), OP_SELLLIMIT, Lots(), g_price_176, 3, g_price_176 + gd_184, g_price_176 - gd_192, name_expert, mn, 0, Red) > 0) gi_164 = TRUE;
         else
            if (GetLastError() != 4110/* LONGS__NOT_ALLOWED */) return (0);
      case 1:
         g_price_176 = Bid;
         g_price_176 = NormalizeDouble(g_price_176, Digits);
         if (OrderSend(Symbol(), OP_SELL, Lots(), g_price_176, 3, g_price_176 + gd_184, g_price_176 - gd_192, name_expert, mn, 0, Red) > 0) gi_172 = TRUE;
         else
            if (GetLastError() != 4110/* LONGS__NOT_ALLOWED */) return (0);
      }
   }
   return (1);
}

bool Close_B(int a_ticket_0, double a_lots_4) {
   if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) >= gd_232) {
      if (OrderClose(a_ticket_0, a_lots_4, Bid, 1, Yellow)) gi_168 = FALSE;
      else return (FALSE);
   }
   return (TRUE);
}

bool Close_S(int a_ticket_0, double a_lots_4) {
   if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) >= gd_232) {
      if (OrderClose(a_ticket_0, a_lots_4, Ask, 1, Yellow)) gi_172 = FALSE;
      else return (FALSE);
   }
   return (TRUE);
}

int Modify_order() {
   if (gi_160 == TRUE) {
      g_price_176 = g_ima_240 - gd_200;
      if (MathAbs(gd_216 - g_price_176) > Point / 2.0)
         if (!OrderModify(g_ticket_148, g_price_176, g_price_176 - gd_184, g_price_176 + gd_192, 0, DeepSkyBlue)) return (0);
   }
   if (gi_164 == TRUE) {
      g_price_176 = g_ima_240 + gd_248 + gd_200;
      if (MathAbs(gd_224 - g_price_176) > Point / 2.0)
         if (!OrderModify(g_ticket_152, g_price_176, g_price_176 + gd_184, g_price_176 - gd_192, 0, Pink)) return (0);
   }
   return (1);
}

int fOrderDeleteLimit(bool ai_0 = TRUE, bool ai_4 = TRUE) {
   int li_ret_8 = 0;
   for (int l_pos_12 = OrdersTotal() - 1; l_pos_12 >= 0; l_pos_12--) {
      if (OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol()) {
            if (OrderType() == OP_BUYLIMIT) {
               if (ai_0) {
                  RefreshRates();
                  if (!IsTradeContextBusy()) {
                     if (!OrderDelete(OrderTicket())) li_ret_8 = -1;
                  } else {
                     if (TimeCurrent() > g_datetime_272 + 20) {
                        g_datetime_272 = TimeCurrent();
                        Print("Need delete BUYLIMIT " + OrderTicket() + ". Trade Context Busy");
                     }
                     return (-2);
                  }
               }
            }
            if (OrderType() == OP_SELLLIMIT) {
               if (ai_4) {
                  RefreshRates();
                  if (!IsTradeContextBusy()) {
                     if (!OrderDelete(OrderTicket())) li_ret_8 = -1;
                  } else {
                     if (TimeCurrent() > g_datetime_276 + 20) {
                        g_datetime_276 = TimeCurrent();
                        Print("Need delete SELLSTOP " + OrderTicket() + ". Trade Context Busy");
                     }
                     return (-2);
                  }
               }
            }
         }
      }
   }
   return (li_ret_8);
}

double Lots() {
   g_minlot_256 = NormalizeDouble(AccountEquity() * Risk / 100.0 / 1000.0, 1);
   double l_minlot_0 = MarketInfo(Symbol(), MODE_MINLOT);
   if (g_minlot_256 == 0.0) g_minlot_256 = l_minlot_0;
   return (g_minlot_256);
}

void fSplitStrToStr(string as_0, string &asa_8[], string as_12) {
   string ls_20 = "";
   string ls_28 = "";
   ArrayResize(asa_8, 0);
   for (int li_36 = 0; li_36 < StringLen(as_0); li_36++) {
      ls_28 = StringSubstr(as_0, li_36, 1);
      if (ls_28 == as_12) {
         if (StringTrimLeft(StringTrimRight(ls_20)) != "") {
            ArrayResize(asa_8, ArraySize(asa_8) + 1);
            asa_8[ArraySize(asa_8) - 1] = ls_20;
         }
         ls_20 = "";
      } else ls_20 = ls_20 + ls_28;
   }
   if (StringTrimLeft(StringTrimRight(ls_20)) != "") {
      ArrayResize(asa_8, ArraySize(asa_8) + 1);
      asa_8[ArraySize(asa_8) - 1] = ls_20;
   }
   ArraySize(asa_8);
}

void fObjVLine(string a_name_0, int a_datetime_8, color a_color_12 = 255, int a_width_16 = 1, int a_window_20 = 0, int a_style_24 = 0, bool a_bool_28 = FALSE) {
   if (ObjectFind(a_name_0) != a_window_20) ObjectCreate(a_name_0, OBJ_VLINE, a_window_20, a_datetime_8, 0);
   ObjectSet(a_name_0, OBJPROP_TIME1, a_datetime_8);
   ObjectSet(a_name_0, OBJPROP_COLOR, a_color_12);
   ObjectSet(a_name_0, OBJPROP_WIDTH, a_width_16);
   ObjectSet(a_name_0, OBJPROP_BACK, a_bool_28);
   ObjectSet(a_name_0, OBJPROP_STYLE, a_style_24);
}

void fObjDeleteByPrefix(string as_0) {
   for (int li_8 = ObjectsTotal() - 1; li_8 >= 0; li_8--)
      if (StringFind(ObjectName(li_8), as_0, 0) == 0) ObjectDelete(ObjectName(li_8));
}

void fNews() {
   for (int l_index_0 = 0; l_index_0 < ArraySize(gia_140); l_index_0++) {
      fObjVLine("Another_News_" + l_index_0, gia_140[l_index_0], NewsColor, 1, 0, STYLE_SOLID, TRUE);
      ObjectSetText("Another_News_" + l_index_0, TimeToStr(gia_140[l_index_0]));
   }
}

int deinit() {
   fObjDeleteByPrefix("Another_News_");
   return (0);
}

bool NewsCanOpen() {
   for (int l_index_0 = 0; l_index_0 < ArraySize(gia_140); l_index_0++)
      if (TimeCurrent() >= gia_140[l_index_0] - 60 * MinutesBeforeNews && TimeCurrent() < gia_140[l_index_0] + 60 * MinutesAfterNews) return (FALSE);
   return (TRUE);
}