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

#import    "ZeusFX-GBPUSD-M21.ex4"
   int OrderExport21(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA21(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB21(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-GBPUSD-M22.ex4"
   int OrderExport22(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA22(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB22(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-GBPUSD-M23.ex4"
   int OrderExport23(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA23(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB23(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-GBPUSD-M24.ex4"
   int OrderExport24(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA24(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB24(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-GBPUSD-M25.ex4"
   int OrderExport25(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA25(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB25(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-GBPUSD-M26.ex4"
   int OrderExport26(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA26(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB26(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-GBPUSD-M27.ex4"
   int OrderExport27(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA27(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB27(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-GBPUSD-M28.ex4"
   int OrderExport28(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA28(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB28(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-GBPUSD-M29.ex4"
   int OrderExport29(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA29(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB29(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-GBPUSD-M30.ex4"
   int OrderExport30(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA30(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB30(int i1, double d1, double d2, double d3, int i2, int i3);
#import    "ZeusFX-GBPUSD-M31.ex4"
   int OrderExport31(string s1, int i1, int i2, int i3, int i4, bool b1, int i5, int i6);
   double OrderVolumeA31(int i1, double d1, double d2, double d3, int i2, int i3);
   double OrderVolumeB31(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   CurrencyC2 = "GBPUSD";
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 = 96;
extern   int      Digit = 4;
extern   int      LotsDigit = 2;
string   var_212 = "Trading Configurations";
int      Channel = 200;
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_264 = "Key Scramble SC1";
string   var_272 = "02F8C241A58E00301AC73442EF00F184EEA92220301053F";
string   var_280 = "A85200274493C37D02716391F62833201C6AA37593602EF";
string   var_288 = "71C86305BFA50030260063070200C3627049C73D01E824F";
string   var_296 = "LEDHSPENABS0FHSSMDKEIAPLDJWLEQAOMNRFOSJWOHSKTVB";
string   var_304 = "J30SKDNMEPATLB`FK#KH#*MKS^L@NVHSOG%JSIHLXM#JHWI";
string   var_312 = "!)~+$*)@$*@+!^$(@_&#(!!^$(@@&!~%(%#@)#%*@$!*@(#";
string   var_320 = "BOEJA^#$)DN!(~NK#K&$KAP@HG~$K##(FOQ&LSKTZB$@)F";
string   var_328 = "hwomdjksleuewjhlsadyap@fsjk$lse0#@(!tkeyqfh~yk";
string   var_336 = "wsiWpsgK@B7Djg8#A~hkr~sdUIY~6#)ngwH4*2KW@%S5l@";
string   var_344 = "Key Scramble SC2";
string   var_352 = "02F8C241A58E00301AC73442EF00F184EEA92220301053F";
string   var_360 = "A85200274493C37D02716391F62833201C6AA37593602EF";
string   var_368 = "71C86305BFA50030260063070200C3627049C73D01E824F";
string   var_376 = "LEDHSPENABS0FHSSMDKEIAPLDJWLEQAOMNRFOSJWOHSKTVB";
string   var_384 = "J30SKDNMEPATLB`FK#KH#*MKS^L@NVHSOG%JSIHLXM#JHWI";
string   var_392 = "!)~+$*)@$*@+!^$(@_&#(!!^$(@@&!~%(%#@)#%*@$!*@(#";
string   var_400 = "BOEJA^#$)DN!(~NK#K&$KAP@HG~$K##(FOQ&LSKTZB$@)F";
string   var_408 = "hwomdjksleuewjhlsadyap@fsjk$lse0#@(!tkeyqfh~yk";
string   var_416 = "wsiWpsgK@B7Djg8#A~hkr~sdUIY~6#)ngwH4*2KW@%S5l@";
string   var_424 = "...................../??/)";
string   var_432 = "...................,/?../";
string   var_440 = "................../..../";
string   var_448 = "............./??/'...'/???`??";
string   var_456 = "........../'/.../..../......./??\.";
string   var_464 = "........('(...?...?.... ?~/'...')";
string   var_472 = ".........\.................'...../";
string   var_480 = "..........''...\.......... _.??";
string   var_488 = "............\..............(";
string   var_496 = "..............\.............\...";
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 = 32;
int    spread = MarketInfo(CurrencyC2,MODE_SPREAD);
int    var_start_8;
int    var_start_12 = 0;
int    expired = 0;
double point = PointNumbersC2(Digit);
bool   allow_trade[32];
bool   arr_start_32[32];
bool   arr_start_36[32];
bool   strail_allow[32];
bool   otrail_allow[32];
int    cmd[32];
int    magic[32];
int    buy_cnt[32];
int    sell_cnt[32];
int    strail_profit[32];
int    strail[32];
int    otrail_profit[32];
int    otrail[32];
double buy_top_price[32];
double buy_bot_price[32];
double sell_top_price[32];
double sell_bot_price[32];
double buy_openprice[32];
double sell_openprice[32];
double lots_buy[32];
double lots_sell[32];
double otraila[32];
double otrailb[32];
double straila[32];
double strailb[32];
int    buy_opentime[32];
int    sell_opentime[32];
double ask = NormalizeDouble(MarketInfo(CurrencyC2,MODE_ASK),Digit);
double bid = NormalizeDouble(MarketInfo(CurrencyC2,MODE_BID),Digit);

for (int j = 21; 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[21] = 212121;
magic[22] = 222222;
magic[23] = 232323;
magic[24] = 242424;
magic[25] = 252525;
magic[26] = 262626;
magic[27] = 272727;
magic[28] = 282828;
magic[29] = 292929;
magic[30] = 303030;
magic[31] = 313131;

allow_trade[21] = true;
allow_trade[22] = true;
allow_trade[23] = true;
allow_trade[24] = true;
allow_trade[25] = true;
allow_trade[26] = true;
allow_trade[27] = true;
allow_trade[28] = true;
allow_trade[29] = true;
allow_trade[30] = true;
allow_trade[31] = true;

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

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

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

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

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

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

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

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

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

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

strail_allow[31] = true;
strail_profit[31] = 9;
strail[31] = 3;
otrail_allow[31] = true;
otrail_profit[31] = 9;
otrail[31] = 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 = 21; 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 = 21; 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 = 21; 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 = 21; j <= max; j++)
   {
   if ((ask >= buy_bot_price[j]) && (ask <= buy_top_price[j]))
      {
      for (int l = 21; l <= max; l++)
         {
         if (buy_cnt[l] == 0) arr_start_32[l] = true;
         }
      }
   if ((bid <= sell_top_price[j]) && (bid >= sell_bot_price[j]))
      {
      for (l = 21; l <= max; l++)
         {
         if (sell_cnt[l] == 0) arr_start_36[l] = true;
         }
      }
   }

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

double high_m5 = iHigh(CurrencyC2,PERIOD_M5,0);
double low_m5 = iLow(CurrencyC2,PERIOD_M5,0);

if (((Hour1 < Hour2) && (hour >= Hour1) && (hour < Hour2)) || ((Hour1 > Hour2) && ((hour >= Hour1) || (hour < Hour2))))
   {
   if (expired == 0)
      {
      if (high_m5 == low_m5)
         {
         cmd[21] = OrderExport21(CurrencyC2,magic[21],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[21] = OrderVolumeA21(magic[21],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[21] = OrderVolumeB21(magic[21],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[21] == 3) || (cmd[21] == 4)) && (arr_start_32[21] == 0) && (allow_trade[21] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[21],ask,3,0,0,"ZeusFX-GBPUSD",magic[21],0,Blue);
            return(0);
            }
         if (((cmd[21] == 2) || (cmd[21] == 4)) && (arr_start_36[21] == 0) && (allow_trade[21] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[21],bid,3,0,0,"ZeusFX-GBPUSD",magic[21],0,Red);
            return(0);
            }
         cmd[22] = OrderExport22(CurrencyC2,magic[22],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[22] = OrderVolumeA22(magic[22],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[22] = OrderVolumeB22(magic[22],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[22] == 3) || (cmd[22] == 4)) && (arr_start_32[22] == 0) && (allow_trade[22] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[22],ask,3,0,0,"ZeusFX-GBPUSD",magic[22],0,Blue);
            return(0);
            }
         if (((cmd[22] == 2) || (cmd[22] == 4)) && (arr_start_36[22] == 0) && (allow_trade[22] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[22],bid,3,0,0,"ZeusFX-GBPUSD",magic[22],0,Red);
            return(0);
            }
         cmd[23] = OrderExport23(CurrencyC2,magic[23],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[23] = OrderVolumeA23(magic[23],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[23] = OrderVolumeB23(magic[23],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[23] == 3) || (cmd[23] == 4)) && (arr_start_32[23] == 0) && (allow_trade[23] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[23],ask,3,0,0,"ZeusFX-GBPUSD",magic[23],0,Blue);
            return(0);
            }
         if (((cmd[23] == 2) || (cmd[23] == 4)) && (arr_start_36[23] == 0) && (allow_trade[23] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[23],bid,3,0,0,"ZeusFX-GBPUSD",magic[23],0,Red);
            return(0);
            }
         cmd[24] = OrderExport24(CurrencyC2,magic[24],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[24] = OrderVolumeA24(magic[24],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[24] = OrderVolumeB24(magic[24],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[24] == 3) || (cmd[24] == 4)) && (arr_start_32[24] == 0) && (allow_trade[24] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[24],ask,3,0,0,"ZeusFX-GBPUSD",magic[24],0,Blue);
            return(0);
            }
         if (((cmd[24] == 2) || (cmd[24] == 4)) && (arr_start_36[24] == 0) && (allow_trade[24] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[24],bid,3,0,0,"ZeusFX-GBPUSD",magic[24],0,Red);
            return(0);
            }
         cmd[25] = OrderExport25(CurrencyC2,magic[25],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[25] = OrderVolumeA25(magic[25],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[25] = OrderVolumeB25(magic[25],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[25] == 3) || (cmd[25] == 4)) && (arr_start_32[25] == 0) && (allow_trade[25] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[25],ask,3,0,0,"ZeusFX-GBPUSD",magic[25],0,Blue);
            return(0);
            }
         if (((cmd[25] == 2) || (cmd[25] == 4)) && (arr_start_36[25] == 0) && (allow_trade[25] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[25],bid,3,0,0,"ZeusFX-GBPUSD",magic[25],0,Red);
            return(0);
            }
         cmd[26] = OrderExport26(CurrencyC2,magic[26],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[26] = OrderVolumeA26(magic[26],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[26] = OrderVolumeB26(magic[26],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[26] == 3) || (cmd[26] == 4)) && (arr_start_32[26] == 0) && (allow_trade[26] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[26],ask,3,0,0,"ZeusFX-GBPUSD",magic[26],0,Blue);
            return(0);
            }
         if (((cmd[26] == 2) || (cmd[26] == 4)) && (arr_start_36[26] == 0) && (allow_trade[26] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[26],bid,3,0,0,"ZeusFX-GBPUSD",magic[26],0,Red);
            return(0);
            }
         cmd[27] = OrderExport27(CurrencyC2,magic[27],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[27] = OrderVolumeA27(magic[27],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[27] = OrderVolumeB27(magic[27],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[27] == 3) || (cmd[27] == 4)) && (arr_start_32[27] == 0) && (allow_trade[27] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[27],ask,3,0,0,"ZeusFX-GBPUSD",magic[27],0,Blue);
            return(0);
            }
         if (((cmd[27] == 2) || (cmd[27] == 4)) && (arr_start_36[27] == 0) && (allow_trade[27] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[27],bid,3,0,0,"ZeusFX-GBPUSD",magic[27],0,Red);
            return(0);
            }
         cmd[28] = OrderExport28(CurrencyC2,magic[28],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[28] = OrderVolumeA28(magic[28],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[28] = OrderVolumeB28(magic[28],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[28] == 3) || (cmd[28] == 4)) && (arr_start_32[28] == 0) && (allow_trade[28] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[28],ask,3,0,0,"ZeusFX-GBPUSD",magic[28],0,Blue);
            return(0);
            }
         if (((cmd[28] == 2) || (cmd[28] == 4)) && (arr_start_36[28] == 0) && (allow_trade[28] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[28],bid,3,0,0,"ZeusFX-GBPUSD",magic[28],0,Red);
            return(0);
            }
         cmd[29] = OrderExport29(CurrencyC2,magic[29],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[29] = OrderVolumeA29(magic[29],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[29] = OrderVolumeB29(magic[29],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[29] == 3) || (cmd[29] == 4)) && (arr_start_32[29] == 0) && (allow_trade[29] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[29],ask,3,0,0,"ZeusFX-GBPUSD",magic[29],0,Blue);
            return(0);
            }
         if (((cmd[29] == 2) || (cmd[29] == 4)) && (arr_start_36[29] == 0) && (allow_trade[29] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[29],bid,3,0,0,"ZeusFX-GBPUSD",magic[29],0,Red);
            return(0);
            }
         cmd[30] = OrderExport30(CurrencyC2,magic[30],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[30] = OrderVolumeA30(magic[30],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[30] = OrderVolumeB30(magic[30],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[30] == 3) || (cmd[30] == 4)) && (arr_start_32[30] == 0) && (allow_trade[30] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[30],ask,3,0,0,"ZeusFX-GBPUSD",magic[30],0,Blue);
            return(0);
            }
         if (((cmd[30] == 2) || (cmd[30] == 4)) && (arr_start_36[30] == 0) && (allow_trade[30] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[30],bid,3,0,0,"ZeusFX-GBPUSD",magic[30],0,Red);
            return(0);
            }
         cmd[31] = OrderExport31(CurrencyC2,magic[31],MondayStart,FridayEndHour,BrokerGMT,AntiFullMargin,MaxMargin,Digit);
         lots_buy[31] = OrderVolumeA31(magic[31],var_164,Risk,var_188,LotsDigit,Digit);
         lots_sell[31] = OrderVolumeB31(magic[31],var_164,Risk,var_188,LotsDigit,Digit);
         if (((cmd[31] == 3) || (cmd[31] == 4)) && (arr_start_32[31] == 0) && (allow_trade[31] == 1))
            {
            OrderSend(CurrencyC2,OP_BUY,lots_buy[31],ask,3,0,0,"ZeusFX-GBPUSD",magic[31],0,Blue);
            return(0);
            }
         if (((cmd[31] == 2) || (cmd[31] == 4)) && (arr_start_36[31] == 0) && (allow_trade[31] == 1))
            {
            OrderSend(CurrencyC2,OP_SELL,lots_sell[31],bid,3,0,0,"ZeusFX-GBPUSD",magic[31],0,Red);
            return(0);
            }
         }
      }
   }

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

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

double PointNumbersC2(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 = PointNumbersC2(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 = PointNumbersC2(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 = PointNumbersC2(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 = PointNumbersC2(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);
}