Navigation:Home > Content >

Auto-profit_v.2.0.mq4

Time: 2010-06-28 | Download file:Auto-profit_v.2.0.mq4

#property copyright "Copyright © 2011, Invest-system.net"
#property link      "Invest-system.net"

//int gi_76 = 3027389;
string gs_80 = "FRX_";
string gsa_88[7];
bool gi_unused_92 = TRUE;
bool gi_96 = FALSE;
double gd_100 = 0.01;
extern string _ = "Параметр риска (лот от Баланса)";
extern double RiskPercent = 20.0;
extern string __ = "Количество торг.слоёв (<4)";
extern int TorgSloy = 3;
extern string ___ = "Количество ордеров предыд.слоя до вкл.след.";
extern int N_enable_Sloy = 7;
double g_maxlot_148 = 0.0;
extern string ____ = "множитель след лота";
extern double LotMultiplicator = 1.2;
extern string _____ = "Расстояние до след. ордера";
extern int hSETKY = 30;
int gi_unused_184 = 30;
extern string ______ = "hSETKY (0-const 1-ув. 2-ум.)";
extern int Uvel_hSETKY = 1;
extern string _______ = "шаг увелич.сетки";
extern int ShagUvel_hSETKY = 2;
int gi_212 = 0;
int gi_216 = 0;
extern string ________ = "Прибыль от закрытия группы";
extern int ProtectionTP = 7;
int gi_232 = 7;
int gi_unused_236 = 1;
double gd_unused_240 = 40.0;
extern string __________ = "Идентификатор ордеров";
extern int Magic = 1230;
extern string ____________ = "логотип и вывод данных";
extern bool ShowTableOnTesting = TRUE;
extern string _____________ = "(true-вкл.,false-выкл.)";
string gs_unused_280 = "Огр.торг.по своб.ср.счета";
string gs_unused_288 = "в % от депозита";
double gd_296 = 3.0;
int gi_304 = 3;
int g_slippage_316 = 2;
double gd_320;
double gd_328;
double g_ask_344;
double g_bid_352;
double gd_360;
double gd_368;
int gia_376[7];
int gia_unused_380[7];
double gd_384;
int gia_392[3][2] = {16711680, 255,
   15570276, 7504122,
   13959039, 17919};
string gsa_396[3][2] = {"NextBUY_0", "NextSELL_0",
   "NextBUY_1", "NextSELL_1",
   "NextBUY_2", "NextSELL_2"};
int g_index_400;
int gi_404 = 7;
int gia_408[7] = {1, 0, 0, 0, 0, 0, 0};
string gsa_412[7];
int gia_416[7] = {10, 1, 0, 1, 1, 1, 1};
int gia_420[7] = {5, 3, 3, 3, 3, 3, 3};
int gia_424[7] = {20, 20, 20, 20, 20, 20, 20};
int gia_428[7] = {7, 7, 7, 7, 7, 7, 7};
int gia_432[7] = {111, 222, 333, 444, 555, 777, 999};
double gda_unused_436[7];
double gda_unused_440[7];
double gda_unused_444[7];
double gda_unused_448[7];
double gda_unused_452[7];
double gda_unused_456[7];
double gda_unused_460[7];
int gia_464[10] = {1, 5, 15, 30, 60, 240, 1440, 10080, 43200, 0};
double gda_468[7][16][50];
double gda_472[7][16][50];
double gda_476[7][16][50];
int gia_480[7][16][50];
double gda_484[7][16][50];
double gda_488[7][16][50];
double gda_492[7];
double gda_496[7];
double gda_500[7][16];
double gda_504[7][16];
int gia_508[7];
int gia_512[7];
int gia_516[7];
int gia_520[7];
int gia_524[7];
int gia_528[7];
int g_pos_532;
int gi_536;
int g_ord_total_540;
int gi_552;
int gi_556;
int gia_568[7];
int gia_572[7];
int gia_576[7];
int gia_580[7];
int gia_584[7];
int gia_588[7];
int gia_592[7];
int gia_596[7];
int gia_600[7];
int gia_604[7];
int gia_608[7];
int gia_612[7];
int gia_616[7];
int gia_620[7];
int gia_unused_624[7];
int gia_unused_628[7];
int gia_632[7];
int gia_636[7];
int gia_unused_640[7];
int gi_644;
double gda_648[7];
double gda_652[7];
double gda_656[7];
double gda_660[7];
int gia_664[7];
int gia_668[7];
double gda_672[7];
double gda_676[7];
double gda_680[7];
double gda_684[7];
double gda_688[7];
double gda_692[7];
double gda_696[7];
double gda_700[7];
int gi_unused_704;
int gi_unused_708;
bool gi_712;
bool gi_716;
double g_price_736;
double g_price_744;
double g_price_752;
double g_price_760;
double gda_768[7];
double gda_772[7];
int gi_unused_776 = 10;

int init() {
   gi_644 = 1;
   if (Digits == 5 || Digits == 3) gi_644 = 10;
   for (gi_552 = 1; gi_552 < 8; gi_552++) {
      gia_568[gi_552] = 0;
      gia_572[gi_552] = 0;
      gia_584[gi_552] = 0;
      gia_588[gi_552] = 0;
      gia_592[gi_552] = 0;
      gia_596[gi_552] = 0;
      gia_600[gi_552] = 0;
      gia_604[gi_552] = 0;
      Print(gia_568[gi_552], gia_572[gi_552], gia_584[gi_552], gia_588[gi_552], gia_592[gi_552], gia_596[gi_552], gia_600[gi_552], gia_604[gi_552]);
   }
   return (0);
}

void deinit() {
   Comment("");
}

