Navigation:Home > Content >

Ultra+Fibonator+v01~.mq4

Time: 2010-10-19 | Download file:Ultra+Fibonator+v01~.mq4

#property copyright "Trading-SYS.COM, Copyright © 2012, Vlad Gilka"
#property link      "http://trading-sys.com/"

extern int Expert_Id = 1;
extern string Настройки_Лота = "----Лот----";
extern double Lot = 0.1;
extern int TotalOpen = 15;
string gs_unused_100 = "-------Blocks-Of-Positions-------";
int gi_108 = 15;
int gi_112 = 35;
string gs_unused_116 = "-------Signal-Properties-------";
string gs_unused_124 = "----MA-Channels-FIBO----";
string gs_unused_132 = "----General----";
string gs_unused_140 = "1 - (-23.5%), 2 - (-38.2%), 3 - (-50%), 4 - (-61.8%)";
int gi_148 = 3;
string gs_unused_152 = "1 - (23.5%), 2 - (38.2%), 3 - (50%), 4 - (61.8%)";
int gi_160 = 2;
int gi_164 = 3;
string gs_unused_168 = "1 - (23.5%), 2 - (38.2%), 3 - (50%), 4 - (61.8%)";
int gi_176 = 3;
string gs_unused_180 = "1 - (-23.5%), 2 - (-38.2%), 3 - (-50%), 4 - (-61.8%)";
int gi_188 = 2;
int gi_192 = 3;
extern string Нстройки_Сигналов = "----Нстройки-Сигналов----";
extern int BarsCount = 500;
extern int MAPeriod = 100;
int g_ma_method_212 = MODE_EMA;
int g_applied_price_216 = PRICE_CLOSE;
string gs_unused_220 = "----Momentum-Pinball----";
string gs_unused_228 = "----General----";
double gd_236 = 30.0;
double gd_244 = 70.0;
string gs_unused_252 = "----Input----";
int g_period_260 = 3;
int gi_264 = 1;
string gs_unused_268 = "----SMA----";
string gs_unused_276 = "----Input----";
extern int SMAPeriod = 200;
int g_ma_method_288 = MODE_EMA;
int g_applied_price_292 = PRICE_CLOSE;
extern string Нстройки_оповещения = "----Оповещение-о-Просадке----";
extern bool AlertOnDrawDown = TRUE;
extern double TotalDrawDown = 10.0;
extern string Trade_Properties = "--------Trade-Properties-------";
extern int Slippage = 5;
extern int PauseBeforeTrade = 1;
extern int MaxWaitingTime = 300;
extern bool IgnorIsConnected = TRUE;
extern color OrderBuyColor = Lime;
extern color OrderSellColor = Red;
extern string Allow_Flags = "-----------Allow-Flags---------";
extern bool Allow_Info = TRUE;
extern bool Allow_LogFile = TRUE;
extern bool Allow_TradeLogFile = TRUE;
extern bool Allow_ErrorMail = TRUE;
extern bool Allow_ErrorLogFile = TRUE;
extern string Info_Properties = "--------Info-Properties--------";
extern bool EnglishInfo = FALSE;
extern int Font_Size_Variant = 4;
extern color Standart_Color = White;
extern color Warning_Color = Fuchsia;
extern color Price_Up_Color = Lime;
extern color Price_Down_Color = Red;
string gs_408;
string gs_416;
string gs_arial_424 = "Arial";
double g_fontsize_432;
double g_fontsize_440;
string g_symbol_448;
string gs_456;
int g_timeframe_464;
int g_magic_468;
int g_digits_472;
double g_point_476;
double gd_484;
double gd_492;
int g_datetime_500;
string gs_504 = "Сервер ";
string gs_512 = "РЕАЛЬНЫЙ СЧЁТ #";
string gs_520 = "Демо-счёт #";
string gs_528 = "ТОРГОВЛЯ РАЗРЕШЕНА!";
string gs_536 = "Торговля запрещена";
string gs_544 = "Эксперт успешно загружен...";
string gs_552 = "Есть позиция, открытая экспертом:";
string gs_560 = "Есть ордер, установленный экспертом:";
string gs_568 = "Пунктов до срабатывания - ";
string gs_unused_576 = "Эксперт остановлен!";
string gs_unused_584 = "Глобальная переменная";
string gs_unused_592 = "должна быть >= 0!";
string gs_600 = "Слишком мало баров на графике!";
string gs_608 = "Неправильные параметры";
string gs_616 = "Неправильный тип позиции";
string gs_624 = " - Неправильный объем!!!";
string gs_632 = " - Неправильно (выше";
string gs_640 = " - Неправильно (ниже";
string gs_648 = " - Неправильно (слишком близко к";
string gs_656 = " - Для маркет-ордера нельзя установить время истечения!!!";
string gs_664 = " - Время истечения нельзя установить в прошлом!!!";
string gs_672 = "Устанавливаем ";
string gs_680 = "-ордер...";
string gs_688 = "Открываем ";
string gs_696 = " позицию...";
string gs_704 = "Проверяем параметры.....";
string gs_712 = "Проверяем параметры.....Ошибка!";
string gs_720 = "Проверяем параметры.....Все правильно...";
string gs_728 = "Нет соединения с сервером";
string gs_736 = "Эксперт остановлен пользователем";
string gs_744 = "Время ожидания истекло";
string gs_752 = "Успешно...";
int gi_760 = 0;
int g_count_764 = 0;
int g_count_768 = 0;
int gi_unused_772 = 0;
double gd_unused_776 = 0.0;
double gd_unused_784 = 0.0;
double gd_unused_792 = 0.0;
double gd_unused_800 = 0.0;
int gi_unused_808 = -1;
double gd_unused_812 = 0.0;
double gd_unused_820 = 0.0;
double gd_unused_828 = 0.0;
string gs_unused_836 = "";
int gi_unused_844 = 0;
double gd_unused_848 = 0.0;
double gd_unused_856 = 0.0;
double gd_unused_864 = 0.0;
double gd_unused_872 = 0.0;
int gi_unused_880 = -1;
double gd_unused_884 = 0.0;
double gd_unused_892 = 0.0;
double gd_unused_900 = 0.0;
string gs_unused_908 = "";
int gi_unused_916 = 0;
double gd_unused_920 = 0.0;
double gd_unused_928 = 0.0;
double gd_unused_936 = 0.0;
double gd_unused_944 = 0.0;
int gi_unused_952 = -1;
string gs_unused_956 = "";
int gi_unused_964 = -1;
int gi_unused_968 = 0;
double gd_unused_972 = 0.0;
double gd_unused_980 = 0.0;
double gd_unused_988 = 0.0;
double gd_unused_996 = 0.0;
int gi_unused_1004 = -1;
string gs_unused_1008 = "";
int gi_unused_1016 = -1;
int gi_unused_1020 = 0;
double gd_unused_1024 = 0.0;
double gd_unused_1032 = 0.0;
double gd_unused_1040 = 0.0;
double gd_unused_1048 = 0.0;
int gi_unused_1056 = -1;
string gs_unused_1060 = "";
int gi_unused_1068 = -1;
int gi_unused_1072 = 0;
double gd_unused_1076 = 0.0;
double gd_unused_1084 = 0.0;
double gd_unused_1092 = 0.0;
double gd_unused_1100 = 0.0;
int gi_unused_1108 = -1;
string gs_unused_1112 = "";
int gi_unused_1120 = -1;
string g_symbol_1124 = "";
string g_comment_1132 = "";
int g_cmd_1140 = OP_BUY;
int g_slippage_1144 = 0;
int g_magic_1148 = 0;
int gi_1152 = 0;
int g_error_1156 = 0/* NO_ERROR */;
double g_lots_1160 = 0.0;
double g_price_1168 = 0.0;
double g_price_1176 = 0.0;
double g_price_1184 = 0.0;
int g_datetime_1192 = 0;
int g_color_1196 = CLR_NONE;
int g_ticket_1200 = -1;
string g_symbol_1204 = "";
string gs_1212 = "";
int g_ticket_1220 = 0;
int g_cmd_1224 = OP_BUY;
int g_magic_1228 = 0;
int gi_1232 = 0;
int g_error_1236 = 0/* NO_ERROR */;
double gd_1240 = 0.0;
double gd_1248 = 0.0;
double gd_1256 = 0.0;
double gd_1264 = 0.0;
double g_price_1272 = 0.0;
double g_price_1280 = 0.0;
double g_price_1288 = 0.0;
int g_datetime_1296 = 0;
int g_datetime_1300 = 0;
int g_color_1304 = CLR_NONE;
bool g_bool_1308 = FALSE;
string g_symbol_1312 = "";
string g_dbl2str_1320 = "";
string g_comment_1328 = "";
int g_ticket_1336 = 0;
int g_cmd_1340 = OP_BUY;
int g_magic_1344 = 0;
int g_slippage_1348 = 0;
int gi_1352 = 0;
int g_error_1356 = 0/* NO_ERROR */;
double g_lots_1360 = 0.0;
double gd_1368 = 0.0;
double g_order_open_price_1376 = 0.0;
double g_price_1384 = 0.0;
int g_color_1392 = CLR_NONE;
bool g_is_closed_1396 = FALSE;
string gs_1400 = "";
int g_ticket_1408 = 0;
int g_cmd_1412 = OP_BUY;
int g_magic_1416 = 0;
int gi_1420 = 0;
int g_error_1424 = 0/* NO_ERROR */;
bool g_is_deleted_1428 = FALSE;
string g_symbol_1432 = "";
string gs_1440 = "";
int g_ticket_1448 = 0;
int gi_1452 = 0;
int gi_1456 = 0;
int g_cmd_1460 = OP_BUY;
int g_magic_1464 = 0;
int gi_1468 = 0;
int g_error_1472 = 0/* NO_ERROR */;
double g_price_1476 = 0.0;
double gd_1484 = 0.0;
double g_price_1492 = 0.0;
double g_price_1500 = 0.0;
double gd_1508 = 0.0;
double gd_1516 = 0.0;
int g_datetime_1524 = 0;
int g_color_1528 = CLR_NONE;
bool g_bool_1532 = FALSE;
double gd_1536 = 0.0;
string g_symbol_1544 = "";
string gs_1552 = "";
int g_ticket_1560 = 0;
int gi_1564 = 0;
int gi_1568 = 0;
int g_cmd_1572 = OP_BUY;
int g_magic_1576 = 0;
int gi_1580 = 0;
int g_error_1584 = 0/* NO_ERROR */;
double g_price_1588 = 0.0;
double g_price_1596 = 0.0;
double gd_1604 = 0.0;
double g_price_1612 = 0.0;
double gd_1620 = 0.0;
double gd_1628 = 0.0;
int g_datetime_1636 = 0;
int g_color_1640 = CLR_NONE;
bool g_bool_1644 = FALSE;
double gd_1648 = 0.0;
int gia_1656[][2];
int g_count_1660 = 0;
int g_count_1664 = 0;
int g_count_1668 = 0;
int g_count_1672 = 0;
int g_count_1676 = 0;
int g_count_1680 = 0;
int g_count_1684 = 0;
int g_count_1688 = 0;
int g_count_1692 = 0;
int g_count_1696 = 0;
int g_count_1700 = 0;
int g_count_1704 = 0;
bool gi_1708 = TRUE;
int gi_1712 = 0;
int g_datetime_1716 = 0;
double gd_1720 = 0.0;
bool gi_1728 = FALSE;
int gi_1732 = 0;
int gi_1736 = 0;
int gi_1740 = 0;
int gi_1744 = 0;
int g_datetime_1748 = 0;
int g_datetime_1752 = 0;
double g_str2dbl_1756 = 0.0;
int g_hist_total_1764 = -1;
int g_datetime_1768 = 0;
int g_datetime_1772 = 0;
int gi_1776 = -1;
int gi_1780 = -1;
double gda_1784[8];
int gia_1788[];
int gia_1792[];
double gda_1796[];
int gia_1800[];
double gda_1804[];
double gda_1808[];
double gda_1812[];
int gia_1816[];
double gda_1820[];
string gsa_1824[4];
bool gi_1828 = FALSE;

