#property  copyright "Copyright © 2010, ZeusFX Trading Solutions."
#property  link "http://www.zeusfx.com"

#import    "ZeusFX-EURUSD-M01.ex4"
   int OrderExport01(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA01(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB01(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-EURUSD-M02.ex4"
   int OrderExport02(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA02(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB02(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-EURUSD-M03.ex4"
   int OrderExport03(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA03(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB03(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-EURUSD-M04.ex4"
   int OrderExport04(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA04(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB04(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-EURUSD-M05.ex4"
   int OrderExport05(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA05(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB05(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-EURUSD-M06.ex4"
   int OrderExport06(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA06(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB06(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-EURUSD-M08.ex4"
   int OrderExport08(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA08(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB08(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-EURUSD-M09.ex4"
   int OrderExport09(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA09(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB09(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-EURUSD-M10.ex4"
   int OrderExport10(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA10(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB10(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-EURUSD-M11.ex4"
   int OrderExport11(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA11(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB11(int i1, double d1, double d2, double d3, int i2, int i3);
#import

string   Account_Number = "";
string   Email_Address = "";
string   KeyPrefix = "AABBCCDD";
int      Key1 = 947669235;
int      Key2 = 863230;
int      Key3 = -1087097329;
extern   string   CurrencyC1 = "EURUSD";
extern   string   PART_ONE = "Time Configurations";
string   var_128 = "Tokyo:0-9(GMT) --- London:8-17(GMT) --- NewYork:13-22(GMT)";
int      Hour1 = 0;
int      Hour2 = 24;
extern   int      MondayStart = 15;
extern   int      FridayEndHour = 15;
extern   int      BrokerGMT = 2;
extern   string   PART_TWO = "Money Management Configurations";
double   var_164 = 30;
extern   string   RiskRange = "1 To 10";
extern   double   Risk = 10;
double   var_188 = 10;
extern   bool     AntiFullMargin = true;
extern   int      MaxMargin = 98;
int      var_204 = 4;
extern   int      Digit = 4;
extern   int      LotsDigit = 2;
string   var_216 = "Trading Configurations";
int      Channel = 100;
string   Internals = "!! Do NOT! Change Below This Line !!";
string   I_B_A = "[5][38730][67][][[3]7[][45][r32][5[6][34]67]54]6[856][83061]";
string   I_B_B = "[23]6[54]8[6]9[6]79[67][]3[32]6[]5[56]8]57[34]6[43]67[54]74]";
string   I_B_C = "[8]658]7[9[67][]2[3[]765[]9[][3]5[[8]5[7][8]8]9[][][5[][685]";
string   I_B_D = "[12]5[5]78]973[23]6[54]8[6]9[6]79[67][]3[32]6[]5[56]8]57[34]";
string   var_268 = "Key Scramble SC1";
string   var_276 = "02F8C241A58E00301AC73442EF00F184EEA92220301053F";
string   var_284 = "A85200274493C37D02716391F62833201C6AA37593602EF";
string   var_292 = "71C86305BFA50030260063070200C3627049C73D01E824F";
string   var_300 = "LEDHSPENABS0FHSSMDKEIAPLDJWLEQAOMNRFOSJWOHSKTVB";
string   var_308 = "J30SKDNMEPATLB`FK#KH#*MKS^L@NVHSOG%JSIHLXM#JHWI";
string   var_316 = "!)~+$*)@$*@+!^$(@_&#(!!^$(@@&!~%(%#@)#%*@$!*@(#";
string   var_324 = "BOEJA^#$)DN!(~NK#K&$KAP@HG~$K##(FOQ&LSKTZB$@)F";
string   var_332 = "hwomdjksleuewjhlsadyap@fsjk$lse0#@(!tkeyqfh~yk";
string   var_340 = "wsiWpsgK@B7Djg8#A~hkr~sdUIY~6#)ngwH4*2KW@%S5l@";
string   var_348 = "Key Scramble SC2";
string   var_356 = "02F8C241A58E00301AC73442EF00F184EEA92220301053F";
string   var_364 = "A85200274493C37D02716391F62833201C6AA37593602EF";
string   var_372 = "71C86305BFA50030260063070200C3627049C73D01E824F";
string   var_380 = "LEDHSPENABS0FHSSMDKEIAPLDJWLEQAOMNRFOSJWOHSKTVB";
string   var_388 = "J30SKDNMEPATLB`FK#KH#*MKS^L@NVHSOG%JSIHLXM#JHWI";
string   var_396 = "!)~+$*)@$*@+!^$(@_&#(!!^$(@@&!~%(%#@)#%*@$!*@(#";
string   var_404 = "BOEJA^#$)DN!(~NK#K&$KAP@HG~$K##(FOQ&LSKTZB$@)F";
string   var_412 = "hwomdjksleuewjhlsadyap@fsjk$lse0#@(!tkeyqfh~yk";
string   var_420 = "wsiWpsgK@B7Djg8#A~hkr~sdUIY~6#)ngwH4*2KW@%S5l@";
string   var_428 = "...................../??/)";
string   var_436 = "...................,/?../";
string   var_444 = "................../..../";
string   var_452 = "............./??/'...'/???`??";
string   var_460 = "........../'/.../..../......./??\.";
string   var_468 = "........('(...?...?.... ?~/'...')";
string   var_476 = ".........\.................'...../";
string   var_484 = "..........''...\.......... _.??";
string   var_492 = "............\..............(";
string   var_500 = "..............\.............\...";
int      ExpiredDate = D'2021.10.28 02:00:00';

//+------------------------------------------------------------------+

int init()
{
return(0);
}

//+------------------------------------------------------------------+

int deinit()
{
return(0);
}

//+------------------------------------------------------------------+

int start()
{
if (TimeCurrent() >= ExpiredDate)
   {
   Alert("[ EA INTERNAL LOGIC IS DAMAGED! ]");
   Alert("[ OPERATION TERMINATED! ]");
   Alert("[ ERROR CODE: 485027 ]");
   Sleep(500000);
   return(0);
   }
   
int    max = 11;
int    spread = MarketInfo(CurrencyC1,MODE_SPREAD);
int    var_start_8;
int    var_start_12 = 0;
int    expired = 0;
double point = PointNumbersC1(Digit);
bool   allow_trade[12];
bool   arr_start_32[12];
bool   arr_start_36[12];
bool   strail_allow[12];
bool   otrail_allow[12];
int    cmd[12];
int    magic[12];
int    buy_cnt[12];
int    sell_cnt[12];
int    strail_profit[12];
int    strail[12];
int    otrail_profit[12];
int    otrail[12];
double buy_top_price[12];
double buy_bot_price[12];
double sell_top_price[12];
double sell_bot_price[12];
double buy_openprice[12];
double sell_openprice[12];
double lots_buy[12];
double lots_sell[12];
double otraila[12];
double otrailb[12];
double straila[12];
double strailb[12];
int    buy_opentime[12];
int    sell_opentime[12];
double ask1 = NormalizeDouble(MarketInfo(CurrencyC1,MODE_ASK),Digit);
double bid1 = NormalizeDouble(MarketInfo(CurrencyC1,MODE_BID),Digit);

for (int j = 1; j <= max; j++)
   {
   allow_trade[j] = false;
   arr_start_32[j] = false;
   arr_start_36[j] = false;
   cmd[j] = 0;
   buy_cnt[j] = 0;
   sell_cnt[j] = 0;
   buy_openprice[j] = 0;
   sell_openprice[j] = 0;
   buy_opentime[j] = 0;
   sell_opentime[j] = 0;
   lots_buy[j] = 0;
   lots_sell[j] = 0;
   buy_top_price[j] = 0;
   buy_bot_price[j] = 0;
   sell_top_price[j] = 0;
   sell_bot_price[j] = 0;
   }

magic[1] = 10101;
magic[2] = 20202;
magic[3] = 30303;
magic[4] = 40404;
magic[5] = 50505;
magic[6] = 60606;
magic[7] = 70707;
magic[8] = 80808;
magic[9] = 90909;
magic[10] = 101010;
magic[11] = 111111;

allow_trade[1] = true;
allow_trade[2] = true;
allow_trade[3] = true;
allow_trade[4] = true;
allow_trade[5] = true;
allow_trade[6] = true;
allow_trade[7] = true;
allow_trade[8] = true;
allow_trade[9] = true;
allow_trade[10] = true;
allow_trade[11] = true;

strail_allow[1] = true;
strail_profit[1] = 6;
strail[1] = 3;
otrail_allow[1] = true;
otrail_profit[1] = 6;
otrail[1] = 3;

strail_allow[2] = true;
strail_profit[2] = 6;
strail[2] = 3;
otrail_allow[2] = true;
otrail_profit[2] = 6;
otrail[2] = 3;

strail_allow[3] = true;
strail_profit[3] = 4;
strail[3] = 2;
otrail_allow[3] = true;
otrail_profit[3] = 4;
otrail[3] = 2;

strail_allow[4] = true;
strail_profit[4] = 6;
strail[4] = 3;
otrail_allow[4] = true;
otrail_profit[4] = 6;
otrail[4] = 3;

strail_allow[5] = true;
strail_profit[5] = 6;
strail[5] = 3;
otrail_allow[5] = true;
otrail_profit[5] = 6;
otrail[5] = 3;

strail_allow[6] = true;
strail_profit[6] = 6;
strail[6] = 3;
otrail_allow[6] = true;
otrail_profit[6] = 6;
otrail[6] = 3;

strail_allow[7] = true;
strail_profit[7] = 5;
strail[7] = 3;
otrail_allow[7] = true;
otrail_profit[7] = 5;
otrail[7] = 3;

strail_allow[8] = true;
strail_profit[8] = 6;
strail[8] = 3;
otrail_allow[8] = true;
otrail_profit[8] = 6;
otrail[8] = 3;

strail_allow[9] = true;
strail_profit[9] = 6;
strail[9] = 3;
otrail_allow[9] = true;
otrail_profit[9] = 6;
otrail[9] = 3;

strail_allow[10] = true;
strail_profit[10] = 6;
strail[10] = 3;
otrail_allow[10] = true;
otrail_profit[10] = 6;
otrail[10] = 3;

strail_allow[11] = true;
strail_profit[11] = 9;
strail[11] = 3;
otrail_allow[11] = true;
otrail_profit[11] = 6;
otrail[11] = 3;

int hour = Hour() - BrokerGMT;
if (hour < 0) hour = hour + 24;
if (hour >= 24) hour = hour - 24;

if (IsTesting() && ((Year() <= 2004) || ((Year() >= 2021) && (Month() >= 7)))) expired = 1;

for (int i = 0; i < OrdersTotal(); i++)
   {
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   for (j = 1; j <= max; j++)
      {
      if ((OrderMagicNumber() == magic[j]) && (OrderType() == OP_BUY))
         {
         buy_cnt[j] = buy_cnt[j] + 1;
         if (OrderOpenTime() >= buy_opentime[j])
            {
            buy_opentime[j] = OrderOpenTime();
            buy_openprice[j] = NormalizeDouble(OrderOpenPrice(),Digit);
            }
         }
      if ((OrderMagicNumber() == magic[j]) && (OrderType() == OP_SELL))
         {
         sell_cnt[j] = sell_cnt[j] + 1;
         if (OrderOpenTime() >= sell_opentime[j])
            {
            sell_opentime[j] = OrderOpenTime();
            sell_openprice[j] = NormalizeDouble(OrderOpenPrice(),Digit);
            }
         }
      }
   }

for (j = 1; j <= max; j++)
   {
   if (buy_cnt[j] == 0)
      {
      otraila[j] = 0;
      straila[j] = 0;
      }
   if (sell_cnt[j] == 0)
      {
      otrailb[j] = 1000000;
      strailb[j] = 1000000;
      }
   }

for (j = 1; j <= max; j++)
   {
   buy_top_price[j] = buy_openprice[j] + Channel * point;
   buy_bot_price[j] = buy_openprice[j] - Channel * point;
   sell_top_price[j] = sell_openprice[j] + Channel * point;
   sell_bot_price[j] = sell_openprice[j] - Channel * point;
   }

for (j = 1; j <= max; j++)
   {
   if ((ask1 >= buy_bot_price[j]) && (ask1 <= buy_top_price[j]))
      {
      for (int l = 1; l <= max; l++)
         {
         if (buy_cnt[l] == 0) arr_start_32[l] = true;
         }
      }
   if ((bid1 <= sell_top_price[j]) && (bid1 >= sell_bot_price[j]))
      {
      for (l = 1; l <= max; l++)
         {
         if (sell_cnt[l] == 0) arr_start_36[l] = true;
         }
      }
   }

string msg = "\n" + "    ZEUSFX-EURUSD-V1.1 Is Running..." + " \n" + "   ------------------------------------------------------" + " \n";
Comment(msg);

double high_m5 = iHigh(CurrencyC1,PERIOD_M5,0);
double low_m5 = iLow(CurrencyC1,PERIOD_M5,0);
double high_m30 = iHigh(CurrencyC1,PERIOD_M30,0);
double low_m30 = iLow(CurrencyC1,PERIOD_M30,0);
double ask2 = NormalizeDouble(MarketInfo(CurrencyC1,MODE_ASK),var_204);
double bid2 = NormalizeDouble(MarketInfo(CurrencyC1,MODE_BID),var_204);

if (((Hour1 < Hour2) && (hour >= Hour1) && (hour < Hour2)) || ((Hour1 > Hour2) && ((hour >= Hour1) || (hour < Hour2))))
   {
   if (expired == 0)
      {
      if (high_m5 == low_m5)
         {
         cmd[1] = OrderExport01(CurrencyC1,magic[1],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[1] = OrderVolumeA01(magic[1],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[1] = OrderVolumeB01(magic[1],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[1] == 3) || (cmd[1] == 4)) && (arr_start_32[1] == false) && (allow_trade[1] == true))
            {
            OrderSend(CurrencyC1,OP_BUY,lots_buy[1],ask2,3,0,0,"ZeusFX-EURUSD",magic[1],0,Blue);
            return(0);
            }
         if (((cmd[1] == 2) || (cmd[1] == 4)) && (arr_start_36[1] == false) && (allow_trade[1] == true))
            {
            OrderSend(CurrencyC1,OP_SELL,lots_sell[1],bid2,3,0,0,"ZeusFX-EURUSD",magic[1],0,Red);
            return(0);
            }
         cmd[2] = OrderExport02(CurrencyC1,magic[2],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[2] = OrderVolumeA02(magic[2],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[2] = OrderVolumeB02(magic[2],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[2] == 3) || (cmd[2] == 4)) && (arr_start_32[2] == false) && (allow_trade[2] == true))
            {
            OrderSend(CurrencyC1,OP_BUY,lots_buy[2],ask2,3,0,0,"ZeusFX-EURUSD",magic[2],0,Blue);
            return(0);
            }
         if (((cmd[2] == 2) || (cmd[2] == 4)) && (arr_start_36[2] == false) && (allow_trade[2] == true))
            {
            OrderSend(CurrencyC1,OP_SELL,lots_sell[2],bid2,3,0,0,"ZeusFX-EURUSD",magic[2],0,Red);
            return(0);
            }
         cmd[3] = OrderExport03(CurrencyC1,magic[3],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[3] = OrderVolumeA03(magic[3],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[3] = OrderVolumeB03(magic[3],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[3] == 3) || (cmd[3] == 4)) && (arr_start_32[3] == false) && (allow_trade[3] == true))
            {
            OrderSend(CurrencyC1,OP_BUY,lots_buy[3],ask2,3,0,0,"ZeusFX-EURUSD",magic[3],0,Blue);
            return(0);
            }
         if (((cmd[3] == 2) || (cmd[3] == 4)) && (arr_start_36[3] == false) && (allow_trade[3] == true))
            {
            OrderSend(CurrencyC1,OP_SELL,lots_sell[3],bid2,3,0,0,"ZeusFX-EURUSD",magic[3],0,Red);
            return(0);
            }
         cmd[4] = OrderExport04(CurrencyC1,magic[4],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[4] = OrderVolumeA04(magic[4],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[4] = OrderVolumeB04(magic[4],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[4] == 3) || (cmd[4] == 4)) && (arr_start_32[4] == false) && (allow_trade[4] == true))
            {
            OrderSend(CurrencyC1,OP_BUY,lots_buy[4],ask2,3,0,0,"ZeusFX-EURUSD",magic[4],0,Blue);
            return(0);
            }
         if (((cmd[4] == 2) || (cmd[4] == 4)) && (arr_start_36[4] == false) && (allow_trade[4] == true))
            {
            OrderSend(CurrencyC1,OP_SELL,lots_sell[4],bid2,3,0,0,"ZeusFX-EURUSD",magic[4],0,Red);
            return(0);
            }
         cmd[5] = OrderExport05(CurrencyC1,magic[5],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[5] = OrderVolumeA05(magic[5],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[5] = OrderVolumeB05(magic[5],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[5] == 3) || (cmd[5] == 4)) && (arr_start_32[5] == false) && (allow_trade[5] == true))
            {
            OrderSend(CurrencyC1,OP_BUY,lots_buy[5],ask2,3,0,0,"ZeusFX-EURUSD",magic[5],0,Blue);
            return(0);
            }
         if (((cmd[5] == 2) || (cmd[5] == 4)) && (arr_start_36[5] == false) && (allow_trade[5] == true))
            {
            OrderSend(CurrencyC1,OP_SELL,lots_sell[5],bid2,3,0,0,"ZeusFX-EURUSD",magic[5],0,Red);
            return(0);
            }
         cmd[6] = OrderExport06(CurrencyC1,magic[6],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[6] = OrderVolumeA06(magic[6],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[6] = OrderVolumeB06(magic[6],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[6] == 3) || (cmd[6] == 4)) && (arr_start_32[6] == false) && (allow_trade[6] == true))
            {
            OrderSend(CurrencyC1,OP_BUY,lots_buy[6],ask2,3,0,0,"ZeusFX-EURUSD",magic[6],0,Blue);
            return(0);
            }
         if (((cmd[6] == 2) || (cmd[6] == 4)) && (arr_start_36[6] == false) && (allow_trade[6] == true))
            {
            OrderSend(CurrencyC1,OP_SELL,lots_sell[6],bid2,3,0,0,"ZeusFX-EURUSD",magic[6],0,Red);
            return(0);
            }
         cmd[8] = OrderExport08(CurrencyC1,magic[8],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[8] = OrderVolumeA08(magic[8],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[8] = OrderVolumeB08(magic[8],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[8] == 3) || (cmd[8] == 4)) && (arr_start_32[8] == false) && (allow_trade[8] == true))
            {
            OrderSend(CurrencyC1,OP_BUY,lots_buy[8],ask2,3,0,0,"ZeusFX-EURUSD",magic[8],0,Blue);
            return(0);
            }
         if (((cmd[8] == 2) || (cmd[8] == 4)) && (arr_start_36[8] == false) && (allow_trade[8] == true))
            {
            OrderSend(CurrencyC1,OP_SELL,lots_sell[8],bid2,3,0,0,"ZeusFX-EURUSD",magic[8],0,Red);
            return(0);
            }
         cmd[9] = OrderExport09(CurrencyC1,magic[9],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[9] = OrderVolumeA09(magic[9],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[9] = OrderVolumeB09(magic[9],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[9] == 3) || (cmd[9] == 4)) && (arr_start_32[9] == false) && (allow_trade[9] == true))
            {
            OrderSend(CurrencyC1,OP_BUY,lots_buy[9],ask2,3,0,0,"ZeusFX-EURUSD",magic[9],0,Blue);
            return(0);
            }
         if (((cmd[9] == 2) || (cmd[9] == 4)) && (arr_start_36[9] == false) && (allow_trade[9] == true))
            {
            OrderSend(CurrencyC1,OP_SELL,lots_sell[9],bid2,3,0,0,"ZeusFX-EURUSD",magic[9],0,Red);
            return(0);
            }
         cmd[10] = OrderExport10(CurrencyC1,magic[10],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[10] = OrderVolumeA10(magic[10],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[10] = OrderVolumeB10(magic[10],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[10] == 3) || (cmd[10] == 4)) && (arr_start_32[10] == false) && (allow_trade[10] == true))
            {
            OrderSend(CurrencyC1,OP_BUY,lots_buy[10],ask2,3,0,0,"ZeusFX-EURUSD",magic[10],0,Blue);
            return(0);
            }
         if (((cmd[10] == 2) || (cmd[10] == 4)) && (arr_start_36[10] == false) && (allow_trade[10] == true))
            {
            OrderSend(CurrencyC1,OP_SELL,lots_sell[10],bid2,3,0,0,"ZeusFX-EURUSD",magic[10],0,Red);
            return(0);
            }
         cmd[11] = OrderExport11(CurrencyC1,magic[11],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[11] = OrderVolumeA11(magic[11],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[11] = OrderVolumeB11(magic[11],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[11] == 3) || (cmd[11] == 4)) && (arr_start_32[11] == false) && (allow_trade[11] == true))
            {
            OrderSend(CurrencyC1,OP_BUY,lots_buy[11],ask2,3,0,0,"ZeusFX-EURUSD",magic[11],0,Blue);
            return(0);
            }
         if (((cmd[11] == 2) || (cmd[11] == 4)) && (arr_start_36[11] == false) && (allow_trade[11] == true))
            {
            OrderSend(CurrencyC1,OP_SELL,lots_sell[11],bid2,3,0,0,"ZeusFX-EURUSD",magic[11],0,Red);
            return(0);
            }
         }
      }
   }

for (j = 1; j <= max; j++)
   {
   if ((otrail_allow[j] == true) && (buy_cnt[j] == 1))
      {
      otraila[j] = OTrailA(CurrencyC1,magic[j],spread,otrail_profit[j],otrail[j],otraila[j],Digit);
      }
   if ((otrail_allow[j] == true) && (sell_cnt[j] == 1))
      {
      otrailb[j] = OTrailB(CurrencyC1,magic[j],spread,otrail_profit[j],otrail[j],otrailb[j],Digit);
      }
   if ((strail_allow[j] == true) && (buy_cnt[j] > 1))
      {
      straila[j] = STrailA(CurrencyC1,magic[j],spread,strail_profit[j],strail[j],straila[j],Digit);
      }
   if ((strail_allow[j] == true) && (sell_cnt[j] > 1))
      {
      strailb[j] = STrailB(CurrencyC1,magic[j],spread,strail_profit[j],strail[j],strailb[j],Digit);
      }
   }
}

//+------------------------------------------------------------------+

double PointNumbersC1(int digits)
{
double result = 1;
int    i = 0;

for (i = 0; i < digits; i++) result = result / 10.0;

return(result);
}

//+------------------------------------------------------------------+

double OTrailA(string symbol, int magic, int spread, int profit, int trail, double result, int digits)
{
double ask = NormalizeDouble(MarketInfo(symbol,MODE_ASK),digits);
double bid = NormalizeDouble(MarketInfo(symbol,MODE_BID),digits);
double point = PointNumbersC1(digits);

for (int i = 0; i < OrdersTotal(); i++)
   {
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   if ((OrderMagicNumber() == magic) && (OrderType() == OP_BUY))
      {
      if (ask >= OrderOpenPrice() + (spread + profit) * point)
         {
         if (result < ask - trail * point)
            {
            result = ask - trail * point;
            }
         }
      if (ask < result + point / 2.0)
         {
         OrderClose(OrderTicket(),OrderLots(),bid,3,Yellow);
         result = 0;
         }
      }
   }

return(result);
}

//+------------------------------------------------------------------+

double OTrailB(string symbol, int magic, int spread, int profit, int trail, double result, int digits)
{
double ask = NormalizeDouble(MarketInfo(symbol,MODE_ASK),digits);
double bid = NormalizeDouble(MarketInfo(symbol,MODE_BID),digits);
double point = PointNumbersC1(digits);

for (int i = 0; i < OrdersTotal(); i++)
   {
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   if ((OrderMagicNumber() == magic) && (OrderType() == OP_SELL))
      {
      if (bid <= OrderOpenPrice() - (spread + profit) * point)
         {
         if (result > bid + trail * point)
            {
            result = bid + trail * point;
            }
         }
      if (bid > result - point / 2.0)
         {
         OrderClose(OrderTicket(),OrderLots(),ask,3,Yellow);
         result = 1000000;
         }
      }
   }

return(result);
}

//+------------------------------------------------------------------+

double STrailA(string symbol, int magic, int spread, int profit, int trail, double result, int digits)
{
double price;
double summ_pricelots;
double summlots = 0;
double ask = NormalizeDouble(MarketInfo(symbol,MODE_ASK),digits);
double bid = NormalizeDouble(MarketInfo(symbol,MODE_BID),digits);
double point = PointNumbersC1(digits);

for (int i = 0; i < OrdersTotal(); i++)
   {
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   if ((OrderMagicNumber() == magic) && (OrderType() == OP_BUY))
      {
      summ_pricelots = OrderOpenPrice() * OrderLots() + summ_pricelots;
      summlots = OrderLots() + summlots;
      }
   }

if (summlots > 0.0) price = summ_pricelots / summlots + spread * point;

if (ask >= price + profit * point)
   {
   if (result < ask - trail * point)
      {
      result = ask - trail * point;
      }
   if (ask < result + point / 2.0)
      {
      for (i = 0; i < OrdersTotal(); i++)
         {
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if ((OrderMagicNumber() == magic) && (OrderType() == OP_BUY))
            {
            OrderClose(OrderTicket(),OrderLots(),bid,3,Yellow);
            }
         }
      result = 0;
      }
   }

return(result);
}

//+------------------------------------------------------------------+

double STrailB(string symbol, int magic, int spread, int profit, int trail, double result, int digits)
{
double price;
double summ_pricelots;
double summlots = 0;
double ask = NormalizeDouble(MarketInfo(symbol,MODE_ASK),digits);
double bid = NormalizeDouble(MarketInfo(symbol,MODE_BID),digits);
double point = PointNumbersC1(digits);

for (int i = 0; i < OrdersTotal(); i++)
   {
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   if ((OrderMagicNumber() == magic) && (OrderType() == OP_SELL))
      {
      summ_pricelots = OrderOpenPrice() * OrderLots() + summ_pricelots;
      summlots = OrderLots() + summlots;
      }
   }

if (summlots > 0.0) price = summ_pricelots / summlots - spread * point;

if (bid <= price - profit * point)
   {
   if (result > bid + trail * point)
      {
      result = bid + trail * point;
      }
   if (bid > result - point / 2.0)
      {
      for (i = 0; i < OrdersTotal(); i++)
         {
         OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
         if ((OrderMagicNumber() == magic) && (OrderType() == OP_SELL))
            {
            OrderClose(OrderTicket(),OrderLots(),ask,3,Yellow);
            }
         }
      result = 1000000;
      }
   }

return(result);
}