int start() {
   int l_stoplevel_8;
   int l_spread_12;
   double l_point_16;
   double l_bid_24;
   double l_ask_32;
   int li_unused_40;
   double l_minlot_44;
   double l_lotstep_52;
   double ld_60;
   int li_68;
   int li_72;
   int li_76;
   int li_80;
   int li_84;
   int li_88;
   int li_92;
   int li_96;
   int li_100;
   int li_104;
   double ld_108;
   double ld_116;
   string ls_0 = Symbol();
   /*if (AccountNumber() != gi_76 && !IsDemo()) {
      Comment("Советник может работать только на счёте " + gi_76 + ", для бесплатного подключения к другому счёту перейдите на сайт invest-system.net");
      return;
   }*/
   if (gd_296 < 100.0 && AccountFreeMargin() < AccountBalance() * gd_296 / 100.0) {
      Print("Опасная просадка " + NormalizeDouble(AccountProfit(), 2) + "; недостаточно свободных средств счета для продолжения торговли " + NormalizeDouble(AccountFreeMargin(), 2) +
         ", режим ожидания выхода из просадки");
      Comment("\n", "Опасная просадка " + NormalizeDouble(AccountProfit(), 2) + "; недостаточно свободных средств счета для продолжения торговли " + NormalizeDouble(AccountFreeMargin(), 2) +
         ", режим ожидания выхода из просадки");
      Sleep(1000);
      return;
   }
   gia_408[1] = 0;
   gia_408[2] = 0;
   g_index_400 = 0;
   gsa_412[g_index_400] = ls_0;
   gia_432[g_index_400] = Magic + g_index_400;
   N();
   g_index_400 = 1;
   gsa_412[g_index_400] = ls_0;
   gia_432[g_index_400] = Magic + g_index_400;
   N();
   g_index_400 = 2;
   gsa_412[g_index_400] = ls_0;
   gia_432[g_index_400] = Magic + g_index_400;
   N();
   if (gia_508[0] > N_enable_Sloy || gia_512[0] > N_enable_Sloy && TorgSloy > 1 && TorgSloy < 4) gia_408[1] = 1;
   if (gia_508[1] > 0 || gia_512[1] > 0) gia_408[1] = 1;
   if (gia_508[0] > N_enable_Sloy || gia_512[0] > N_enable_Sloy && gia_508[1] > N_enable_Sloy || gia_512[1] > N_enable_Sloy && TorgSloy > 2 && TorgSloy < 4) gia_408[2] = 1;
   if (gia_508[2] > 0 || gia_512[2] > 0) gia_408[2] = 1;
   if (gia_508[1] == 0 && gia_512[1] == 0) {
      ObjectDelete(gsa_396[1][0]);
      ObjectDelete(gsa_396[1][1]);
   }
   if (gia_508[2] == 0 && gia_512[2] == 0) {
      ObjectDelete(gsa_396[2][0]);
      ObjectDelete(gsa_396[2][1]);
   }
   for (g_index_400 = 0; g_index_400 < gi_404; g_index_400++) {
      Sleep(100);
      if (gia_408[g_index_400] == 1) {
         gia_432[g_index_400] = Magic + g_index_400;
         l_stoplevel_8 = MarketInfo(gsa_412[g_index_400], MODE_STOPLEVEL);
         l_spread_12 = MarketInfo(gsa_412[g_index_400], MODE_SPREAD);
         l_point_16 = MarketInfo(gsa_412[g_index_400], MODE_POINT);
         l_bid_24 = MarketInfo(gsa_412[g_index_400], MODE_BID);
         l_ask_32 = MarketInfo(gsa_412[g_index_400], MODE_ASK);
         li_unused_40 = MarketInfo(gsa_412[g_index_400], MODE_DIGITS);
         if (g_maxlot_148 == 0.0) g_maxlot_148 = MarketInfo(gsa_412[g_index_400], MODE_MAXLOT);
         l_minlot_44 = MarketInfo(gsa_412[g_index_400], MODE_MINLOT);
         l_lotstep_52 = MarketInfo(gsa_412[g_index_400], MODE_LOTSTEP);
         ld_60 = AccountBalance();
         if (l_minlot_44 == 0.01) li_68 = 2;
         if (l_minlot_44 == 0.1) li_68 = 1;
         if (l_minlot_44 >= 1.0) li_68 = 0;
         if (l_lotstep_52 == 0.01) li_72 = 2;
         if (l_lotstep_52 == 0.1) li_72 = 1;
         if (l_lotstep_52 >= 1.0) li_72 = 0;
         if ((!IsOptimization() && !IsTesting() && !IsVisualMode()) || (ShowTableOnTesting && IsTesting() && !IsOptimization())) {
            DrawStats();
            DrawLogo();
         }
         if (gi_232 * gi_644 < l_stoplevel_8) gia_664[g_index_400] = l_stoplevel_8 + 5 * gi_644;
         else gia_664[g_index_400] = gi_232 * gi_644;
         if (gi_232 * gi_644 < l_stoplevel_8) gia_668[g_index_400] = l_stoplevel_8 + 5 * gi_644;
         else gia_668[g_index_400] = gi_232 * gi_644;
         gda_648[g_index_400] = gi_212 * gi_644;
         gda_652[g_index_400] = gi_212 * gi_644;
         gda_656[g_index_400] = gi_216 * gi_644;
         gda_660[g_index_400] = gi_216 * gi_644;
         gda_676[g_index_400] = hSETKY * gi_644;
         gda_684[g_index_400] = hSETKY * gi_644;
         gda_696[g_index_400] = ProtectionTP * gi_644;
         gda_700[g_index_400] = ProtectionTP * gi_644;
         gda_768[g_index_400] = gi_304 * gi_644;
         gda_772[g_index_400] = gi_304 * gi_644;
         g_slippage_316 *= gi_644;
         if (gi_96) {
            gda_688[g_index_400] = gd_100;
            gda_692[g_index_400] = gd_100;
         } else {
            gda_688[g_index_400] = NormalizeDouble(ld_60 * RiskPercent / 1000000.0, li_68);
            gda_692[g_index_400] = NormalizeDouble(ld_60 * RiskPercent / 1000000.0, li_68);
         }
         if (gda_688[g_index_400] == 0.0) gda_688[g_index_400] = l_minlot_44;
         if (gda_692[g_index_400] == 0.0) gda_692[g_index_400] = l_minlot_44;
         N();
         if (gia_508[g_index_400] > 0) {
            li_76 = MAX(0, gia_508[g_index_400]);
            li_80 = MIN(0, gia_508[g_index_400]);
         }
         if (gia_512[g_index_400] > 0) {
            li_84 = MAX(1, gia_512[g_index_400]);
            li_88 = MIN(1, gia_512[g_index_400]);
         }
         if (gia_508[g_index_400] > 1) {
            li_92 = NOV(0, gia_508[g_index_400], l_ask_32);
            li_96 = NON(0, gia_508[g_index_400], l_ask_32);
         } else {
            li_92 = 0;
            li_96 = 0;
         }
         if (gia_512[g_index_400] > 1) {
            li_100 = NOV(1, gia_512[g_index_400], l_bid_24);
            li_104 = NON(1, gia_512[g_index_400], l_bid_24);
         } else {
            li_100 = 0;
            li_104 = 0;
         }
         gda_672[g_index_400] = gda_676[g_index_400] * l_point_16;
         gda_680[g_index_400] = gda_684[g_index_400] * l_point_16;
         if (Uvel_hSETKY == 0) {
            gda_672[g_index_400] = gda_676[g_index_400] * l_point_16;
            gda_680[g_index_400] = gda_684[g_index_400] * l_point_16;
         }
         if (Uvel_hSETKY == 1) {
            if (gia_508[g_index_400] < 2) gda_672[g_index_400] = gda_676[g_index_400] * l_point_16;
            if (gia_512[g_index_400] < 2) gda_680[g_index_400] = gda_684[g_index_400] * l_point_16;
            if (gia_508[g_index_400] > 1) gda_672[g_index_400] = (gda_676[g_index_400] + ShagUvel_hSETKY * gia_508[g_index_400] * gi_644) * l_point_16;
            if (gia_512[g_index_400] > 1) gda_680[g_index_400] = (gda_684[g_index_400] + ShagUvel_hSETKY * gia_512[g_index_400] * gi_644) * l_point_16;
         }
         if (Uvel_hSETKY == 2) {
            if (gia_508[g_index_400] < 2) gda_672[g_index_400] = gda_676[g_index_400] * l_point_16;
            if (gia_512[g_index_400] < 2) gda_680[g_index_400] = gda_684[g_index_400] * l_point_16;
            if (gia_508[g_index_400] > 1) gda_672[g_index_400] = (gda_676[g_index_400] - ShagUvel_hSETKY * gia_508[g_index_400] * gi_644) * l_point_16;
            if (gia_512[g_index_400] > 1) gda_680[g_index_400] = (gda_684[g_index_400] - ShagUvel_hSETKY * gia_512[g_index_400] * gi_644) * l_point_16;
         }
         if (gda_672[g_index_400] < 10 * gi_644 * l_point_16) gda_672[g_index_400] = 10 * gi_644 * l_point_16;
         if (gda_680[g_index_400] < 10 * gi_644 * l_point_16) gda_680[g_index_400] = 10 * gi_644 * l_point_16;
         gia_608[g_index_400] = 0;
         gia_616[g_index_400] = 0;
         gia_612[g_index_400] = 0;
         gia_620[g_index_400] = 0;
         if (gia_508[g_index_400] == 0) gia_608[g_index_400] = 1;
         if (gia_512[g_index_400] == 0) gia_612[g_index_400] = 1;
         if (gia_508[g_index_400] > 0 && Ask < gda_472[g_index_400][0][li_80] - gda_672[g_index_400]) gia_608[g_index_400] = 1;
         if (gia_508[g_index_400] > 0 && Ask > gda_472[g_index_400][0][li_76] + gda_672[g_index_400]) gia_608[g_index_400] = 1;
         if (gia_512[g_index_400] > 0 && Bid > gda_472[g_index_400][1][li_84] + gda_680[g_index_400]) gia_612[g_index_400] = 1;
         if (gia_512[g_index_400] > 0 && Bid < gda_472[g_index_400][1][li_88] - gda_680[g_index_400]) gia_612[g_index_400] = 1;
         if (gia_508[g_index_400] > 0 && gia_508[g_index_400] > gia_512[g_index_400] && Ask < gda_472[g_index_400][0][li_80] - gda_672[g_index_400]) gia_608[g_index_400] = 1;
         if (gia_508[g_index_400] > 0 && gia_508[g_index_400] > gia_512[g_index_400] && Ask > gda_472[g_index_400][0][li_76] + gda_672[g_index_400]) gia_608[g_index_400] = 1;
         if (gia_512[g_index_400] > 0 && gia_512[g_index_400] > gia_508[g_index_400] && Bid > gda_472[g_index_400][1][li_84] + gda_680[g_index_400]) gia_612[g_index_400] = 1;
         if (gia_512[g_index_400] > 0 && gia_512[g_index_400] > gia_508[g_index_400] && Bid < gda_472[g_index_400][1][li_88] - gda_680[g_index_400]) gia_612[g_index_400] = 1;
         gia_632[g_index_400] = 0;
         gia_636[g_index_400] = 0;
         if (gia_608[g_index_400] > 0 || gia_612[g_index_400] > 0) {
            if (gia_508[g_index_400] == 0 && gia_512[g_index_400] == 0) {
               gia_632[g_index_400] = 1;
               gia_636[g_index_400] = 1;
            }
            if (gia_508[g_index_400] == 1 && gia_512[g_index_400] == 1 && gia_608[g_index_400] == 1) gia_632[g_index_400] = 1;
            if (gia_508[g_index_400] == 1 && gia_512[g_index_400] == 1 && gia_612[g_index_400] == 1) gia_636[g_index_400] = 1;
            if (gia_508[g_index_400] > 1 && gia_512[g_index_400] > 0 && l_bid_24 < gda_472[g_index_400][0][li_80] - gda_672[g_index_400]) gia_632[g_index_400] = 1;
            if (gia_508[g_index_400] > 0 && gia_512[g_index_400] > 1 && l_bid_24 > gda_472[g_index_400][1][li_84] + gda_680[g_index_400]) gia_636[g_index_400] = 1;
            if (gia_508[g_index_400] > 0 && gia_512[g_index_400] == 0 && l_bid_24 < gda_472[g_index_400][0][li_80] - gda_680[g_index_400]) gia_632[g_index_400] = 1;
            if (gia_508[g_index_400] == 0 && gia_512[g_index_400] > 0 && l_bid_24 > gda_472[g_index_400][1][li_84] + gda_672[g_index_400]) gia_636[g_index_400] = 1;
         }
         if (gsa_412[g_index_400] == ls_0) {
            if (gia_508[g_index_400] > gia_512[g_index_400]) {
               ObjectCreate(gsa_396[g_index_400][0], OBJ_HLINE, 0, Time[0], gda_472[g_index_400][0][li_80] - gda_672[g_index_400]);
               ObjectSet(gsa_396[g_index_400][0], OBJPROP_PRICE1, gda_472[g_index_400][0][li_80] - gda_672[g_index_400]);
               ObjectSet(gsa_396[g_index_400][0], OBJPROP_COLOR, gia_392[g_index_400][0]);
               ObjectSet(gsa_396[g_index_400][0], OBJPROP_STYLE, 7);
               ObjectCreate(gsa_396[g_index_400][1], OBJ_HLINE, 0, Time[0], gda_472[g_index_400][0][li_76] + gda_680[g_index_400]);
               ObjectSet(gsa_396[g_index_400][1], OBJPROP_PRICE1, gda_472[g_index_400][0][li_76] + gda_680[g_index_400]);
               ObjectSet(gsa_396[g_index_400][1], OBJPROP_COLOR, gia_392[g_index_400][1]);
               ObjectSet(gsa_396[g_index_400][1], OBJPROP_STYLE, 7);
            }
            if (gia_508[g_index_400] < gia_512[g_index_400]) {
               ObjectCreate(gsa_396[g_index_400][0], OBJ_HLINE, 0, Time[0], gda_472[g_index_400][1][li_88] - gda_672[g_index_400]);
               ObjectSet(gsa_396[g_index_400][0], OBJPROP_PRICE1, gda_472[g_index_400][1][li_88] - gda_672[g_index_400]);
               ObjectSet(gsa_396[g_index_400][0], OBJPROP_COLOR, gia_392[g_index_400][0]);
               ObjectSet(gsa_396[g_index_400][0], OBJPROP_STYLE, 7);
               ObjectCreate(gsa_396[g_index_400][1], OBJ_HLINE, 0, Time[0], gda_472[g_index_400][1][li_84] + gda_680[g_index_400]);
               ObjectSet(gsa_396[g_index_400][1], OBJPROP_PRICE1, gda_472[g_index_400][1][li_84] + gda_680[g_index_400]);
               ObjectSet(gsa_396[g_index_400][1], OBJPROP_COLOR, gia_392[g_index_400][1]);
               ObjectSet(gsa_396[g_index_400][1], OBJPROP_STYLE, 7);
            }
            if (gia_508[g_index_400] == gia_512[g_index_400]) {
               ObjectCreate(gsa_396[g_index_400][0], OBJ_HLINE, 0, Time[0], gda_472[g_index_400][0][li_80] - gda_672[g_index_400]);
               ObjectSet(gsa_396[g_index_400][0], OBJPROP_PRICE1, gda_472[g_index_400][0][li_80] - gda_672[g_index_400]);
               ObjectSet(gsa_396[g_index_400][0], OBJPROP_COLOR, gia_392[g_index_400][0]);
               ObjectSet(gsa_396[g_index_400][0], OBJPROP_STYLE, 7);
               ObjectCreate(gsa_396[g_index_400][1], OBJ_HLINE, 0, Time[0], gda_472[g_index_400][1][li_84] + gda_680[g_index_400]);
               ObjectSet(gsa_396[g_index_400][1], OBJPROP_PRICE1, gda_472[g_index_400][1][li_84] + gda_680[g_index_400]);
               ObjectSet(gsa_396[g_index_400][1], OBJPROP_COLOR, gia_392[g_index_400][1]);
               ObjectSet(gsa_396[g_index_400][1], OBJPROP_STYLE, 7);
            }
         }
         gi_unused_704 = 0;
         gi_unused_708 = 0;
         gi_712 = FALSE;
         gi_716 = FALSE;
         if (gia_608[g_index_400] == 1 && gia_632[g_index_400] == 1) gi_712 = TRUE;
         if (gia_612[g_index_400] == 1 && gia_636[g_index_400] == 1) gi_716 = TRUE;
         if (gi_712 == TRUE || gi_716 == TRUE || gia_568[g_index_400] == 1) {
            if (gia_508[g_index_400] == 0 && gia_512[g_index_400] == 0) gda_492[g_index_400] = NormalizeDouble(gda_688[g_index_400], li_68);
            if (gia_508[g_index_400] > 0 && gi_712 == TRUE) gda_492[g_index_400] = NormalizeDouble(gda_468[g_index_400][0][li_80] * LotMultiplicator, li_72);
            if (gia_508[g_index_400] > 0 && gi_716 == TRUE) gda_492[g_index_400] = NormalizeDouble(gda_468[g_index_400][1][li_84] * LotMultiplicator, li_72);
            if (gia_508[g_index_400] > 0 && gia_512[g_index_400] == 0) {
               gda_492[g_index_400] = NormalizeDouble(gda_468[g_index_400][0][li_80] * LotMultiplicator, li_72);
               gda_496[g_index_400] = gda_492[g_index_400];
            }
            if (gda_492[g_index_400] < l_minlot_44) gda_492[g_index_400] = l_minlot_44;
            if (gda_492[g_index_400] > g_maxlot_148) gda_492[g_index_400] = g_maxlot_148;
            g_ask_344 = MarketInfo(gsa_412[g_index_400], MODE_ASK);
            gd_320 = 0;
            gd_328 = gia_392[g_index_400][0];
            gd_368 = g_ask_344 - gda_656[g_index_400] * l_point_16;
            if (gda_656[g_index_400] == 0.0) gd_368 = 0;
            gd_360 = g_ask_344 + gda_648[g_index_400] * l_point_16;
            if (gda_648[g_index_400] == 0.0 || gia_508[g_index_400] > 0) gd_360 = 0;
            gi_536 = OpOrd(gsa_412[g_index_400], gd_320, gda_492[g_index_400], g_ask_344, gd_368, gd_360, gia_432[g_index_400], gd_328);
            if (gi_536 > 0) {
               gia_480[g_index_400][0][gia_508[g_index_400] + 1] = gi_536;
               gia_568[g_index_400] = 0;
            }
            if (gi_536 < 0) gia_568[g_index_400] = 1;
            gia_376[g_index_400] += gia_568[g_index_400];
            gia_568[g_index_400] = 0;
         }
         if (gi_712 == TRUE || gi_716 == TRUE || gia_572[g_index_400] == 1) {
            if (gia_508[g_index_400] == 0 && gia_512[g_index_400] == 0) gda_496[g_index_400] = NormalizeDouble(gda_692[g_index_400], li_68);
            if (gia_512[g_index_400] > 0 && gi_712 == TRUE) gda_496[g_index_400] = NormalizeDouble(gda_468[g_index_400][0][li_80] * LotMultiplicator, li_72);
            if (gia_512[g_index_400] > 0 && gi_716 == TRUE) gda_496[g_index_400] = NormalizeDouble(gda_468[g_index_400][1][li_84] * LotMultiplicator, li_72);
            if (gia_508[g_index_400] == 0 && gia_512[g_index_400] > 0) {
               gda_496[g_index_400] = NormalizeDouble(gda_468[g_index_400][1][li_84] * LotMultiplicator, li_72);
               gda_492[g_index_400] = gda_496[g_index_400];
            }
            if (gda_496[g_index_400] < l_minlot_44) gda_496[g_index_400] = l_minlot_44;
            if (gda_496[g_index_400] > g_maxlot_148) gda_496[g_index_400] = g_maxlot_148;
            if (gi_712 == TRUE || gi_716 == TRUE) g_bid_352 = MarketInfo(gsa_412[g_index_400], MODE_BID);
            gd_320 = 1;
            gd_328 = gia_392[g_index_400][1];
            gd_368 = g_bid_352 + gda_660[g_index_400] * l_point_16;
            if (gda_660[g_index_400] == 0.0) gd_368 = 0;
            gd_360 = g_bid_352 - gda_652[g_index_400] * l_point_16;
            if (gda_652[g_index_400] == 0.0 || gia_512[g_index_400] > 0) gd_360 = 0;
            gi_536 = OpOrd(gsa_412[g_index_400], gd_320, gda_496[g_index_400], g_bid_352, gd_368, gd_360, gia_432[g_index_400], gd_328);
            if (gi_536 > 0) gia_480[g_index_400][1][gia_512[g_index_400] + 1] = gi_536;
            if (gi_536 < 0) gia_572[g_index_400] = 1;
            gia_376[g_index_400] += gia_572[g_index_400];
            gia_572[g_index_400] = 0;
         }
         Sleep(500);
         N();
         if (gia_508[g_index_400] > 1 && gia_512[g_index_400] > 1 && Ask > gda_472[g_index_400][0][li_76] + gda_672[g_index_400]) gia_616[g_index_400] = 1;
         if (gia_512[g_index_400] > 1 && gia_508[g_index_400] > 1 && Bid < gda_472[g_index_400][1][li_88] - gda_680[g_index_400]) gia_620[g_index_400] = 1;
         gd_384 = 0;
         g_price_736 = 0;
         g_price_744 = 0;
         if (gia_616[g_index_400] == 1 || gia_576[g_index_400] == 1) {
            for (gi_556 = 1; gi_556 < gia_508[g_index_400]; gi_556++) {
               OrderSelect(gia_480[g_index_400][0][gi_556], SELECT_BY_TICKET, MODE_TRADES);
               gi_536 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(gsa_412[g_index_400], MODE_BID), g_slippage_316, gia_392[g_index_400][0]);
               if (gi_536 == 1 && gia_576[g_index_400] != 1) gia_576[g_index_400] = 0;
               if (gi_536 == 0) gia_576[g_index_400] = 1;
               gia_376[g_index_400] += gia_576[g_index_400];
            }
            gia_576[g_index_400] = 0;
         }
         N();
         gd_384 = U0(gia_508[g_index_400], gia_512[g_index_400]);
         if (gia_616[g_index_400] == 1 || gia_584[g_index_400] == 1) {
            for (gi_552 = 1; gi_552 <= gia_508[g_index_400]; gi_552++) {
               OrderSelect(gia_480[g_index_400][0][gi_552], SELECT_BY_TICKET, MODE_TRADES);
               if (OrderType() == OP_BUY && OrderMagicNumber() == gia_432[g_index_400] && OrderSymbol() == gsa_412[g_index_400]) {
                  if (gd_384 - gda_700[g_index_400] * l_point_16 != OrderStopLoss() || OrderStopLoss() == 0.0) {
                     gi_536 = OrderModify(OrderTicket(), OrderOpenPrice(), gd_384 - gda_700[g_index_400] * l_point_16, g_price_736, 0, gia_392[g_index_400][0]);
                     if (gi_536 == 0) gia_584[g_index_400] = 1;
                     if (gi_536 == 1 && gia_584[g_index_400] != 1) gia_584[g_index_400] = 0;
                  }
               }
            }
            gia_376[g_index_400] += gia_584[g_index_400];
            gia_584[g_index_400] = 0;
         }
         if (gia_616[g_index_400] == 1 || gia_588[g_index_400] == 1) {
            for (gi_552 = 1; gi_552 <= gia_512[g_index_400]; gi_552++) {
               OrderSelect(gia_480[g_index_400][1][gi_552], SELECT_BY_TICKET, MODE_TRADES);
               if (OrderType() == OP_SELL && OrderMagicNumber() == gia_432[g_index_400] && OrderSymbol() == gsa_412[g_index_400]) {
                  if (gd_384 - (gda_700[g_index_400] - l_spread_12) * l_point_16 != OrderTakeProfit() || OrderTakeProfit() == 0.0) {
                     gi_536 = OrderModify(OrderTicket(), OrderOpenPrice(), g_price_744, gd_384 - (gda_700[g_index_400] - l_spread_12) * l_point_16, 0, gia_392[g_index_400][1]);
                     if (gi_536 == 0) gia_588[g_index_400] = 1;
                     if (gi_536 == 1 && gia_588[g_index_400] == 0) gia_588[g_index_400] = 0;
                  }
               }
            }
            gia_376[g_index_400] += gia_588[g_index_400];
            gia_588[g_index_400] = 0;
         }
         if (gia_620[g_index_400] == 1 || gia_580[g_index_400] == 1) {
            for (gi_556 = 1; gi_556 < gia_512[g_index_400]; gi_556++) {
               OrderSelect(gia_480[g_index_400][1][gi_556], SELECT_BY_TICKET, MODE_TRADES);
               gi_536 = OrderClose(OrderTicket(), OrderLots(), MarketInfo(gsa_412[g_index_400], MODE_ASK), g_slippage_316, gia_392[g_index_400][1]);
               if (gi_536 == 1 && gia_580[g_index_400] != 1) gia_580[g_index_400] = 0;
               if (gi_536 == 0) gia_580[g_index_400] = 1;
               gia_376[g_index_400] += gia_580[g_index_400];
            }
            gia_580[g_index_400] = 0;
         }
         N();
         gd_384 = U0(gia_508[g_index_400], gia_512[g_index_400]);
         if (gia_620[g_index_400] == 1 || gia_592[g_index_400] == 1) {
            for (gi_552 = 1; gi_552 <= gia_508[g_index_400]; gi_552++) {
               OrderSelect(gia_480[g_index_400][0][gi_552], SELECT_BY_TICKET, MODE_TRADES);
               if (OrderType() == OP_BUY && OrderMagicNumber() == gia_432[g_index_400] && OrderSymbol() == gsa_412[g_index_400]) {
                  if (gd_384 + gda_696[g_index_400] * l_point_16 != OrderTakeProfit() || OrderTakeProfit() == 0.0) {
                     gi_536 = OrderModify(OrderTicket(), OrderOpenPrice(), g_price_736, gd_384 + gda_696[g_index_400] * l_point_16, 0, gia_392[g_index_400][0]);
                     if (gi_536 == 0) gia_592[g_index_400] = 1;
                     if (gi_536 == 1 && gia_592[g_index_400] != 1) gia_592[g_index_400] = 0;
                  }
               }
            }
            gia_376[g_index_400] += gia_592[g_index_400];
            gia_592[g_index_400] = 0;
         }
         if (gia_620[g_index_400] == 1 || gia_596[g_index_400] == 1) {
            for (gi_552 = 1; gi_552 <= gia_512[g_index_400]; gi_552++) {
               OrderSelect(gia_480[g_index_400][1][gi_552], SELECT_BY_TICKET, MODE_TRADES);
               if (OrderType() == OP_SELL && OrderMagicNumber() == gia_432[g_index_400] && OrderSymbol() == gsa_412[g_index_400]) {
                  if (gd_384 + (gda_696[g_index_400] + l_spread_12) * l_point_16 != OrderStopLoss() || OrderStopLoss() == 0.0) {
                     gi_536 = OrderModify(OrderTicket(), OrderOpenPrice(), gd_384 + (gda_696[g_index_400] + l_spread_12) * l_point_16, g_price_744, 0, gia_392[g_index_400][1]);
                     if (gi_536 == 0) gia_596[g_index_400] = 1;
                     if (gi_536 == 1 && gia_596[g_index_400] != 1) gia_596[g_index_400] = 0;
                  }
               }
            }
            gia_376[g_index_400] += gia_596[g_index_400];
            gia_596[g_index_400] = 0;
         }
         gsa_88[g_index_400] = "Основная. ТС - НОРМА";
         N();
         if ((gia_508[g_index_400] > 1 && gia_512[g_index_400] > 1) || (gia_508[g_index_400] > 1 && gia_512[g_index_400] > 0 && gda_484[g_index_400][1][gia_512[g_index_400]] == 0.0 &&
            gda_488[g_index_400][1][gia_512[g_index_400]] == 0.0) || (gia_508[g_index_400] > 0 && gia_512[g_index_400] > 1 && gda_484[g_index_400][0][gia_508[g_index_400]] == 0.0 && gda_488[g_index_400][0][gia_508[g_index_400]] == 0.0)) {
            ld_108 = UB(gia_508[g_index_400], 0) + gda_768[g_index_400] * l_point_16;
            ld_116 = UB(gia_512[g_index_400], 1) - gda_772[g_index_400] * l_point_16;
            gsa_88[g_index_400] = "Вспом., ожидание вкл. ТРАЛЛа";
         }
         if ((gia_508[g_index_400] > 0 && gia_512[g_index_400] == 0) || (gia_508[g_index_400] > 1 && gia_512[g_index_400] > 1 && Bid > ld_108)) {
            g_price_752 = U0(gia_508[g_index_400], gia_512[g_index_400]) + gda_768[g_index_400] * l_point_16;
            g_price_736 = 0;
            if (gia_508[g_index_400] > 1 && gia_512[g_index_400] > 1) {
               g_price_752 = ld_108;
               g_price_736 = 0;
            }
            gsa_88[g_index_400] = "Вспомогательная. Тралл BUY";
            if (gsa_412[g_index_400] == ls_0) {
               ObjectCreate("UBB", OBJ_HLINE, 0, Time[0], g_price_752);
               ObjectSet("UBB", OBJPROP_PRICE1, g_price_752);
               ObjectSet("UBB", OBJPROP_COLOR, gia_392[g_index_400][0]);
               ObjectSet("UBB", OBJPROP_WIDTH, 2);
               ObjectCreate("SLB", OBJ_HLINE, 0, Time[0], l_bid_24 - gia_664[g_index_400] * l_point_16);
               ObjectSet("SLB", OBJPROP_PRICE1, l_bid_24 - gia_664[g_index_400] * l_point_16);
               ObjectSet("SLB", OBJPROP_COLOR, gia_392[g_index_400][0]);
               ObjectSet("SLB", OBJPROP_STYLE, STYLE_DASHDOT);
            }
            if (gia_508[g_index_400] > 0 && g_price_752 < l_bid_24 - gia_664[g_index_400] * l_point_16) {
               for (gi_552 = 1; gi_552 <= gia_508[g_index_400]; gi_552++) {
                  OrderSelect(gia_480[g_index_400][0][gi_552], SELECT_BY_TICKET, MODE_TRADES);
                  if (OrderType() == OP_BUY && OrderMagicNumber() == gia_432[g_index_400] && OrderSymbol() == gsa_412[g_index_400])
                     if (l_bid_24 - gia_664[g_index_400] * l_point_16 > OrderStopLoss() || OrderStopLoss() == 0.0) gi_536 = OrderModify(gia_480[g_index_400][0][gi_552], OrderOpenPrice(), l_bid_24 - gia_664[g_index_400] * l_point_16, g_price_736, 0, gia_392[g_index_400][0]);
               }
            }
         } else {
            ObjectDelete("UBB");
            ObjectDelete("SLB");
         }
         if ((gia_508[g_index_400] == 0 && gia_512[g_index_400] > 0) || (gia_508[g_index_400] > 1 && gia_512[g_index_400] > 1 && Ask < ld_116)) {
            g_price_760 = U0(gia_508[g_index_400], gia_512[g_index_400]) - gda_772[g_index_400] * l_point_16;
            g_price_744 = 0;
            if (gia_508[g_index_400] > 1 && gia_512[g_index_400] > 1) {
               g_price_760 = ld_116;
               g_price_744 = 0;
            }
            gsa_88[g_index_400] = "Вспомогательная. Тралл SELL";
            if (gsa_412[g_index_400] == ls_0) {
               ObjectCreate("UBS", OBJ_HLINE, 0, Time[0], g_price_760);
               ObjectSet("UBS", OBJPROP_PRICE1, g_price_760);
               ObjectSet("UBS", OBJPROP_COLOR, gia_392[g_index_400][1]);
               ObjectSet("UBS", OBJPROP_WIDTH, 2);
               ObjectCreate("SLS", OBJ_HLINE, 0, Time[0], l_ask_32 + gia_668[g_index_400] * l_point_16);
               ObjectSet("SLS", OBJPROP_PRICE1, l_ask_32 + gia_668[g_index_400] * l_point_16);
               ObjectSet("SLS", OBJPROP_COLOR, gia_392[g_index_400][1]);
               ObjectSet("SLS", OBJPROP_STYLE, STYLE_DASHDOT);
            }
            if (gia_512[g_index_400] > 0 && g_price_760 > l_ask_32 + gia_668[g_index_400] * l_point_16) {
               for (gi_552 = 1; gi_552 <= gia_512[g_index_400]; gi_552++) {
                  OrderSelect(gia_480[g_index_400][1][gi_552], SELECT_BY_TICKET, MODE_TRADES);
                  if (OrderType() == OP_SELL && OrderMagicNumber() == gia_432[g_index_400] && OrderSymbol() == gsa_412[g_index_400])
                     if (l_ask_32 + gia_668[g_index_400] * l_point_16 < OrderStopLoss() || OrderStopLoss() == 0.0) gi_536 = OrderModify(gia_480[g_index_400][1][gi_552], OrderOpenPrice(), l_ask_32 + gia_668[g_index_400] * l_point_16, g_price_744, 0, gia_392[g_index_400][1]);
               }
            }
         } else {
            ObjectDelete("UBS");
            ObjectDelete("SLS");
         }
         gia_576[g_index_400] = 0;
         gia_580[g_index_400] = 0;
         gia_584[g_index_400] = 0;
         gia_588[g_index_400] = 0;
         gia_592[g_index_400] = 0;
         gia_596[g_index_400] = 0;
         if (gia_508[g_index_400] == 1 && gia_512[g_index_400] > 1) {
            for (gi_552 = 1; gi_552 <= gia_512[g_index_400]; gi_552++) {
               if (gda_484[g_index_400][1][gi_552] == 0.0 && gda_488[g_index_400][1][gi_552] == 0.0) {
                  gia_584[g_index_400] = 1;
                  gia_588[g_index_400] = 1;
               }
            }
            if (gda_484[g_index_400][0][gia_508[g_index_400]] == 0.0 && gda_488[g_index_400][0][gia_508[g_index_400]] == 0.0) {
               gia_584[g_index_400] = 1;
               gia_588[g_index_400] = 1;
            }
         }
         if (gia_508[g_index_400] > 1 && gia_512[g_index_400] == 1) {
            for (gi_552 = 1; gi_552 <= gia_508[g_index_400]; gi_552++) {
               if (gda_484[g_index_400][0][gi_552] == 0.0 && gda_488[g_index_400][0][gi_552] == 0.0) {
                  gia_592[g_index_400] = 1;
                  gia_596[g_index_400] = 1;
               }
            }
            if (gda_484[g_index_400][1][gia_512[g_index_400]] == 0.0 && gda_488[g_index_400][1][gia_512[g_index_400]] == 0.0) {
               gia_592[g_index_400] = 1;
               gia_596[g_index_400] = 1;
            }
         }
      }
   }
   if (gia_508[0] > 0 || gia_512[0] > 0 && gia_508[1] > 0 || gia_512[1] > 0 && gia_508[2] > 0 || gia_512[2] > 0) {
      Comment("                         +-----------------------------------------------------------------------+", 
         "\n", "                          |   Колич. ордеров 0 слой = ", gia_508[0] + gia_512[0], " (", gia_508[0], "+", gia_512[0], ")", 
         "\n", "                          |   Торг. логика - ", gsa_88[0], 
         "\n", "                          |   Колич. сбоев сетки = ", gia_376[0], 
         "\n", "                          |   ", 
         "\n", "                          |   Колич. ордеров 1 слой = ", gia_508[1] + gia_512[1], " (", gia_508[1], "+", gia_512[1], ")", 
         "\n", "                          |   Торг. логика - ", gsa_88[1], 
         "\n", "                          |   Колич. сбоев сетки = ", gia_376[1], 
         "\n", "                          |   ", 
         "\n", "                          |   Колич. ордеров 2 слой = ", gia_508[2] + gia_512[2], " (", gia_508[2], "+", gia_512[2], ")", 
         "\n", "                          |   Торг. логика - ", gsa_88[2], 
         "\n", "                          |   Колич. сбоев сетки = ", gia_376[2], 
      "\n", "                         +-----------------------------------------------------------------------+");
   }
   if (gia_508[0] > 0 || gia_512[0] > 0 && gia_508[1] > 0 || gia_512[1] > 0 && gia_508[2] == 0 && gia_512[2] == 0) {
      Comment("                         +-----------------------------------------------------------------------+", 
         "\n", "                          |   Колич. ордеров 0 слой = ", gia_508[0] + gia_512[0], " (", gia_508[0], "+", gia_512[0], ")", 
         "\n", "                          |   Торг. логика - ", gsa_88[0], 
         "\n", "                          |   Колич. сбоев сетки = ", gia_376[0], 
         "\n", "                          |   ", 
         "\n", "                          |   Колич. ордеров 1 слой = ", gia_508[1] + gia_512[1], " (", gia_508[1], "+", gia_512[1], ")", 
         "\n", "                          |   Торг. логика - ", gsa_88[1], 
         "\n", "                          |   Колич. сбоев сетки = ", gia_376[1], 
      "\n", "                         +-----------------------------------------------------------------------+");
   }
   if (gia_508[0] > 0 || gia_512[0] > 0 && gia_508[2] > 0 || gia_512[2] > 0 && gia_508[1] == 0 && gia_512[1] == 0) {
      Comment("                         +-----------------------------------------------------------------------+", 
         "\n", "                          |   Колич. ордеров 0 слой = ", gia_508[0] + gia_512[0], " (", gia_508[0], "+", gia_512[0], ")", 
         "\n", "                          |   Торг. логика - ", gsa_88[0], 
         "\n", "                          |   Колич. сбоев сетки = ", gia_376[0], 
         "\n", "                          |   ", 
         "\n", "                          |   Колич. ордеров 2 слой = ", gia_508[2] + gia_512[2], " (", gia_508[2], "+", gia_512[2], ")", 
         "\n", "                          |   Торг. логика - ", gsa_88[2], 
         "\n", "                          |   Колич. сбоев сетки = ", gia_376[2], 
      "\n", "                         +-----------------------------------------------------------------------+");
   }
   if (gia_508[0] > 0 || gia_512[0] > 0 && gia_508[1] == 0 && gia_512[1] == 0 && gia_508[2] == 0 && gia_512[2] == 0) {
      Comment("                         +-----------------------------------------------------------------------+", 
         "\n", "                          |   Колич. ордеров 0 слой = ", gia_508[0] + gia_512[0], " (", gia_508[0], "+", gia_512[0], ")", 
         "\n", "                          |   Торг. логика - ", gsa_88[0], 
         "\n", "                          |   Колич. сбоев сетки = ", gia_376[0], 
      "\n", "                         +-----------------------------------------------------------------------+");
   }
   return (0);
}