void f0_76() {
   string lsa_unused_0[];
}

void f0_46(int a_magic_0, string as_4) {
   f0_76();
   if (EnglishInfo) {
      gs_504 = "Server ";
      gs_512 = "REAL ACCOUNT #";
      gs_520 = "Demo account #";
      gs_528 = "TRADE IS ALLOWED!";
      gs_536 = "Trade is not allowed";
      gs_544 = "Expert loaded successfully...";
      gs_552 = " - position opened by this expert:";
      gs_560 = " - order opened by this expert:";
      gs_568 = "Points to execution - ";
      gs_unused_576 = "Expert was stopped!";
      gs_unused_584 = "Global variable";
      gs_unused_592 = "must be >= 0!";
      gs_600 = "Bars less than 100!";
      gs_608 = "Invalid trade parameters";
      gs_616 = "Invalid OrderType";
      gs_624 = " - invalid volume!!!";
      gs_632 = " - Incorrect (above";
      gs_640 = " - Incorrect (below";
      gs_648 = " - Incorrect (too beside to";
      gs_656 = " - It is impossible to set expiration time for market-orders!!!";
      gs_664 = " - Expiration time must be more than Current Time!!!";
      gs_672 = "Sending ";
      gs_680 = "-order...";
      gs_688 = "Sending ";
      gs_696 = " position...";
      gs_704 = "Checking.....";
      gs_712 = "Checking.....Error!";
      gs_720 = "Checking.....OK...";
      gs_728 = "No connection with trade server";
      gs_736 = "Expert was stopped by user";
      gs_744 = "Limit of waiting time";
      gs_752 = "Successfully...";
   }
   if (IsTesting()) {
      if (!IsVisualMode()) Allow_Info = FALSE;
      Allow_LogFile = FALSE;
      Allow_TradeLogFile = FALSE;
      Allow_ErrorMail = FALSE;
      Allow_ErrorLogFile = FALSE;
   }
   g_datetime_500 = 0;
   g_symbol_448 = Symbol();
   g_timeframe_464 = Period();
   g_digits_472 = MarketInfo(g_symbol_448, MODE_DIGITS);
   g_point_476 = MarketInfo(g_symbol_448, MODE_POINT);
   gd_484 = NormalizeDouble((MarketInfo(g_symbol_448, MODE_STOPLEVEL) + 1.0) * g_point_476, g_digits_472);
   gd_492 = NormalizeDouble(MarketInfo(g_symbol_448, MODE_SPREAD) * g_point_476, g_digits_472);
   gs_416 = f0_85(g_timeframe_464);
   g_magic_468 = a_magic_0;
   if (as_4 == "") gs_456 = WindowExpertName();
   else gs_456 = as_4;
   gs_408 = gs_456 + " (" + g_symbol_448 + ", " + gs_416 + ")";
   f0_32();
   int li_12 = 16;
   int li_16 = 350;
   switch (Font_Size_Variant) {
   case 1:
      g_fontsize_432 = 5;
      g_fontsize_440 = 5;
      li_12 = 8;
      li_16 = 180;
      break;
   case 2:
      g_fontsize_432 = 6;
      g_fontsize_440 = 7;
      li_12 = 9;
      li_16 = 200;
      break;
   case 3:
      g_fontsize_432 = 7;
      g_fontsize_440 = 8;
      li_12 = 11;
      li_16 = 230;
      break;
   case 4:
      g_fontsize_432 = 8;
      g_fontsize_440 = 9;
      li_12 = 13;
      li_16 = 270;
      break;
   case 5:
      g_fontsize_432 = 9;
      g_fontsize_440 = 11;
      li_12 = 15;
      li_16 = 310;
      break;
   case 6:
      g_fontsize_432 = 10;
      g_fontsize_440 = 12;
      li_12 = 16;
      li_16 = 350;
      break;
   case 7:
      g_fontsize_432 = 11;
      g_fontsize_440 = 13;
      li_12 = 18;
      li_16 = 390;
      break;
   case 8:
      g_fontsize_432 = 12;
      g_fontsize_440 = 14;
      li_12 = 20;
      li_16 = 430;
      break;
   case 9:
      g_fontsize_432 = 13;
      g_fontsize_440 = 15;
      li_12 = 22;
      li_16 = 480;
      break;
   case 10:
      g_fontsize_432 = 14;
      g_fontsize_440 = 16;
      li_12 = 24;
      li_16 = 530;
      break;
   default:
      g_fontsize_432 = 10;
      g_fontsize_440 = 12;
      li_12 = 16;
      li_16 = 350;
   }
   f0_27("ExpertLog_00", 4, 15);
   f0_27("ExpertLog_01", 4, li_12 + 15);
   f0_27("ExpertLog_02", 4, li_12 * 2 + 15);
   f0_27("ExpertLog_03", 4, 3 * li_12 + 15);
   f0_27("ExpertLog_04", 4, li_12 * 4 + 15);
   f0_27("ExpertLog_10", li_16, 15);
   f0_27("ExpertLog_11", li_16, li_12 + 15);
   f0_27("ExpertLog_12", li_16, li_12 * 2 + 15);
   f0_27("ExpertLog_13", li_16, 3 * li_12 + 15);
   f0_27("ExpertLog_14", li_16, li_12 * 4 + 15);
   string ls_24 = gs_512;
   bool li_32 = TRUE;
   if (IsDemo()) {
      ls_24 = gs_520;
      li_32 = FALSE;
   }
   string ls_36 = gs_528;
   bool li_44 = TRUE;
   if (!IsTradeAllowed()) {
      ls_36 = gs_536;
      li_44 = FALSE;
   }
   f0_74();
   f0_10("\n");
   f0_10("++---------Initialization---------++");
   f0_51(1, gs_504 + AccountServer(), 0);
   f0_51(2, ls_24 + AccountNumber() + " ( " + AccountName() + " )", li_32);
   f0_51(3, ls_36, li_44);
   f0_51(4, gs_544, 0);
   f0_10("++--------------------------------++\n");
   ObjectsRedraw();
}

int f0_0() {
   if (IsTesting()) {
      if (!(IsVisualMode())) return (1);
      f0_74();
      return (1);
   }
   gd_484 = NormalizeDouble((MarketInfo(g_symbol_448, MODE_STOPLEVEL) + 1.0) * g_point_476, g_digits_472);
   gd_492 = NormalizeDouble(MarketInfo(g_symbol_448, MODE_SPREAD) * g_point_476, g_digits_472);
   f0_74();
   if (Bars < 100) {
      f0_51(1, gs_600, 1);
      return (0);
   }
   if (!IsExpertEnabled()) {
      f0_51(1, "Experts are disabled!", 1, 0);
      return (0);
   }
   return (1);
}

void f0_72() {
   if (Allow_Info) {
      for (int count_0 = 0; count_0 < 2; count_0++) for (int count_4 = 0; count_4 < 5; count_4++) ObjectDelete(StringConcatenate("ExpertLog_", count_0, count_4));
      GetLastError();
   }
}

void f0_51(int ai_0, string a_text_4 = "", int ai_12 = 0, bool ai_16 = TRUE) {
   int error_20;
   string name_24;
   double fontsize_32;
   color color_44;
   if (Allow_Info) {
      fontsize_32 = g_fontsize_432;
      switch (ai_0) {
      case 0:
         name_24 = "ExpertLog_00";
         fontsize_32 = g_fontsize_440;
         break;
      case 1:
         name_24 = "ExpertLog_01";
         break;
      case 2:
         name_24 = "ExpertLog_02";
         break;
      case 3:
         name_24 = "ExpertLog_03";
         break;
      case 4:
         name_24 = "ExpertLog_04";
         break;
      case 10:
         name_24 = "ExpertLog_10";
         fontsize_32 = g_fontsize_440;
         break;
      case 11:
         name_24 = "ExpertLog_11";
         break;
      case 12:
         name_24 = "ExpertLog_12";
         break;
      case 13:
         name_24 = "ExpertLog_13";
         break;
      case 14:
         name_24 = "ExpertLog_14";
         break;
      default:
         name_24 = "ExpertLog_01";
      }
      switch (ai_12) {
      case 1:
         color_44 = Warning_Color;
         break;
      case 2:
         color_44 = Price_Up_Color;
         break;
      case 3:
         color_44 = Price_Down_Color;
         break;
      default:
         color_44 = Standart_Color;
      }
      if (!ObjectSetText("ExpertLog_00", "Expert log ( " + TimeToStr(TimeLocal(), TIME_SECONDS) + " )", g_fontsize_440, gs_arial_424, Standart_Color)) error_20 = GetLastError();
      if (!ObjectSetText(name_24, a_text_4, fontsize_32, gs_arial_424, color_44)) error_20 = GetLastError();
   }
   if (a_text_4 != "" && ai_16) f0_10(a_text_4);
}

void f0_74() {
   if (Allow_Info) {
      for (int count_0 = 0; count_0 < 2; count_0++) for (int count_4 = 0; count_4 < 5; count_4++) ObjectSetText(StringConcatenate("ExpertLog_", count_0, count_4), "", 10);
      GetLastError();
   }
}

void f0_27(string a_name_0, int a_x_8, int a_y_12, int a_corner_16 = 0) {
   int error_20;
   if (Allow_Info) {
      if (!ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0)) {
         error_20 = GetLastError();
         if (error_20 != 4200/* OBJECT_ALREADY_EXISTS */) {
            Print("|  _LabelCreate( \"", a_name_0, "\", ", a_x_8, ", ", a_y_12, ", ", a_corner_16, " ) - ObjectCreate( \"", a_name_0, "\", OBJ_LABEL,0,0,0 ) - Error #", error_20,
               " ( ", f0_78(error_20), " )");
            return;
         }
      }
      if (!ObjectSet(a_name_0, OBJPROP_CORNER, a_corner_16)) {
         error_20 = GetLastError();
         Print("|  _LabelCreate( \"", a_name_0, "\", ", a_x_8, ", ", a_y_12, ", ", a_corner_16, " ) - ObjectSet( \"", a_name_0, "\", OBJPROP_CORNER, ", a_corner_16, " ) - Error #",
            error_20, " ( ", f0_78(error_20), " )");
      }
      if (!ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_8)) {
         error_20 = GetLastError();
         Print("|  _LabelCreate( \"", a_name_0, "\", ", a_x_8, ", ", a_y_12, ", ", a_corner_16, " ) - ObjectSet( \"", a_name_0, "\", OBJPROP_XDISTANCE, ", a_x_8, " ) - Error #",
            error_20, " ( ", f0_78(error_20), " )");
      }
      if (!ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_12)) {
         error_20 = GetLastError();
         Print("|  _LabelCreate( \"", a_name_0, "\", ", a_x_8, ", ", a_y_12, ", ", a_corner_16, " ) - ObjectSet( \"", a_name_0, "\", OBJPROP_YDISTANCE, ", a_y_12, " ) - Error #",
            error_20, " ( ", f0_78(error_20), " )");
      }
      if (!ObjectSetText(a_name_0, "", 10)) {
         error_20 = GetLastError();
         Print("|  _LabelCreate( \"", a_name_0, "\", ", a_x_8, ", ", a_y_12, ", ", a_corner_16, " ) - ObjectSetText( \"", a_name_0, "\", \"\", 10 ) - Error #", error_20, " ( ",
            f0_78(error_20), " )");
      }
   }
}

void f0_10(string as_0) {
   int error_8;
   string name_12;
   int file_20;
   if (Allow_LogFile) {
      name_12 = "_ExpertLogs\\" + gs_408 + "\\" + TimeToStr(TimeLocal(), TIME_DATE) + ".txt";
      file_20 = FileOpen(name_12, FILE_WRITE|FILE_READ, " ");
      if (file_20 > 0) {
         if (FileSeek(file_20, 0, SEEK_END)) {
            if (as_0 != "\n" && as_0 != "\r\n") as_0 = TimeToStr(TimeLocal(), TIME_SECONDS) + " - - - " + as_0;
            if (FileWrite(file_20, as_0) < 0) {
               error_8 = GetLastError();
               Print("|  _FileWrite( \"" + as_0 + "\" ) - FileWrite ( ", file_20, ", ", as_0, " ) - Error #", error_8, " ( ", f0_78(error_8), " )");
            }
         } else {
            error_8 = GetLastError();
            Print("|  _FileWrite( \"" + as_0 + "\" ) - FileSeek ( " + file_20 + ", 0, SEEK_END ) - Error #", error_8, " ( ", f0_78(error_8), " )");
         }
         FileClose(file_20);
      } else {
         error_8 = GetLastError();
         Print("|  _FileWrite( \"" + as_0 + "\" ) - FileOpen( ", name_12, ", FILE_READ | FILE_WRITE, \" \" ) - Error #", error_8, " ( ", f0_78(error_8), " )");
      }
   }
}

int f0_61(int a_magic_0) {
   int error_4;
   int ticket_32;
   int cmd_36;
   string symbol_40;
   double ld_48;
   double ld_56;
   double ld_64;
   double ld_72;
   double order_profit_80;
   double ld_88;
   double ld_96;
   int li_104;
   double ld_108;
   double ld_116;
   double ld_124;
   string ls_132;
   int li_140;
   bool li_144;
   double ld_148;
   string ls_156;
   string ls_8 = "Прибыль/Убыток: ";
   string ls_16 = "До СтопЛосса:" + " " + " " + " " + " " + " ";
   if (EnglishInfo) {
      ls_8 = "Profit/Loss:" + " " + " " + " " + " " + " " + " " + " " + " ";
      ls_16 = "Distance to SL: ";
   }
   int order_total_24 = OrdersTotal();
   for (int pos_28 = order_total_24 - 1; pos_28 >= 0; pos_28--) {
      if (!OrderSelect(pos_28, SELECT_BY_POS)) {
         error_4 = GetLastError();
         Print("|  _IsExpertOrder( ", a_magic_0, " ) - OrderSelect( ", pos_28, ", SELECT_BY_POS ) - Error #", error_4, " ( ", f0_78(error_4), " )");
      } else {
         if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == g_symbol_448) {
            if (!Allow_Info) return (1);
            ticket_32 = OrderTicket();
            cmd_36 = OrderType();
            symbol_40 = OrderSymbol();
            ld_48 = NormalizeDouble(OrderLots(), 2);
            ld_56 = NormalizeDouble(OrderOpenPrice(), g_digits_472);
            ld_64 = NormalizeDouble(OrderClosePrice(), g_digits_472);
            ld_72 = NormalizeDouble(OrderStopLoss(), g_digits_472);
            order_profit_80 = OrderProfit();
            f0_51(10, "");
            f0_51(11, "");
            f0_51(12, "");
            f0_51(13, "");
            f0_51(14, "");
            if (cmd_36 <= OP_SELL) {
               ld_88 = order_profit_80 + OrderSwap() + OrderCommission();
               ld_96 = MarketInfo(symbol_40, MODE_TICKVALUE) * ld_48;
               li_104 = 0;
               if (ld_88 > 0.0) li_104 = 2;
               if (ld_88 < 0.0) li_104 = 3;
               if (cmd_36 == OP_BUY) ld_108 = (ld_64 - ld_56) / g_point_476;
               else ld_108 = (ld_56 - ld_64) / g_point_476;
               if (cmd_36 == OP_BUY) ld_116 = (ld_72 - ld_56) / g_point_476;
               else ld_116 = (ld_56 - ld_72) / g_point_476;
               ld_124 = ld_116 * ld_96 + OrderSwap() + OrderCommission();
               ls_132 = DoubleToStr(ld_124, 2) + " " + AccountCurrency() + " (" + DoubleToStr(MathAbs(ld_116), 0) + " points)";
               li_140 = 0;
               if (ld_116 > 0.0) li_140 = 2;
               if (ld_116 < 0.0) li_140 = 3;
               if (ld_72 <= 0.0) {
                  li_140 = 1;
                  if (!EnglishInfo) ls_132 = "Стоп Лосс НЕ УСТАНОВЛЕН!";
                  else ls_132 = "NO STOP LOSS!";
               }
               f0_51(1, gs_552, 0, 0);
               f0_51(2, "#" + ticket_32 + " - " + f0_5(cmd_36) + ",  " + DoubleToStr(ld_48, 2) + " lot(s)", 0, 0);
               f0_51(3, ls_8 + DoubleToStr(ld_88, 2) + " " + AccountCurrency() + " (" + DoubleToStr(ld_108, 0) + " points)", li_104, 0);
               f0_51(4, ls_16 + ls_132, li_140, 0);
            } else {
               li_144 = FALSE;
               ld_148 = NormalizeDouble(MarketInfo(symbol_40, MODE_BID), g_digits_472);
               ls_156 = ", Bid = " + DoubleToStr(ld_148, g_digits_472);
               if (cmd_36 == OP_BUYLIMIT || cmd_36 == OP_BUYSTOP) {
                  ld_148 = NormalizeDouble(MarketInfo(symbol_40, MODE_ASK), g_digits_472);
                  ls_156 = ", Ask = " + DoubleToStr(ld_148, g_digits_472);
               }
               if (MathAbs(ld_56 - ld_148) / g_point_476 <= 10.0) li_144 = TRUE;
               f0_51(1, symbol_40 + gs_560, 0, 0);
               f0_51(2, "№ " + ticket_32 + " - " + f0_5(cmd_36), 0, 0);
               f0_51(3, "Open Price = " + DoubleToStr(ld_56, g_digits_472) + ls_156, 0, 0);
               f0_51(4, gs_568 + DoubleToStr(MathAbs(ld_56 - ld_148) / g_point_476, 0), li_144, 0);
            }
            return (1);
         }
      }
   }
   return (0);
}