int OpOrd(string a_symbol_0, int a_cmd_8, double a_lots_12, double a_price_20, double a_price_28, double a_price_36, int a_magic_44, color a_color_48) {
   int l_ticket_52;
   l_ticket_52 = OrderSend(a_symbol_0, a_cmd_8, a_lots_12, a_price_20, 6, a_price_28, a_price_36, gsa_412[g_index_400] + " MGK-" + a_magic_44 + " торг.сл.№" + g_index_400, a_magic_44, 0, a_color_48);
   return (l_ticket_52);
}

double UB(int ai_0, int ai_4) {
   double ld_8 = 0;
   double ld_16 = 0;
   for (gi_552 = 1; gi_552 <= ai_0; gi_552++) {
      ld_8 += gda_472[g_index_400][ai_4][gi_552] * gda_468[g_index_400][ai_4][gi_552];
      ld_16 += gda_468[g_index_400][ai_4][gi_552];
   }
   if (ld_16 == 0.0) return (0);
   return (ld_8 / ld_16);
}

double U0(int ai_0, int ai_4) {
   double ld_8 = 0;
   double ld_16 = 0;
   double ld_24 = 0;
   double ld_32 = 0;
   for (gi_552 = 1; gi_552 <= ai_0; gi_552++) {
      ld_8 += gda_472[g_index_400][0][gi_552] * gda_468[g_index_400][0][gi_552];
      ld_16 += gda_468[g_index_400][0][gi_552];
   }
   for (gi_552 = 1; gi_552 <= ai_4; gi_552++) {
      ld_24 += gda_472[g_index_400][1][gi_552] * gda_468[g_index_400][1][gi_552];
      ld_32 += gda_468[g_index_400][1][gi_552];
   }
   if (ld_16 - ld_32 == 0.0) return (0);
   return ((ld_8 - ld_24) / (ld_16 - ld_32));
}

int MIN(int ai_0, int ai_4) {
   int li_ret_16;
   double ld_8 = 1000;
   for (gi_552 = 1; gi_552 <= ai_4; gi_552++) {
      if (ld_8 >= gda_472[g_index_400][ai_0][gi_552]) {
         ld_8 = gda_472[g_index_400][ai_0][gi_552];
         li_ret_16 = gi_552;
      }
   }
   return (li_ret_16);
}

int MAX(int ai_0, int ai_4) {
   int li_ret_16;
   double ld_8 = 0;
   for (gi_552 = 1; gi_552 <= ai_4; gi_552++) {
      if (ld_8 <= gda_472[g_index_400][ai_0][gi_552]) {
         ld_8 = gda_472[g_index_400][ai_0][gi_552];
         li_ret_16 = gi_552;
      }
   }
   return (li_ret_16);
}

int NOV(int ai_0, int ai_4, double ad_8) {
   int li_ret_24;
   double ld_16 = 1000;
   for (gi_552 = 1; gi_552 <= ai_4; gi_552++) {
      if (ld_16 >= gda_472[g_index_400][ai_0][gi_552] && ad_8 <= gda_472[g_index_400][ai_0][gi_552]) {
         ld_16 = gda_472[g_index_400][ai_0][gi_552];
         li_ret_24 = gi_552;
      }
   }
   return (li_ret_24);
}