void f0_18(int a_magic_0) {
   int error_4;
   int cmd_16;
   int ticket_20;
   double ld_24;
   double ld_32;
   double ld_40;
   double ld_48;
   int datetime_56;
   double ld_60;
   double ld_68;
   double ld_76;
   string ls_84;
   int datetime_92;
   gi_760 = 0;
   g_count_764 = 0;
   g_count_768 = 0;
   gi_unused_772 = 0;
   gd_unused_776 = 0.0;
   gd_unused_784 = 0.0;
   gd_unused_792 = 0.0;
   gd_unused_800 = 0.0;
   gi_unused_808 = -1;
   gd_unused_812 = 0.0;
   gd_unused_820 = 0.0;
   gd_unused_828 = 0.0;
   gs_unused_836 = "";
   gi_unused_844 = 0;
   gd_unused_848 = 0.0;
   gd_unused_856 = 0.0;
   gd_unused_864 = 0.0;
   gd_unused_872 = 0.0;
   gi_unused_880 = -1;
   gd_unused_884 = 0.0;
   gd_unused_892 = 0.0;
   gd_unused_900 = 0.0;
   gs_unused_908 = "";
   gi_unused_916 = 0;
   gd_unused_920 = 0.0;
   gd_unused_928 = 0.0;
   gd_unused_936 = 0.0;
   gd_unused_944 = 0.0;
   gi_unused_952 = -1;
   gs_unused_956 = "";
   gi_unused_964 = -1;
   gi_unused_968 = 0;
   gd_unused_972 = 0.0;
   gd_unused_980 = 0.0;
   gd_unused_988 = 0.0;
   gd_unused_996 = 0.0;
   gi_unused_1004 = -1;
   gs_unused_1008 = "";
   gi_unused_1016 = -1;
   gi_unused_1020 = 0;
   gd_unused_1024 = 0.0;
   gd_unused_1032 = 0.0;
   gd_unused_1040 = 0.0;
   gd_unused_1048 = 0.0;
   gi_unused_1056 = -1;
   gs_unused_1060 = "";
   gi_unused_1068 = -1;
   gi_unused_1072 = 0;
   gd_unused_1076 = 0.0;
   gd_unused_1084 = 0.0;
   gd_unused_1092 = 0.0;
   gd_unused_1100 = 0.0;
   gi_unused_1108 = -1;
   gs_unused_1112 = "";
   gi_unused_1120 = -1;
   int order_total_8 = OrdersTotal();
   for (int pos_12 = order_total_8 - 1; pos_12 >= 0; pos_12--) {
      if (!OrderSelect(pos_12, SELECT_BY_POS)) {
         error_4 = GetLastError();
         Print("|  _ExpertOrdersInit( ", a_magic_0, " ) - OrderSelect( ", pos_12, ", SELECT_BY_POS ) - Error #", error_4, " ( ", f0_78(error_4), " )");
      } else {
         if (OrderMagicNumber() == a_magic_0 && OrderSymbol() == g_symbol_448) {
            cmd_16 = OrderType();
            ticket_20 = OrderTicket();
            ld_24 = NormalizeDouble(OrderLots(), 2);
            ld_32 = NormalizeDouble(OrderOpenPrice(), g_digits_472);
            ld_40 = NormalizeDouble(OrderStopLoss(), g_digits_472);
            ld_48 = NormalizeDouble(OrderTakeProfit(), g_digits_472);
            datetime_56 = OrderOpenTime();
            ld_60 = NormalizeDouble(OrderProfit(), 2);
            ld_68 = NormalizeDouble(OrderSwap(), 2);
            ld_76 = NormalizeDouble(OrderCommission(), 2);
            ls_84 = OrderComment();
            datetime_92 = OrderExpiration();
            if (cmd_16 == OP_BUY) {
               g_count_764++;
               gi_unused_772 = ticket_20;
               gd_unused_776 = ld_24;
               gd_unused_784 = ld_32;
               gd_unused_792 = ld_40;
               gd_unused_800 = ld_48;
               gi_unused_808 = datetime_56;
               gd_unused_812 = ld_60;
               gd_unused_820 = ld_68;
               gd_unused_828 = ld_76;
               gs_unused_836 = ls_84;
            }
            if (cmd_16 == OP_SELL) {
               g_count_764++;
               gi_unused_844 = ticket_20;
               gd_unused_848 = ld_24;
               gd_unused_856 = ld_32;
               gd_unused_864 = ld_40;
               gd_unused_872 = ld_48;
               gi_unused_880 = datetime_56;
               gd_unused_884 = ld_60;
               gd_unused_892 = ld_68;
               gd_unused_900 = ld_76;
               gs_unused_908 = ls_84;
            }
            if (cmd_16 == OP_BUYSTOP) {
               g_count_768++;
               gi_unused_916 = ticket_20;
               gd_unused_920 = ld_24;
               gd_unused_928 = ld_32;
               gd_unused_936 = ld_40;
               gd_unused_944 = ld_48;
               gi_unused_952 = datetime_56;
               gs_unused_956 = ls_84;
               gi_unused_964 = datetime_92;
            }
            if (cmd_16 == OP_SELLSTOP) {
               g_count_768++;
               gi_unused_968 = ticket_20;
               gd_unused_972 = ld_24;
               gd_unused_980 = ld_32;
               gd_unused_988 = ld_40;
               gd_unused_996 = ld_48;
               gi_unused_1004 = datetime_56;
               gs_unused_1008 = ls_84;
               gi_unused_1016 = datetime_92;
            }
            if (cmd_16 == OP_BUYLIMIT) {
               g_count_768++;
               gi_unused_1020 = ticket_20;
               gd_unused_1024 = ld_24;
               gd_unused_1032 = ld_32;
               gd_unused_1040 = ld_40;
               gd_unused_1048 = ld_48;
               gi_unused_1056 = datetime_56;
               gs_unused_1060 = ls_84;
               gi_unused_1068 = datetime_92;
            }
            if (cmd_16 == OP_SELLLIMIT) {
               g_count_768++;
               gi_unused_1072 = ticket_20;
               gd_unused_1076 = ld_24;
               gd_unused_1084 = ld_32;
               gd_unused_1092 = ld_40;
               gd_unused_1100 = ld_48;
               gi_unused_1108 = datetime_56;
               gs_unused_1112 = ls_84;
               gi_unused_1120 = datetime_92;
            }
         }
      }
   }
   gi_760 = g_count_764 + g_count_768;
}

int f0_65(string a_symbol_0, int a_cmd_8, double a_lots_12, double a_price_20, int a_slippage_28 = -1, double a_price_32 = 0.0, double a_price_40 = 0.0, string a_comment_48 = "", int a_magic_56 = 0, int a_datetime_60 = 0, int a_color_64 = -2) {
   int error_72;
   g_symbol_1124 = a_symbol_0;
   g_comment_1132 = a_comment_48;
   g_cmd_1140 = a_cmd_8;
   g_slippage_1144 = a_slippage_28;
   g_magic_1148 = a_magic_56;
   gi_1152 = GetTickCount();
   g_lots_1160 = a_lots_12;
   g_price_1168 = a_price_20;
   g_price_1176 = a_price_32;
   g_price_1184 = a_price_40;
   g_datetime_1192 = a_datetime_60;
   g_color_1196 = a_color_64;
   g_ticket_1200 = -1;
   g_datetime_500 = TimeLocal();
   f0_49();
   f0_22();
   if (f0_6() == 0) return (-2);
   int li_ret_68 = f0_14(1);
   if (li_ret_68 < 0) return (li_ret_68);
   if (GetTickCount() - gi_1152 > 1000) {
      f0_54();
      if (f0_6() == 0) {
         f0_32();
         return (-2);
      }
   }
   g_ticket_1200 = OrderSend(g_symbol_1124, g_cmd_1140, g_lots_1160, g_price_1168, g_slippage_1144, g_price_1176, g_price_1184, g_comment_1132, g_magic_1148, g_datetime_1192,
      g_color_1196);
   g_error_1156 = GetLastError();
   if (g_ticket_1200 < 0 || g_error_1156 > 0/* NO_ERROR */) {
      f0_52(g_error_1156, "OrderSend");
      f0_32();
      f0_47(1, "Error", g_error_1156, f0_78(g_error_1156), "OrderSend(...)", "Error #" + g_error_1156 + " ( " + f0_78(g_error_1156) + " )");
      return (-1);
   }
   f0_32();
   for (int count_76 = 0; count_76 < 5; count_76++) {
      Sleep(1000);
      if (OrderSelect(g_ticket_1200, SELECT_BY_TICKET)) break;
      error_72 = GetLastError();
      if (error_72 != 0/* NO_ERROR */) f0_13(1, "OrderSelect( " + g_ticket_1200 + ", SELECT_BY_TICKET )", "Error #" + error_72 + " ( " + f0_78(error_72) + " )");
      else {
         f0_52(0, "OrderSend");
         f0_47(1, "Error", 0, "Ордер не был установлен/Позиция не была открыта", "OrderSend(...)", "Ордер не был установлен/Позиция не была открыта");
         return (-4);
      }
   }
   f0_91();
   f0_51(14, gs_752);
   f0_47(1, "OK", 0, "", "OrderSend(...)", "OK. Ticket " + g_ticket_1200);
   return (g_ticket_1200);
}

void f0_49() {
   if (g_slippage_1144 < 0) g_slippage_1144 = Slippage;
   if (g_comment_1132 == "") g_comment_1132 = gs_408;
   if (g_color_1196 < CLR_NONE) {
      g_color_1196 = OrderSellColor;
      if (g_cmd_1140 == OP_BUY || g_cmd_1140 == OP_BUYLIMIT || g_cmd_1140 == OP_BUYSTOP) g_color_1196 = OrderBuyColor;
   } else
      if (g_color_1196 < Black) g_color_1196 = CLR_NONE;
   if (g_cmd_1140 == OP_BUY) {
      g_price_1168 = NormalizeDouble(MarketInfo(g_symbol_1124, MODE_ASK), MarketInfo(g_symbol_1124, MODE_DIGITS));
      g_datetime_1192 = 0;
   }
   if (g_cmd_1140 == OP_SELL) {
      g_price_1168 = NormalizeDouble(MarketInfo(g_symbol_1124, MODE_BID), MarketInfo(g_symbol_1124, MODE_DIGITS));
      g_datetime_1192 = 0;
   }
   g_price_1168 = NormalizeDouble(g_price_1168, MarketInfo(g_symbol_1124, MODE_DIGITS));
   g_price_1176 = NormalizeDouble(g_price_1176, MarketInfo(g_symbol_1124, MODE_DIGITS));
   g_price_1184 = NormalizeDouble(g_price_1184, MarketInfo(g_symbol_1124, MODE_DIGITS));
}

void f0_22() {
   if (!Allow_Info && !Allow_LogFile) return;
   string ls_0 = gs_672 + f0_5(g_cmd_1140) + gs_680;
   if (g_cmd_1140 <= OP_SELL) ls_0 = gs_688 + f0_5(g_cmd_1140) + gs_696;
   int li_8 = 3;
   if (g_cmd_1140 == OP_BUY || g_cmd_1140 == OP_BUYLIMIT || g_cmd_1140 == OP_BUYSTOP) li_8 = 2;
   f0_10("- - - - - - - - - - - - - - - - - OrderSend Start- - - - - - - - - - - - - - - - - - -");
   f0_51(10, ls_0, li_8);
   f0_51(1, "Open Price = " + DoubleToStr(g_price_1168, MarketInfo(g_symbol_1124, MODE_DIGITS)));
   f0_51(2, "Stop Loss = " + DoubleToStr(g_price_1176, MarketInfo(g_symbol_1124, MODE_DIGITS)));
   f0_51(3, "Take Profit = " + DoubleToStr(g_price_1184, MarketInfo(g_symbol_1124, MODE_DIGITS)));
   f0_51(4, "Lot(s) = " + DoubleToStr(g_lots_1160, 2));
   f0_51(11, "Comment = " + g_comment_1132, 0, 0);
   f0_51(12, "MagicNumber = " + g_magic_1148, 0, 0);
   f0_51(13, "");
   f0_51(14, "");
   if (g_datetime_1192 > 0) f0_10("Expiration Time = " + TimeToStr(g_datetime_1192, TIME_DATE|TIME_SECONDS));
}