int NON(int ai_0, int ai_4, double ad_8) {
   int li_ret_24;
   double ld_16 = 0;
   for (gi_552 = 1; gi_552 <= ai_4; gi_552++) {
      if (ld_16 <= gda_472[g_index_400][ai_0][gi_552] && ad_8 >= gda_472[g_index_400][ai_0][gi_552]) {
         ld_16 = gda_472[g_index_400][ai_0][gi_552];
         li_ret_24 = gi_552;
      }
   }
   return (li_ret_24);
}

void N() {
   gia_508[g_index_400] = 0;
   gia_512[g_index_400] = 0;
   gia_516[g_index_400] = 0;
   gia_520[g_index_400] = 0;
   int l_count_0 = 0;
   int l_count_4 = 0;
   int l_count_8 = 0;
   int l_count_12 = 0;
   int l_count_16 = 0;
   int l_count_20 = 0;
   gda_500[g_index_400][0] = 0;
   gda_500[g_index_400][1] = 0;
   gda_500[g_index_400][2] = 0;
   gda_500[g_index_400][3] = 0;
   gda_504[g_index_400][0] = 0;
   gda_504[g_index_400][1] = 0;
   g_ord_total_540 = OrdersTotal();
   for (g_pos_532 = 0; g_pos_532 < g_ord_total_540; g_pos_532++) {
      OrderSelect(g_pos_532, SELECT_BY_POS, MODE_TRADES);
      if (OrderType() == OP_BUY && OrderMagicNumber() == gia_432[g_index_400] && OrderSymbol() == gsa_412[g_index_400]) {
         l_count_0++;
         gia_480[g_index_400][0][l_count_0] = OrderTicket();
         gda_472[g_index_400][0][l_count_0] = OrderOpenPrice();
         gda_468[g_index_400][0][l_count_0] = OrderLots();
         gda_476[g_index_400][0][l_count_0] = OrderProfit();
         gda_484[g_index_400][0][l_count_0] = OrderTakeProfit();
         gda_488[g_index_400][0][l_count_0] = OrderStopLoss();
         gda_504[g_index_400][0] += gda_476[g_index_400][0][l_count_0];
         gda_500[g_index_400][0] += gda_468[g_index_400][0][l_count_0];
         if (gda_488[g_index_400][0][l_count_0] > 0.0) l_count_8++;
      }
      if (OrderType() == OP_SELL && OrderMagicNumber() == gia_432[g_index_400] && OrderSymbol() == gsa_412[g_index_400]) {
         l_count_4++;
         gia_480[g_index_400][1][l_count_4] = OrderTicket();
         gda_472[g_index_400][1][l_count_4] = OrderOpenPrice();
         gda_468[g_index_400][1][l_count_4] = OrderLots();
         gda_476[g_index_400][1][l_count_4] = OrderProfit();
         gda_484[g_index_400][1][l_count_4] = OrderTakeProfit();
         gda_488[g_index_400][1][l_count_4] = OrderStopLoss();
         gda_504[g_index_400][1] += gda_476[g_index_400][1][l_count_4];
         gda_500[g_index_400][1] += gda_468[g_index_400][1][l_count_4];
         if (gda_488[g_index_400][1][l_count_4] > 0.0) l_count_12++;
      }
      if (OrderType() == OP_BUYSTOP && OrderMagicNumber() == gia_432[g_index_400] && OrderSymbol() == gsa_412[g_index_400]) {
         l_count_16++;
         gia_480[g_index_400][2][l_count_16] = OrderTicket();
         gda_472[g_index_400][2][l_count_16] = OrderOpenPrice();
         gda_484[g_index_400][2][l_count_16] = OrderTakeProfit();
         gda_488[g_index_400][2][l_count_16] = OrderStopLoss();
         gda_468[g_index_400][2][l_count_16] = OrderLots();
         gda_500[g_index_400][2] += gda_468[g_index_400][2][l_count_16];
      }
      if (OrderType() == OP_SELLSTOP && OrderMagicNumber() == gia_432[g_index_400] && OrderSymbol() == gsa_412[g_index_400]) {
         l_count_20++;
         gda_472[g_index_400][3][l_count_20] = OrderOpenPrice();
         gia_480[g_index_400][3][l_count_20] = OrderTicket();
         gda_484[g_index_400][3][l_count_20] = OrderTakeProfit();
         gda_488[g_index_400][3][l_count_20] = OrderStopLoss();
         gda_468[g_index_400][3][l_count_20] = OrderLots();
         gda_500[g_index_400][3] += gda_468[g_index_400][3][l_count_20];
      }
   }
   gia_508[g_index_400] = l_count_0;
   gia_512[g_index_400] = l_count_4;
   gia_524[g_index_400] = l_count_8;
   gia_528[g_index_400] = l_count_12;
   gia_516[g_index_400] = l_count_16;
   gia_520[g_index_400] = l_count_20;
}

void DrawStats() {
   double ld_0 = GetProfitForDay(0);
   string l_name_8 = gs_80 + "1";
   if (ObjectFind(l_name_8) == -1) {
      ObjectCreate(l_name_8, OBJ_LABEL, 0, 0, 0);
      ObjectSet(l_name_8, OBJPROP_CORNER, 1);
      ObjectSet(l_name_8, OBJPROP_XDISTANCE, 10);
      ObjectSet(l_name_8, OBJPROP_YDISTANCE, 15);
   }
   ObjectSetText(l_name_8, "Заработок сегодня: " + DoubleToStr(ld_0, 2), 10, "Courier New", Yellow);
   ld_0 = GetProfitForDay(1);
   l_name_8 = gs_80 + "2";
   if (ObjectFind(l_name_8) == -1) {
      ObjectCreate(l_name_8, OBJ_LABEL, 0, 0, 0);
      ObjectSet(l_name_8, OBJPROP_CORNER, 1);
      ObjectSet(l_name_8, OBJPROP_XDISTANCE, 10);
      ObjectSet(l_name_8, OBJPROP_YDISTANCE, 30);
   }
   ObjectSetText(l_name_8, "Заработок вчера: " + DoubleToStr(ld_0, 2), 10, "Courier New", Yellow);
   ld_0 = GetProfitForDay(2);
   l_name_8 = gs_80 + "3";
   if (ObjectFind(l_name_8) == -1) {
      ObjectCreate(l_name_8, OBJ_LABEL, 0, 0, 0);
      ObjectSet(l_name_8, OBJPROP_CORNER, 1);
      ObjectSet(l_name_8, OBJPROP_XDISTANCE, 10);
      ObjectSet(l_name_8, OBJPROP_YDISTANCE, 45);
   }
   ObjectSetText(l_name_8, "Заработок позавчера: " + DoubleToStr(ld_0, 2), 10, "Courier New", Yellow);
   l_name_8 = gs_80 + "4";
   if (ObjectFind(l_name_8) == -1) {
      ObjectCreate(l_name_8, OBJ_LABEL, 0, 0, 0);
      ObjectSet(l_name_8, OBJPROP_CORNER, 1);
      ObjectSet(l_name_8, OBJPROP_XDISTANCE, 10);
      ObjectSet(l_name_8, OBJPROP_YDISTANCE, 75);
   }
   ObjectSetText(l_name_8, "Баланс: " + DoubleToStr(AccountBalance(), 2), 12, "Courier New", Yellow);
}