int f0_6() {
   if (Allow_Info) f0_51(13, gs_704, 0, 0);
   if (f0_26(g_symbol_1124, g_cmd_1140, g_lots_1160, g_price_1168, g_price_1176, g_price_1184, g_datetime_1192) < 0) {
      if (Allow_Info) f0_51(13, gs_712, 1, 0);
      if (Allow_LogFile) f0_10("Ошибка при проверке параметров!");
      f0_47(1, "Error", 0, gs_608, "_OrderSend_Check()", gs_608);
      return (0);
   }
   if (Allow_Info) f0_51(13, gs_720, 0, 0);
   return (1);
}

void f0_54() {
   bool li_0 = FALSE;
   if (g_cmd_1140 == OP_BUY) {
      if (NormalizeDouble(g_price_1168, MarketInfo(g_symbol_1124, MODE_DIGITS)) != NormalizeDouble(MarketInfo(g_symbol_1124, MODE_ASK), MarketInfo(g_symbol_1124, MODE_DIGITS))) {
         g_price_1168 = NormalizeDouble(MarketInfo(g_symbol_1124, MODE_ASK), MarketInfo(g_symbol_1124, MODE_DIGITS));
         if (Allow_Info || Allow_LogFile) {
            if (!li_0) {
               f0_10("- - - - - - - - - - - - - - - - - OrderSend Refresh  - - - - - - - - - - - - - - - - -");
               li_0 = TRUE;
            }
            f0_51(1, "Refreshed Open Price = " + DoubleToStr(g_price_1168, MarketInfo(g_symbol_1124, MODE_DIGITS)));
         }
      }
   }
   if (g_cmd_1140 == OP_SELL) {
      if (NormalizeDouble(g_price_1168, MarketInfo(g_symbol_1124, MODE_DIGITS)) != NormalizeDouble(MarketInfo(g_symbol_1124, MODE_BID), MarketInfo(g_symbol_1124, MODE_DIGITS))) {
         g_price_1168 = NormalizeDouble(MarketInfo(g_symbol_1124, MODE_BID), MarketInfo(g_symbol_1124, MODE_DIGITS));
         if (Allow_Info || Allow_LogFile) {
            if (!li_0) {
               f0_10("- - - - - - - - - - - - - - - - - OrderSend Refresh  - - - - - - - - - - - - - - - - -");
               li_0 = TRUE;
            }
            f0_51(1, "Refreshed Open Price = " + DoubleToStr(g_price_1168, MarketInfo(g_symbol_1124, MODE_DIGITS)));
         }
      }
   }
}

void f0_91() {
   string text_0;
   string ls_8;
   string name_20;
   string name_28;
   string name_36;
   if (g_color_1196 != CLR_NONE) {
      text_0 = g_comment_1132 
      + "\nId " + g_magic_1148;
      switch (g_cmd_1140) {
      case OP_BUY:
         ls_8 = " buy ";
         break;
      case OP_SELL:
         ls_8 = " sell ";
         break;
      case OP_BUYLIMIT:
         ls_8 = " buy limit ";
         break;
      case OP_SELLLIMIT:
         ls_8 = " sell limit ";
         break;
      case OP_BUYSTOP:
         ls_8 = " buy stop ";
         break;
      case OP_SELLSTOP:
         ls_8 = " sell stop ";
      }
      name_20 = "#" + g_ticket_1200 + ls_8 + DoubleToStr(g_lots_1160, 2) + " " + g_symbol_1124 + " at " + DoubleToStr(g_price_1168, MarketInfo(g_symbol_1124, MODE_DIGITS));
      name_28 = name_20 + " stop loss at " + DoubleToStr(g_price_1176, MarketInfo(g_symbol_1124, MODE_DIGITS));
      name_36 = name_20 + " take profit at " + DoubleToStr(g_price_1184, MarketInfo(g_symbol_1124, MODE_DIGITS));
      ObjectSetText(name_20, text_0, 10);
      if (NormalizeDouble(g_price_1176, MarketInfo(g_symbol_1124, MODE_DIGITS)) > 0.0) ObjectSetText(name_28, text_0, 10);
      if (NormalizeDouble(g_price_1184, MarketInfo(g_symbol_1124, MODE_DIGITS)) > 0.0) ObjectSetText(name_36, text_0, 10);
      GetLastError();
   }
}

int f0_93(int a_ticket_0, double ad_4 = 0.0, double ad_12 = 0.0, double ad_20 = 0.0, int a_datetime_28 = 0, int a_color_32 = -2) {
   g_symbol_1204 = "";
   gs_1212 = "";
   g_ticket_1220 = a_ticket_0;
   g_cmd_1224 = 0;
   g_magic_1228 = 0;
   gi_1232 = GetTickCount();
   gd_1240 = 0.0;
   gd_1248 = 0.0;
   gd_1256 = 0.0;
   gd_1264 = 0.0;
   g_price_1272 = NormalizeDouble(ad_4, g_digits_472);
   g_price_1280 = NormalizeDouble(ad_12, g_digits_472);
   g_price_1288 = NormalizeDouble(ad_20, g_digits_472);
   g_datetime_1296 = 0;
   g_datetime_1300 = a_datetime_28;
   g_color_1304 = a_color_32;
   g_bool_1308 = FALSE;
   g_datetime_500 = TimeLocal();
   if (f0_1() == 0) return (-2);
   f0_39();
   int li_ret_36 = f0_40();
   if (li_ret_36 < 0) return (li_ret_36);
   int li_ret_40 = f0_14(2);
   if (li_ret_40 < 0) return (li_ret_40);
   if (GetTickCount() - gi_1232 > 1000) {
      if (f0_75() == 0) {
         f0_32();
         return (-2);
      }
      li_ret_36 = f0_40();
      if (li_ret_36 < 0) {
         f0_32();
         return (li_ret_36);
      }
   }
   g_bool_1308 = OrderModify(g_ticket_1220, g_price_1272, g_price_1280, g_price_1288, g_datetime_1300, g_color_1304);
   g_error_1236 = GetLastError();
   if (!g_bool_1308 || g_error_1236 > 0/* NO_ERROR */) {
      f0_52(g_error_1236, "OrderModify");
      f0_32();
      f0_47(2, "Error", g_error_1236, f0_78(g_error_1236), "OrderModify(...)", "Error #" + g_error_1236 + " ( " + f0_78(g_error_1236) + " )");
      return (-1);
   }
   f0_32();
   for (int count_44 = 0; count_44 < 5; count_44++) {
      Sleep(1000);
      if (!OrderSelect(g_ticket_1220, SELECT_BY_TICKET)) {
         g_error_1236 = GetLastError();
         f0_13(2, "OrderSelect( " + g_ticket_1220 + ", SELECT_BY_TICKET )", "Error #" + g_error_1236 + " ( " + f0_78(g_error_1236) + " )");
      } else {
         if (NormalizeDouble(gd_1248, g_digits_472) != NormalizeDouble(OrderOpenPrice(), g_digits_472) || NormalizeDouble(gd_1256, g_digits_472) != NormalizeDouble(OrderStopLoss(),
            g_digits_472) || NormalizeDouble(gd_1264, g_digits_472) != NormalizeDouble(OrderTakeProfit(), g_digits_472) || g_datetime_1296 != OrderExpiration()) break;
         f0_52(0, "OrderModify");
         f0_47(2, "Error", 0, "Ордер не был модифицирован/Позиция не была модифицирована", "OrderModify(...)", "Ордер не был модифицирован/Позиция не была модифицирована");
         return (-4);
      }
   }
   f0_63();
   f0_51(14, gs_752);
   f0_47(2, "OK", 0, "", "OrderModify(...)", "OK");
   return (1);
}

int f0_1() {
   if (!OrderSelect(g_ticket_1220, SELECT_BY_TICKET)) {
      g_error_1236 = GetLastError();
      f0_47(2, "Error", g_error_1236, f0_78(g_error_1236), "OrderSelect( " + g_ticket_1220 + ", SELECT_BY_TICKET )", "Error #" + g_error_1236 + " ( " + f0_78(g_error_1236) +
         " )");
      return (0);
   }
   g_symbol_1204 = OrderSymbol();
   g_cmd_1224 = OrderType();
   gd_1240 = NormalizeDouble(OrderLots(), 2);
   gd_1248 = NormalizeDouble(OrderOpenPrice(), g_digits_472);
   gd_1256 = NormalizeDouble(OrderStopLoss(), g_digits_472);
   gd_1264 = NormalizeDouble(OrderTakeProfit(), g_digits_472);
   g_datetime_1296 = OrderExpiration();
   g_magic_1228 = OrderMagicNumber();
   gs_1212 = OrderComment();
   if (g_color_1304 < CLR_NONE) {
      g_color_1304 = OrderSellColor;
      if (g_cmd_1224 == OP_BUY || g_cmd_1224 == OP_BUYLIMIT || g_cmd_1224 == OP_BUYSTOP) g_color_1304 = OrderBuyColor;
   } else
      if (g_color_1304 < Black) g_color_1304 = CLR_NONE;
   if (g_price_1272 < 0.0) g_price_1272 = NormalizeDouble(gd_1248, g_digits_472);
   if (g_price_1280 < 0.0) g_price_1280 = NormalizeDouble(gd_1256, g_digits_472);
   if (g_price_1288 < 0.0) g_price_1288 = NormalizeDouble(gd_1264, g_digits_472);
   if (g_datetime_1300 < 0) g_datetime_1300 = g_datetime_1296;
   if (g_cmd_1224 <= OP_SELL) {
      g_price_1272 = NormalizeDouble(gd_1248, g_digits_472);
      g_datetime_1300 = 0;
   }
   return (1);
}