void DrawLogo() {
   string l_name_0 = gs_80 + "L_1";
   if (ObjectFind(l_name_0) == -1) {
      ObjectCreate(l_name_0, OBJ_LABEL, 0, 0, 0);
      ObjectSet(l_name_0, OBJPROP_CORNER, 0);
      ObjectSet(l_name_0, OBJPROP_XDISTANCE, 390);
      ObjectSet(l_name_0, OBJPROP_YDISTANCE, 10);
   }
   ObjectSetText(l_name_0, "I N V E S T", 28, "Verdana", Chocolate);
   l_name_0 = gs_80 + "L_2";
   if (ObjectFind(l_name_0) == -1) {
      ObjectCreate(l_name_0, OBJ_LABEL, 0, 0, 0);
      ObjectSet(l_name_0, OBJPROP_CORNER, 0);
      ObjectSet(l_name_0, OBJPROP_XDISTANCE, 478);
      ObjectSet(l_name_0, OBJPROP_YDISTANCE, 47);
   }
   ObjectSetText(l_name_0, "S Y S T E M", 16, "Verdana", SaddleBrown);
   l_name_0 = gs_80 + "L_3";
   if (ObjectFind(l_name_0) == -1) {
      ObjectCreate(l_name_0, OBJ_LABEL, 0, 0, 0);
      ObjectSet(l_name_0, OBJPROP_CORNER, 0);
      ObjectSet(l_name_0, OBJPROP_XDISTANCE, 393);
      ObjectSet(l_name_0, OBJPROP_YDISTANCE, 78);
   }
   ObjectSetText(l_name_0, "www.invest-system.net", 12, "Verdana", Gold);
   l_name_0 = gs_80 + "L_4";
   if (ObjectFind(l_name_0) == -1) {
      ObjectCreate(l_name_0, OBJ_LABEL, 0, 0, 0);
      ObjectSet(l_name_0, OBJPROP_CORNER, 0);
      ObjectSet(l_name_0, OBJPROP_XDISTANCE, 393);
      ObjectSet(l_name_0, OBJPROP_YDISTANCE, 81);
   }
   ObjectSetText(l_name_0, "_____________________", 12, "Verdana", Gold);
   l_name_0 = gs_80 + "L_5";
   if (ObjectFind(l_name_0) == -1) {
      ObjectCreate(l_name_0, OBJ_LABEL, 0, 0, 0);
      ObjectSet(l_name_0, OBJPROP_CORNER, 0);
      ObjectSet(l_name_0, OBJPROP_XDISTANCE, 393);
      ObjectSet(l_name_0, OBJPROP_YDISTANCE, 84);
   }
   ObjectSetText(l_name_0, "___________________", 12, "Verdana", Gold);
   l_name_0 = gs_80 + "L_6";
   if (ObjectFind(l_name_0) == -1) {
      ObjectCreate(l_name_0, OBJ_LABEL, 0, 0, 0);
      ObjectSet(l_name_0, OBJPROP_CORNER, 0);
      ObjectSet(l_name_0, OBJPROP_XDISTANCE, 393);
      ObjectSet(l_name_0, OBJPROP_YDISTANCE, 87);
   }
   ObjectSetText(l_name_0, "_________________", 12, "Verdana", Gold);
}

double GetProfitForDay(int ai_0) {
   double ld_ret_4 = 0;
   for (int l_pos_12 = 0; l_pos_12 < OrdersHistoryTotal(); l_pos_12++) {
      if (!(OrderSelect(l_pos_12, SELECT_BY_POS, MODE_HISTORY))) break;
      if (OrderSymbol() == gsa_412[g_index_400] && OrderMagicNumber() == gia_432[0] || OrderMagicNumber() == gia_432[1] || OrderMagicNumber() == gia_432[2])
         if (OrderCloseTime() >= iTime(gsa_412[g_index_400], PERIOD_D1, ai_0) && OrderCloseTime() < iTime(gsa_412[g_index_400], PERIOD_D1, ai_0) + 86400) ld_ret_4 = ld_ret_4 + OrderProfit() + OrderCommission() + OrderSwap();
   }
   return (ld_ret_4);
}

Recommend