void f0_39() {
   if (!Allow_Info && !Allow_LogFile) return;
   string ls_0 = "Модифицируем ордер № ";
   if (g_cmd_1224 <= OP_SELL) ls_0 = "Модифицируем позицию № ";
   int li_8 = 0;
   bool li_12 = FALSE;
   if (g_price_1272 > gd_1248) {
      li_8 = 2;
      li_12 = TRUE;
   }
   if (g_price_1272 < gd_1248) {
      li_8 = 3;
      li_12 = TRUE;
   }
   int li_16 = 0;
   bool li_20 = FALSE;
   if (g_price_1280 > gd_1256) {
      li_16 = 2;
      li_20 = TRUE;
   }
   if (g_price_1280 < gd_1256) {
      li_16 = 3;
      li_20 = TRUE;
   }
   int li_24 = 0;
   bool li_28 = FALSE;
   if (g_price_1288 > gd_1264) {
      li_24 = 2;
      li_28 = TRUE;
   }
   if (g_price_1288 < gd_1264) {
      li_24 = 3;
      li_28 = TRUE;
   }
   f0_10(" - - - - - - - - - - - - - - - - OrderModify Start - - - - - - - - - - - - - - - - - -");
   f0_51(10, ls_0 + g_ticket_1220 + ", " + f0_5(g_cmd_1224) + "...");
   f0_51(1, "Old Open Price = " + DoubleToStr(gd_1248, g_digits_472), li_8, li_12);
   f0_51(2, "Old Stop Loss = " + DoubleToStr(gd_1256, g_digits_472), li_16, li_20);
   f0_51(3, "Old Take Profit = " + DoubleToStr(gd_1264, g_digits_472), li_24, li_28);
   f0_51(4, "");
   f0_51(11, "New Open Price = " + DoubleToStr(g_price_1272, g_digits_472), li_8, li_12);
   f0_51(12, "New Stop Loss = " + DoubleToStr(g_price_1280, g_digits_472), li_16, li_20);
   f0_51(13, "New Take Profit = " + DoubleToStr(g_price_1288, g_digits_472), li_24, li_28);
   f0_51(14, "");
   if (g_datetime_1300 > 0) f0_10("New Expiration Time = " + TimeToStr(g_datetime_1300, TIME_DATE|TIME_SECONDS));
}

int f0_40() {
   if (Allow_Info) f0_51(14, gs_704, 0, 0);
   if (NormalizeDouble(g_price_1272, g_digits_472) == NormalizeDouble(gd_1248, g_digits_472) && NormalizeDouble(g_price_1280, g_digits_472) == NormalizeDouble(gd_1256,
      g_digits_472) && NormalizeDouble(g_price_1288, g_digits_472) == NormalizeDouble(gd_1264, g_digits_472) && g_datetime_1300 == g_datetime_1296) {
      if (Allow_Info) f0_51(14, "Проверяем параметры.....Нет ни одного параметра для изменения. Модификация отменена...");
      if (Allow_LogFile) f0_10("Нет ни одного параметра для изменения. Модификация отменена...");
      f0_47(2, "Error", 0, "Нет ни одного параметра для изменения", "_OrderModify_Check()", "Нет ни одного параметра для изменения");
      return (-1);
   }
   if (Allow_Info) f0_51(14, gs_720, 0, 0);
   return (1);
}

int f0_75() {
   if (!OrderSelect(g_ticket_1220, SELECT_BY_TICKET)) {
      g_error_1236 = GetLastError();
      f0_47(2, "Error", g_error_1236, f0_78(g_error_1236), "OrderSelect( " + g_ticket_1220 + ", SELECT_BY_TICKET )", "Error #" + g_error_1236 + " ( " + f0_78(g_error_1236) +
         " )");
      return (0);
   }
   gd_1240 = NormalizeDouble(OrderLots(), 2);
   gd_1248 = NormalizeDouble(OrderOpenPrice(), g_digits_472);
   gd_1256 = NormalizeDouble(OrderStopLoss(), g_digits_472);
   gd_1264 = NormalizeDouble(OrderTakeProfit(), g_digits_472);
   g_datetime_1296 = OrderExpiration();
   if (g_price_1272 < 0.0) g_price_1272 = NormalizeDouble(gd_1248, g_digits_472);
   if (g_price_1280 < 0.0) g_price_1280 = NormalizeDouble(gd_1256, g_digits_472);
   if (g_price_1288 < 0.0) g_price_1288 = NormalizeDouble(gd_1264, g_digits_472);
   if (g_datetime_1300 < 0) g_datetime_1300 = g_datetime_1296;
   return (1);
}

void f0_63() {
   string text_0;
   string ls_8;
   string name_20;
   string name_28;
   string name_36;
   if (g_color_1304 != CLR_NONE) {
      text_0 = gs_1212 
      + "\nId " + g_magic_1228;
      switch (g_cmd_1224) {
      case OP_BUY:
         ls_8 = " buy";
         break;
      case OP_SELL:
         ls_8 = " sell";
         break;
      case OP_BUYLIMIT:
         ls_8 = " buy limit";
         break;
      case OP_SELLLIMIT:
         ls_8 = " sell limit";
         break;
      case OP_BUYSTOP:
         ls_8 = " buy stop";
         break;
      case OP_SELLSTOP:
         ls_8 = " sell stop";
      }
      ls_8 = ls_8 + " modified " + TimeToStr(TimeCurrent());
      name_20 = "#" + g_ticket_1220 + ls_8;
      name_28 = "#" + g_ticket_1220 + " sl modified ";
      name_36 = "#" + g_ticket_1220 + " tp modified ";
      if (NormalizeDouble(g_price_1272, g_digits_472) != NormalizeDouble(gd_1248, g_digits_472)) {
         name_28 = name_28 + TimeToStr(TimeCurrent());
         name_36 = name_36 + TimeToStr(TimeCurrent());
         ObjectSetText(name_20, text_0, 10);
      }
      if (NormalizeDouble(g_price_1280, g_digits_472) != NormalizeDouble(gd_1256, g_digits_472)) ObjectSetText(name_28, text_0, 10);
      if (NormalizeDouble(g_price_1288, g_digits_472) != NormalizeDouble(gd_1264, g_digits_472)) ObjectSetText(name_36, text_0, 10);
      GetLastError();
   }
}

int f0_26(string a_symbol_0, int ai_8, double ad_12, double ad_20, double ad_28, double ad_36, int ai_44) {
   int li_ret_48 = 1;
   double ld_52 = NormalizeDouble(MarketInfo(a_symbol_0, MODE_ASK), g_digits_472);
   double ld_60 = NormalizeDouble(MarketInfo(a_symbol_0, MODE_BID), g_digits_472);
   string dbl2str_68 = DoubleToStr(ld_52, g_digits_472);
   string dbl2str_76 = DoubleToStr(ld_60, g_digits_472);
   string dbl2str_84 = DoubleToStr(ad_20, g_digits_472);
   string dbl2str_92 = DoubleToStr(ad_28, g_digits_472);
   string dbl2str_100 = DoubleToStr(ad_36, g_digits_472);
   string time2str_108 = TimeToStr(ai_44, TIME_DATE|TIME_SECONDS);
   if (ai_8 < 0 || ai_8 > 5) {
      f0_51(4, gs_616 + " ( " + ai_8 + " )!!!", 1);
      g_error_1156 = 3;
      li_ret_48 = -1;
   }
   if (NormalizeDouble(MarketInfo(a_symbol_0, MODE_MINLOT) - ad_12, 4) > 0.0 || NormalizeDouble(ad_12 - MarketInfo(a_symbol_0, MODE_MAXLOT), 4) > 0.0) {
      f0_51(4, "Lot(s) = " + DoubleToStr(ad_12, 4) + gs_624, 1);
      g_error_1156 = 131;
      li_ret_48 = -1;
   }
   if (ai_8 == 2) {
      if (NormalizeDouble(ld_52 - ad_20 - gd_484, g_digits_472) < 0.0) {
         if (NormalizeDouble(ld_52 - ad_20, g_digits_472) < 0.0) f0_51(1, "Open Price = " + dbl2str_84 + gs_632 + " Ask = " + dbl2str_68 + ")!!!", 1);
         else f0_51(1, "Open Price = " + dbl2str_84 + gs_648 + " Ask = " + dbl2str_68 + ")!!!", 1);
         g_error_1156 = 4107;
         li_ret_48 = -1;
      }
   }
   if (ai_8 == 4) {
      if (NormalizeDouble(ad_20 - ld_52 - gd_484, g_digits_472) < 0.0) {
         if (NormalizeDouble(ad_20 - ld_52, g_digits_472) < 0.0) f0_51(1, "Open Price = " + dbl2str_84 + gs_640 + " Ask = " + dbl2str_68 + ")!!!", 1);
         else f0_51(1, "Open Price = " + dbl2str_84 + gs_648 + " Ask = " + dbl2str_68 + ")!!!", 1);
         g_error_1156 = 4107;
         li_ret_48 = -1;
      }
   }
   if (ai_8 == 3) {
      if (NormalizeDouble(ad_20 - ld_60 - gd_484, g_digits_472) < 0.0) {
         if (NormalizeDouble(ad_20 - ld_60, g_digits_472) < 0.0) f0_51(1, "Open Price = " + dbl2str_84 + gs_640 + " Bid = " + dbl2str_76 + ")!!!", 1);
         else f0_51(1, "Open Price = " + dbl2str_84 + gs_648 + " Bid = " + dbl2str_76 + ")!!!", 1);
         g_error_1156 = 4107;
         li_ret_48 = -1;
      }
   }
   if (ai_8 == 5) {
      if (NormalizeDouble(ld_60 - ad_20 - gd_484, g_digits_472) < 0.0) {
         if (NormalizeDouble(ld_60 - ad_20, g_digits_472) < 0.0) f0_51(1, "Open Price = " + dbl2str_84 + gs_632 + " Bid = " + dbl2str_76 + ")!!!", 1);
         else f0_51(1, "Open Price = " + dbl2str_84 + gs_648 + " Bid = " + dbl2str_76 + ")!!!", 1);
         g_error_1156 = 4107;
         li_ret_48 = -1;
      }
   }
   if (ai_8 == 0 || ai_8 == 2 || ai_8 == 4) {
      if (NormalizeDouble(ad_28, g_digits_472) > 0.0 && NormalizeDouble(ad_20 - gd_492 - ad_28 - gd_484, g_digits_472) < 0.0) {
         if (NormalizeDouble(ad_20 - ad_28, g_digits_472) < 0.0) f0_51(2, "Stop Loss = " + dbl2str_92 + gs_632 + " OpenPrice = " + dbl2str_84 + ")!!!", 1);
         else f0_51(2, "Stop Loss = " + dbl2str_92 + gs_648 + " OpenPrice = " + dbl2str_84 + ")!!!", 1);
         g_error_1156 = 130;
         li_ret_48 = -1;
      }
      if (NormalizeDouble(ad_36, g_digits_472) > 0.0 && NormalizeDouble(ad_36 - (ad_20 - gd_492) - gd_484, g_digits_472) < 0.0) {
         if (NormalizeDouble(ad_36 - ad_20, g_digits_472) < 0.0) f0_51(3, "Take Profit = " + dbl2str_100 + gs_640 + " OpenPrice = " + dbl2str_84 + ")!!!", 1);
         else f0_51(3, "Take Profit = " + dbl2str_100 + gs_648 + " OpenPrice = " + dbl2str_84 + ")!!!", 1);
         g_error_1156 = 130;
         li_ret_48 = -1;
      }
   }
   if (ai_8 == 1 || ai_8 == 3 || ai_8 == 5) {
      if (NormalizeDouble(ad_28, g_digits_472) > 0.0 && NormalizeDouble(ad_28 - (ad_20 + gd_492) - gd_484, g_digits_472) < 0.0) {
         if (NormalizeDouble(ad_28 - ad_20, g_digits_472) < 0.0) f0_51(2, "Stop Loss = " + dbl2str_92 + gs_640 + " OpenPrice = " + dbl2str_84 + ")!!!", 1);
         else f0_51(2, "Stop Loss = " + dbl2str_92 + gs_648 + " OpenPrice = " + dbl2str_84 + ")!!!", 1);
         g_error_1156 = 130;
         li_ret_48 = -1;
      }
      if (NormalizeDouble(ad_36, g_digits_472) > 0.0 && NormalizeDouble(ad_20 + gd_492 - ad_36 - gd_484, g_digits_472) < 0.0) {
         if (NormalizeDouble(ad_20 - ad_36, g_digits_472) < 0.0) f0_51(3, "Take Profit = " + dbl2str_100 + gs_632 + " OpenPrice = " + dbl2str_84 + ")!!!", 1);
         else f0_51(3, "Take Profit = " + dbl2str_100 + gs_648 + " OpenPrice = " + dbl2str_84 + ")!!!", 1);
         g_error_1156 = 130;
         li_ret_48 = -1;
      }
   }
   if (ai_8 <= 1) {
      if (ai_44 != 0) {
         f0_51(4, "Expiration Time = " + time2str_108 + gs_656, 1);
         g_error_1156 = 3;
         li_ret_48 = -1;
      }
   } else {
      if (ai_44 > 0 && ai_44 <= TimeCurrent()) {
         f0_51(4, "Expiration Time = " + time2str_108 + gs_664, 1);
         g_error_1156 = 3;
         li_ret_48 = -1;
      }
   }
   return (li_ret_48);
}

int f0_38(int a_ticket_0, double a_lots_4 = 0.0, double a_price_12 = 0.0, int a_slippage_20 = -1, int a_color_24 = -2) {
   g_symbol_1312 = "";
   g_dbl2str_1320 = "";
   g_comment_1328 = "";
   g_ticket_1336 = a_ticket_0;
   g_cmd_1340 = 0;
   g_magic_1344 = 0;
   g_slippage_1348 = a_slippage_20;
   gi_1352 = GetTickCount();
   g_lots_1360 = a_lots_4;
   gd_1368 = 0.0;
   g_order_open_price_1376 = 0.0;
   g_price_1384 = a_price_12;
   g_color_1392 = a_color_24;
   g_is_closed_1396 = FALSE;
   g_datetime_500 = TimeLocal();
   if (f0_33() == 0) return (-2);
   f0_29();
   if (f0_59() == 0) return (-3);
   int li_ret_28 = f0_14(3);
   if (li_ret_28 < 0) return (li_ret_28);
   if (GetTickCount() - gi_1352 > 1000) {
      if (f0_94() == 0) {
         f0_32();
         return (-2);
      }
      if (f0_59() == 0) {
         f0_32();
         return (-3);
      }
   }
   g_is_closed_1396 = OrderClose(g_ticket_1336, g_lots_1360, g_price_1384, g_slippage_1348, g_color_1392);
   g_error_1356 = GetLastError();
   if (!g_is_closed_1396 || g_error_1356 > 0/* NO_ERROR */) {
      f0_52(g_error_1356, "OrderClose");
      f0_32();
      f0_47(3, "Error", g_error_1356, f0_78(g_error_1356), "OrderClose(...)", "Error #" + g_error_1356 + " ( " + f0_78(g_error_1356) + " )");
      return (-1);
   }
   f0_32();
   for (int count_32 = 0; count_32 < 5; count_32++) {
      Sleep(1000);
      if (OrderSelect(g_ticket_1336, SELECT_BY_TICKET)) {
         if (OrderCloseTime() > 0) break;
         f0_52(0, "OrderClose");
         f0_47(3, "Error", 0, "Позиция не была закрыта", "OrderClose(...)", "Позиция не была закрыта");
         return (-5);
      }
      g_error_1356 = GetLastError();
      f0_13(3, "OrderSelect( " + g_ticket_1336 + ", SELECT_BY_TICKET )", "Error #" + g_error_1356 + " ( " + f0_78(g_error_1356) + " )");
   }
   f0_24();
   f0_51(14, gs_752);
   f0_47(3, "OK", 0, "", "OrderClose(...)", "OK");
   return (1);
}

int f0_33() {
   if (g_slippage_1348 < 0) g_slippage_1348 = Slippage;
   if (!OrderSelect(g_ticket_1336, SELECT_BY_TICKET)) {
      g_error_1356 = GetLastError();
      f0_47(3, "Error", g_error_1356, f0_78(g_error_1356), "OrderSelect( " + g_ticket_1336 + ", SELECT_BY_TICKET )", "Error #" + g_error_1356 + " ( " + f0_78(g_error_1356) +
         " )");
      return (0);
   }
   g_symbol_1312 = OrderSymbol();
   g_cmd_1340 = OrderType();
   g_dbl2str_1320 = DoubleToStr(OrderProfit() + OrderSwap() + OrderCommission(), 2);
   g_comment_1328 = OrderComment();
   g_magic_1344 = OrderMagicNumber();
   g_order_open_price_1376 = OrderOpenPrice();
   gd_1368 = OrderLots();
   if (NormalizeDouble(g_lots_1360 - gd_1368, 2) > 0.0 || NormalizeDouble(MarketInfo(g_symbol_1312, MODE_MINLOT) - g_lots_1360, 2) > 0.0) g_lots_1360 = gd_1368;
   if (g_cmd_1340 == OP_SELL) g_price_1384 = NormalizeDouble(MarketInfo(g_symbol_1312, MODE_ASK), MarketInfo(g_symbol_1312, MODE_DIGITS));
   if (g_cmd_1340 == OP_BUY) g_price_1384 = NormalizeDouble(MarketInfo(g_symbol_1312, MODE_BID), MarketInfo(g_symbol_1312, MODE_DIGITS));
   g_lots_1360 = NormalizeDouble(g_lots_1360, 2);
   if (g_color_1392 < CLR_NONE) {
      g_color_1392 = OrderSellColor;
      if (g_cmd_1340 == OP_BUY || g_cmd_1340 == OP_BUYLIMIT || g_cmd_1340 == OP_BUYSTOP) g_color_1392 = OrderBuyColor;
   } else
      if (g_color_1392 < Black) g_color_1392 = CLR_NONE;
   return (1);
}

void f0_29() {
   if (!Allow_Info && !Allow_LogFile) return;
   int li_0 = 3;
   if (g_cmd_1340 == OP_BUY || g_cmd_1340 == OP_BUYLIMIT || g_cmd_1340 == OP_BUYSTOP) li_0 = 2;
   f0_10("- - - - - - - - - - - - - - - - - OrderClose Start - - - - - - - - - - - - - - - - - -");
   f0_51(10, "Закрываем позицию № " + g_ticket_1336 + ", " + f0_5(g_cmd_1340) + "...", li_0);
   f0_51(1, "Сlose Price = " + DoubleToStr(g_price_1384, MarketInfo(g_symbol_1312, MODE_DIGITS)));
   f0_51(2, "Lot(s) = " + DoubleToStr(g_lots_1360, 2));
   f0_51(3, "Profit/Loss = " + g_dbl2str_1320);
   f0_51(4, "");
   f0_51(11, "Comment = " + g_comment_1328, 0, 0);
   f0_51(12, "MagicNumber = " + g_magic_1344, 0, 0);
   f0_51(13, "");
   f0_51(14, "");
}

int f0_59() {
   if (Allow_Info) f0_51(13, gs_704, 0, 0);
   if (g_cmd_1340 > OP_SELL) {
      if (Allow_Info || Allow_LogFile) {
         f0_51(13, gs_712, 1, 0);
         f0_51(4, "Ошибочный OrderType() - " + g_cmd_1340 + ". Закрыта может быть только OP_BUY или OP_SELL позиция.", 1);
      }
      f0_47(3, "Error", 0, "Ошибочный OrderType()", "_OrderClose_Check()", "Ошибочный OrderType()");
      return (0);
   }
   if (Allow_Info) f0_51(13, gs_720, 0, 0);
   return (1);
}

int f0_94() {
   if (!OrderSelect(g_ticket_1336, SELECT_BY_TICKET)) {
      g_error_1356 = GetLastError();
      f0_47(3, "Error", g_error_1356, f0_78(g_error_1356), "OrderSelect( " + g_ticket_1336 + ", SELECT_BY_TICKET )", "Error #" + g_error_1356 + " ( " + f0_78(g_error_1356) +
         " )");
      return (0);
   }
   bool li_0 = FALSE;
   g_cmd_1340 = OrderType();
   gd_1368 = NormalizeDouble(OrderLots(), MarketInfo(g_symbol_1312, MODE_DIGITS));
   if (g_cmd_1340 == OP_SELL) {
      if (NormalizeDouble(g_price_1384, MarketInfo(g_symbol_1312, MODE_DIGITS)) != NormalizeDouble(MarketInfo(g_symbol_1312, MODE_ASK), MarketInfo(g_symbol_1312, MODE_DIGITS))) {
         g_price_1384 = NormalizeDouble(MarketInfo(g_symbol_1312, MODE_ASK), MarketInfo(g_symbol_1312, MODE_DIGITS));
         if (Allow_Info || Allow_LogFile) {
            if (!li_0) {
               f0_10("- - - - - - - - - - - - - - - - - OrderClose Refresh - - - - - - - - - - - - - - - - -");
               li_0 = TRUE;
            }
            f0_51(1, "Refreshed Сlose Price = " + DoubleToStr(g_price_1384, MarketInfo(g_symbol_1312, MODE_DIGITS)));
         }
      }
   }
   if (g_cmd_1340 == OP_BUY) {
      if (NormalizeDouble(g_price_1384, MarketInfo(g_symbol_1312, MODE_DIGITS)) != NormalizeDouble(MarketInfo(g_symbol_1312, MODE_BID), MarketInfo(g_symbol_1312, MODE_DIGITS))) {
         g_price_1384 = NormalizeDouble(MarketInfo(g_symbol_1312, MODE_BID), MarketInfo(g_symbol_1312, MODE_DIGITS));
         if (Allow_Info || Allow_LogFile) {
            if (!li_0) {
               f0_10("- - - - - - - - - - - - - - - - - OrderClose Refresh - - - - - - - - - - - - - - - - -");
               li_0 = TRUE;
            }
            f0_51(1, "Refreshed Сlose Price = " + DoubleToStr(g_price_1384, MarketInfo(g_symbol_1312, MODE_DIGITS)));
         }
      }
   }
   if (NormalizeDouble(g_lots_1360 - gd_1368, 2) > 0.0 || NormalizeDouble(MarketInfo(g_symbol_1312, MODE_MINLOT) - g_lots_1360, 2) > 0.0) {
      g_lots_1360 = NormalizeDouble(gd_1368, 2);
      if (Allow_Info || Allow_LogFile) {
         if (!li_0) {
            f0_10("- - - - - - - - - - - - - - - - - OrderClose Refresh - - - - - - - - - - - - - - - - -");
            li_0 = TRUE;
         }
         f0_51(2, "Refreshed Lot(s) = " + DoubleToStr(g_lots_1360, 2));
      }
   }
   return (1);
}

void f0_24() {
   string text_0;
   string ls_8;
   string name_20;
   if (g_color_1392 != CLR_NONE) {
      text_0 = g_comment_1328 
      + "\nId " + g_magic_1344;
      switch (g_cmd_1340) {
      case OP_BUY:
         ls_8 = " buy ";
         break;
      case OP_SELL:
         ls_8 = " sell ";
      }
      name_20 = "#" + g_ticket_1336 + ls_8 + DoubleToStr(g_lots_1360, 2) + " " + g_symbol_1312 + " at " + DoubleToStr(g_order_open_price_1376, MarketInfo(g_symbol_1312,
         MODE_DIGITS)) + " close at " + DoubleToStr(g_price_1384, MarketInfo(g_symbol_1312, MODE_DIGITS));
      ObjectSetText(name_20, text_0, 10);
      GetLastError();
   }
}

int f0_45(int a_ticket_0) {
   int order_total_12;
   gs_1400 = "";
   g_ticket_1408 = a_ticket_0;
   g_cmd_1412 = 0;
   g_magic_1416 = 0;
   gi_1420 = GetTickCount();
   g_is_deleted_1428 = FALSE;
   g_datetime_500 = TimeLocal();
   if (f0_36() == 0) return (-2);
   f0_56();
   if (f0_50() == 0) return (-3);
   int li_ret_4 = f0_14(3);
   if (li_ret_4 < 0) return (li_ret_4);
   if (GetTickCount() - gi_1420 > 1000) {
      if (f0_92() == 0) {
         f0_32();
         return (-2);
      }
      if (f0_50() == 0) {
         f0_32();
         return (-3);
      }
   }
   g_is_deleted_1428 = OrderDelete(g_ticket_1408);
   g_error_1424 = GetLastError();
   if (!g_is_deleted_1428 || g_error_1424 > 0/* NO_ERROR */) {
      f0_52(g_error_1424, "OrderDelete");
      f0_32();
      f0_47(4, "Error", g_error_1424, f0_78(g_error_1424), "OrderDelete(...)", "Error #" + g_error_1424 + " ( " + f0_78(g_error_1424) + " )");
      return (-1);
   }
   f0_32();
   for (int count_8 = 0; count_8 < 5; count_8++) {
      Sleep(1000);
      order_total_12 = OrdersTotal();
      for (int pos_16 = order_total_12 - 1; pos_16 >= 0; pos_16--) {
         if (OrderSelect(pos_16, SELECT_BY_POS)) {
            if (OrderTicket() == g_ticket_1408) {
               f0_52(0, "OrderDelete");
               f0_47(4, "Error", 0, "Ордер не был удалён", "OrderDelete(...)", "Ордер не был удалён");
               return (-5);
            }
            if (pos_16 != 0) continue;
            count_8 = 5;
         } else {
            g_error_1424 = GetLastError();
            f0_13(4, "OrderSelect( " + pos_16 + ", SELECT_BY_POS )", "Error #" + g_error_1424 + " ( " + f0_78(g_error_1424) + " )");
         }
      }
   }
   f0_51(14, gs_752);
   f0_47(4, "OK", 0, "", "OrderDelete(...)", "OK");
   return (1);
}

int f0_36() {
   if (!OrderSelect(g_ticket_1408, SELECT_BY_TICKET)) {
      g_error_1424 = GetLastError();
      f0_13(4, "OrderSelect( " + g_ticket_1408 + ", SELECT_BY_TICKET )", "Error #" + g_error_1424 + " ( " + f0_78(g_error_1424) + " )");
      return (0);
   }
   g_cmd_1412 = OrderType();
   gs_1400 = OrderComment();
   g_magic_1416 = OrderMagicNumber();
   return (1);
}

void f0_56() {
   if (!Allow_Info && !Allow_LogFile) return;
   int li_0 = 3;
   if (g_cmd_1412 == OP_BUY || g_cmd_1412 == OP_BUYLIMIT || g_cmd_1412 == OP_BUYSTOP) li_0 = 2;
   f0_10(" - - - - - - - - - - - - - - - - OrderDelete Start - - - - - - - - - - - - - - - - - -");
   f0_51(10, "Удаляем ордер № " + g_ticket_1408 + ", " + f0_5(g_cmd_1412) + "...", li_0);
   f0_51(1, "");
   f0_51(2, "");
   f0_51(3, "");
   f0_51(4, "");
   f0_51(11, "Comment = " + gs_1400, 0, 0);
   f0_51(12, "MagicNumber = " + g_magic_1416, 0, 0);
   f0_51(13, "");
   f0_51(14, "");
}

int f0_50() {
   if (Allow_Info) f0_51(13, gs_704, 0, 0);
   if (g_cmd_1412 <= OP_SELL) {
      if (Allow_Info || Allow_LogFile) {
         f0_51(13, gs_712, 1, 0);
         f0_51(14, "Ошибочный OrderType() - " + g_cmd_1412 + ". Удалён может быть только отложенный ордер.", 1);
      }
      f0_47(4, "Error", 0, "Ошибочный OrderType", "_OrderDelete_Check()", "Ошибочный OrderType");
      return (0);
   }
   if (Allow_Info) f0_51(13, gs_720, 0, 0);
   return (1);
}

int f0_92() {
   if (!OrderSelect(g_ticket_1408, SELECT_BY_TICKET)) {
      g_error_1424 = GetLastError();
      f0_13(4, "OrderSelect( " + g_ticket_1408 + ", SELECT_BY_TICKET )", "Error #" + g_error_1424 + " ( " + f0_78(g_error_1424) + " )");
      return (0);
   }
   g_cmd_1412 = OrderType();
   return (1);
}

int f0_2(int a_ticket_0, int a_slippage_4 = -1, int a_color_8 = -1, int a_color_12 = -1) {
   int error_24;
   g_symbol_1312 = "";
   g_dbl2str_1320 = "";
   g_comment_1328 = "";
   g_ticket_1336 = a_ticket_0;
   g_cmd_1340 = 0;
   g_magic_1344 = 0;
   g_slippage_1348 = a_slippage_4;
   gi_1352 = GetTickCount();
   g_lots_1360 = 0.0;
   gd_1368 = 0.0;
   g_price_1384 = 0.0;
   g_color_1392 = a_color_8;
   g_is_closed_1396 = FALSE;
   g_symbol_1124 = "";
   g_comment_1132 = "";
   g_cmd_1140 = 0;
   g_slippage_1144 = a_slippage_4;
   g_magic_1148 = 0;
   g_lots_1160 = 0.0;
   g_price_1168 = 0.0;
   g_price_1176 = 0.0;
   g_price_1184 = 0.0;
   g_datetime_1192 = 0;
   g_color_1196 = a_color_12;
   g_ticket_1200 = -1;
   g_datetime_500 = TimeLocal();
   if (f0_21() == 0) return (-2);
   f0_16();
   if (f0_4() == 0) return (-3);
   int li_ret_16 = f0_14(5);
   if (li_ret_16 < 0) return (li_ret_16);
   if (GetTickCount() - gi_1352 > 1000) {
      if (f0_73() == 0) {
         f0_32();
         return (-2);
      }
      if (f0_4() == 0) {
         f0_32();
         return (-3);
      }
   }
   g_is_closed_1396 = OrderClose(g_ticket_1336, g_lots_1360, g_price_1384, g_slippage_1348, g_color_1392);
   g_error_1356 = GetLastError();
   if (!g_is_closed_1396 || g_error_1356 > 0/* NO_ERROR */) {
      f0_52(g_error_1356, "Reverse");
      f0_32();
      f0_47(5, "Error", g_error_1356, f0_78(g_error_1356), "Reverse(...)", "Error #" + g_error_1356 + " ( " + f0_78(g_error_1356) + " )");
      return (-1);
   }
   for (int count_20 = 0; count_20 < 5; count_20++) {
      Sleep(1000);
      if (OrderSelect(g_ticket_1336, SELECT_BY_TICKET)) {
         if (OrderCloseTime() > 0) break;
         f0_52(0, "OrderClose");
         f0_47(5, "Error", 0, "Позиция не была закрыта", "Reverse(...)", "Позиция не была закрыта");
         return (-5);
      }
      g_error_1356 = GetLastError();
      f0_13(5, "OrderSelect( " + g_ticket_1336 + ", SELECT_BY_TICKET )", "Error #" + g_error_1356 + " ( " + f0_78(g_error_1356) + " )");
   }
   f0_24();
   f0_47(5, "OK", 0, "", "OrderClose(...)", "OK");
   g_ticket_1200 = OrderSend(g_symbol_1124, g_cmd_1140, g_lots_1160, g_price_1168, g_slippage_1144, g_price_1176, g_price_1184, g_comment_1132, g_magic_1148, g_datetime_1192,
      g_color_1196);
   g_error_1156 = GetLastError();
   if (g_ticket_1200 < 0 || g_error_1156 > 0/* NO_ERROR */) {
      f0_52(g_error_1156, "Reverse");
          

Recommend