Gap_Expert_v01_1

Author: Inkov Evgeni
Price Data Components
Series array that contains close prices for each barSeries array that contains the highest prices of each bar
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyChecks for the total of closed ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites
Gap_Expert_v01_1
ÿþ//+------------------------------------------------------------------+

//|                                             Gap_Expert_v01_1.mq4 |

//|  =0G. 16/10/2017   @5;87 >B 16/10/2017  ?>A;.87<. 16/10/2017     |

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

#property copyright "Inkov Evgeni"

#property link      "ew123@mail.ru"

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

#property version   "1.00"

#property strict

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

// 8I5BAO D;5B >B 2-3> 10@0 4;8=>9 kol_flat_bar

// A;8 =0 ?5@2>< 10@5 8 40;55 5ABL 10@K 2 >4=C AB>@>=C (-) @07<5@>< 1>;LH5< D;5B0 2 Koef_Gap @07,

//   B> =0 0 10@5 >B:@K205BAO @525@A=K9 >@45@ A> AB>?-;>AA>< =0 D;5B+Otstup_SL

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

input bool       Trade                = true;

input bool       UP                   = true;

input bool       DW                   = true;

input string     s1_______________    = "------------------------------------";

                                                  // 5A;8 = 0, AG8B05< ;>B >B Proc_Lot

input double     Lots                 = 0;

                                             // ?@>F5=B >B 10;0=A0 4;O @0AG5B0 =0G. ;>B0

input double     Proc_Lot             = 10;

input string     s2_______________    = "------------------------------------";

input ENUM_TIMEFRAMES TF1             = PERIOD_M1;

input ENUM_TIMEFRAMES TF2             = PERIOD_M5;

input bool       On_TF2               = true;

                                                // :>;. 10@ D;5B0

input int        kol_flat_bar1        = 1;

                                                // @07<5@ 10@0 -0 >B=>AB5;L=> @07<5@0 D;5B0

input double     Koef_Gap1            = 2.5;

                                                // :>;. 10@ D;5B0

input int        kol_flat_bar2        = 5;

                                                // @07<5@ 10@0 -0 >B=>AB5;L=> @07<5@0 D;5B0

input double     Koef_Gap2            = 1.8;

input string     s3_______________    = "------------------------------------";

                                                // :>MD." >B @07<5@0 -0

input double     Koef_TP              = 4.3;

                                                // >BABC? 4;O CAB. SL

input int        Otstup_SL            = 130;

input string     s4_______________    = "------------------------------------";

input int        Magic                = 142389;

input int        Slippage             = 50;

input bool       Sound                = true;

//-------------------------------------------------------

bool   Risk_from_Balance    = true;// true - AG8B05< @8A: >B 10;0=A0, false - >B A2>1.A@54AB2

double lot;

double min_l, max_l;

int    dig_lot;

double n_lot;

double poi;

string com_err="";



int    mas_ord[6];

int    kol_ord, kol_ord_pred;

string pref="GE_";

string Glob_SL;

string Glob_TP;

string ss1,ss2;

bool   out_obj;

bool   ust_sl;

bool   ust_tp;

double profit=0;

//========================================

int OnInit()

{

   min_l=MarketInfo(Symbol(),MODE_MINLOT);

   max_l=MarketInfo(Symbol(),MODE_MAXLOT);

   //.............................................

   n_lot=MarketInfo(Symbol(),MODE_LOTSTEP);

   dig_lot=(int)NormalizeDouble(MathLog(1.0/n_lot)/MathLog(10.0),0);

   //.............................................

   poi=MarketInfo(Symbol(),MODE_POINT);

   if (poi==0)poi=1;

   //.............................................

   out_obj=true;

   if (IsTesting() && !IsVisualMode())out_obj=false;

   //.....................................................

   Glob_SL=pref+IntegerToString(IsTesting())+"_"+Symbol()+"_"+TimeFrameToString(TF1)+"_SL";

   Glob_TP=pref+IntegerToString(IsTesting())+"_"+Symbol()+"_"+TimeFrameToString(TF1)+"_TP";

   if (!GlobalVariableCheck(Glob_SL))GlobalVariableSet(Glob_SL,-1);

   if (!GlobalVariableCheck(Glob_TP))GlobalVariableSet(Glob_TP,-1);

   //.....................................................

   kol_ord_pred=-1;

   ust_sl=true;

   ust_tp=true;

   //.............................................

   OnTick();

   //.............................

   return(INIT_SUCCEEDED);

}

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

void OnDeinit(const int reason)

{

}

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

double OnTester()

{

   double n1=TesterStatistics(STAT_PROFIT);

   double n2=TesterStatistics(STAT_EQUITY_DD);

   double n3=1;

//   n3=MathLog10(TesterStatistics(STAT_TRADES));

   double n=0;

   if (n2!=0)n=n1/n2*n3;

   return(n);

}

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

void OnTick()

{

   if (Bid==0)return;

   //........................................

   com_err="";  // >1=C;8BL AB@>:C :><<5=B0@8O >H81>: >B:@KB8O >@45@>2

   //........................................

   lot=opred_lot();

   //........................................

   Orders_Total();

   //........................................

   double sl=0;

   double tp=0;

   int usl2=0;

   if (On_TF2)usl2=usl_open_ord(TF2,kol_flat_bar2,Koef_Gap2,sl,tp,ss2);

   int us1l = usl_open_ord(TF1,kol_flat_bar1,Koef_Gap1,sl,tp,ss1);

   //........................................

   if (out_obj)

      Comment("UP= ",(UP?"Yes":"NO"),"   DW= ",(DW?"Yes":"NO"),(Trade?"":"   ">@3>2;O 70:@KB0 !")+"\n",

              "LOT = ",DoubleToStr(lot,2), (Lots==0?"  ( "+DoubleToStr(Proc_Lot,2)+"% )":"")+"\n"+

              "TF1= ",TimeFrameToString(TF1)+": "+ss1+"\n"

              "TF2= ",TimeFrameToString(TF2)+": "+(On_TF2?ss2:"NO"));

   //........................................

   if (kol_ord==0)

      if(Trade)

         if (UP && us1l>0 && (!On_TF2 || usl2>0))

         {

            double sl_end_ord=-1;

            bool prof_plus=Profit_end_plus_Hist(OP_BUY,sl_end_ord);

            if (!prof_plus || (prof_plus && ND(sl_end_ord)!=ND(sl)))

            {

               if (Open_Buy())

               {

                  ust_sl=true;

                  ust_tp=true;

                  GlobalVariableSet(Glob_SL,sl);

                  GlobalVariableSet(Glob_TP,tp);

               }

            }

         }

         else

            if (DW && us1l<0 && (!On_TF2 || usl2<0))

            {

               double sl_end_ord=-1;

               bool prof_plus=Profit_end_plus_Hist(OP_SELL,sl_end_ord);

               if (!prof_plus || (prof_plus && ND(sl_end_ord)!=ND(sl)))

               {

                  if (Open_Sell())

                  {

                     ust_sl=true;

                     GlobalVariableSet(Glob_SL,sl);

                     GlobalVariableSet(Glob_TP,tp);

                  }

               }

            }

   //........................................

   if (ust_sl || ust_tp)ust_SL_TP();

   //........................................

   if (out_obj)

      if (com_err!="")Comment(com_err);

} 

//=========================================================

int usl_open_ord(int TF, int kol_flat_bar, double Koef_Gap,double& sl,double& tp, string& ss)

{

      // =09B8 ?5@2K9 =5 =C;52>9 10@

   ss="";

   double OC;

   int n_beg=0;

   do

   {

      n_beg++;

      OC=iClose(NULL,TF,n_beg)-iClose(NULL,TF,n_beg+1);

   }

   while(ND(OC)==0 && n_beg<iBars(NULL,TF)-2);

   //................................

         // =09B8 =0G0;> ?;NH:8

   int N;

   for(N=n_beg+1;N<iBars(NULL,TF)-kol_flat_bar-2;N++)

   {

      double OC_N=iClose(NULL,TF,N)-iClose(NULL,TF,N+1);

      if ((ND(OC)>0 && ND(OC_N)<0) || (ND(OC)<0 && ND(OC_N)>0))break;

   }

   //........................

            // >F5=8BL @07<5@ ?;NH:8 8 =09B8 <0:A. 8 <8=. 4;O CAB.",!

   int out=0;

   double hi_pred_bar;

   double lo_pred_bar;

   sl=0;

   tp=0;

   

   double HL=Find_hl_pred_bar(TF,kol_flat_bar,N+1,hi_pred_bar,lo_pred_bar); // =09B8 A@54=55 7=0G5=85 10@>2 >B 10@ N 8 40;55 =0704

   double OC_1=iClose(NULL,TF,1)-iClose(NULL,TF,N+1);

   if (ND(HL)==0)HL=Point;

   double K= OC_1/HL;

   

   if (kol_ord==0)

      if (K>0) // 1KG89 10@, CAB.Sell

      {

            if (NormalizeDouble(K,2)>=NormalizeDouble(Koef_Gap,2))

            {

               sl=hi_pred_bar;

               tp=iClose(NULL,TF,1)-(iClose(NULL,TF,1)-lo_pred_bar)*Koef_TP;

               out=-1;

            }

      }

      else

         if (K<0) // <542.10@, CAB.Buy

            if (NormalizeDouble(-K,2)>=NormalizeDouble(Koef_Gap,2))

            {

               sl=lo_pred_bar;

               tp=iClose(NULL,TF,1)+(hi_pred_bar-iClose(NULL,TF,1))*Koef_TP;

               out=1;

            }

         

   if (out_obj)

      ss="K= "+DoubleToStr(K,2)+" / "+DoubleToStr(Koef_Gap,2)+"  Open order= "+(out==0?"NO":(out==1?"BUY":"SELL"));

         

   return(out);

}

//------------------------------------

double Find_hl_pred_bar(int TF,int kol_flat_bar, int N,double& max_hl,double& min_lo)

{  // =0 =09B8 @07<0E 10@>2 ?;NH:8

   double lo=0,hi=0;

   max_hl=0;

   min_lo=0;

   

   for(int i=0;i<kol_flat_bar;i++)

   {

      lo=iLow (NULL,TF,i+N);

      hi=iHigh(NULL,TF,i+N);

      if (max_hl==0 || ND(hi)>ND(max_hl))max_hl=hi;

      if (min_lo==0 || ND(lo)<ND(min_lo))min_lo=lo;

   }

   double hl=ND(max_hl-min_lo);

   //.......................................

   for(int i=1;i<N;i++)

   {

      lo=iLow (NULL,TF,i);

      hi=iHigh(NULL,TF,i);

      if (max_hl==0 || ND(hi)>ND(max_hl))max_hl=hi;

      if (min_lo==0 || ND(lo)<ND(min_lo))min_lo=lo;

   }

   

   return(hl);

}

//----------------------------

void ust_SL_TP()

{

   double sl_Buy =0;

   double sl_Sell=0;

   

   int stop_level=(int)MarketInfo(Symbol(),MODE_STOPLEVEL);

   double tp_Glob=GlobalVariableGet(Glob_TP);

   double sl_Glob=GlobalVariableGet(Glob_SL);

   if (sl_Glob>0)

   {

      sl_Buy =sl_Glob-Otstup_SL*poi;

      sl_Sell=sl_Glob+Otstup_SL*poi;

   }

   //..........................................

   for (int i=OrdersTotal()-1;i>=0;i--)

   {

      if (!Good_ord(i,MODE_TRADES))continue;

      

      if (OrderType()==OP_BUY)

      {

         if (ND(sl_Buy)>0)

         {

            RefreshRates();

            double sl=sl_Buy;

            if (ND(sl_Buy)>ND(Bid-stop_level*poi))sl=Bid-stop_level*poi;

            if (OrderStopLoss()==0 || ND(sl)>ND(OrderStopLoss()))

            {

               bool M=OrderModify(OrderTicket(),OrderOpenPrice(),ND(sl),OrderTakeProfit(),0,clrBlue);

               ust_sl=!(ND(OrderStopLoss())==ND(sl_Glob-Otstup_SL*poi));

            }

         }

         if (ND(tp_Glob)>0)

            if (ND(tp_Glob)!=ND(OrderTakeProfit()))

            {

               bool M=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),ND(tp_Glob),0,clrBlue);

               ust_tp=!(ND(OrderTakeProfit())==ND(tp_Glob));

            }

      }

            

      if (OrderType()==OP_SELL)

      {

         if (ND(sl_Sell)>0)

         {

            RefreshRates();

            double sl=sl_Sell;

            if (ND(sl_Sell)<ND(Ask+stop_level*poi))sl=Ask+stop_level*poi;

            if (OrderStopLoss()==0 || ND(sl)<ND(OrderStopLoss()))

            {

               bool M=OrderModify(OrderTicket(),OrderOpenPrice(),ND(sl),OrderTakeProfit(),0,clrRed);

               ust_sl=!(ND(OrderStopLoss())==ND(sl_Glob+Otstup_SL*poi));

            }

         }

         if (ND(tp_Glob)>0)

            if (ND(tp_Glob)!=ND(OrderTakeProfit()))

            {

               bool M=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),ND(tp_Glob),0,clrRed);

               ust_tp=!(ND(OrderTakeProfit())==ND(tp_Glob));

            }

      }

   }

}

//---------------------------

bool Profit_end_plus_Hist(int tip, double& sl)

{  // 5A;8 =0 =C;52>< 10@5 1K; >@45@ A ?;NA><, B> 2KE true

   bool out=false;

   sl=-1;

   

   for (int i=OrdersHistoryTotal()-1;i>=0;i--)

   {

      if (!Good_ord(i,MODE_HISTORY))continue;

      

      if (OrderType()==tip)

         if (OrderProfit()>0)

         {

            sl=OrderStopLoss();

            out=true;

         }

      break;

   }

   return(out);

}

//---------------------------------

double opred_lot()

{

   double L=0;

   if (Lots>0)     // >?@545;8BLAO A =0G0;L=K< ;>B><

      L=Ogran_min_lot(Lots);

   else

      L=Ogran_min_lot(GetLot(Proc_Lot));

   return(L);

}

//-------------------------------

double GetLot(double proc)

{

   double free_magrin;

   

   if (Risk_from_Balance)

      free_magrin = AccountBalance();

   else

      free_magrin = AccountFreeMargin();



   double lot1 = NormalizeDouble(free_magrin * proc/100000.0,dig_lot);

   

   return (lot1);

}

//---------------------------------------------------------------

double Ogran_min_lot(double lot1)

{

   if (lot1 < min_l)lot1 = min_l;

   return(lot1);

}

//---------------------------------------------------------------

double Ogran_max_lot(double lot1)

{

   if (lot1 > max_l)lot1 = max_l;

   return(lot1);

}

//---------------------------------------------------------------

void Orders_Total()

{

   ArrayInitialize(mas_ord,0);

   kol_ord=0;

   profit=0;

   

   for (int i=0;i<OrdersTotal();i++)

   {

      if (!Good_ord(i,MODE_TRADES))continue;

      

      mas_ord[OrderType()]++;

      kol_ord++;

      profit+=OrderProfit()+OrderSwap()+OrderCommission();

   }

   //.....................................

   if (kol_ord_pred>0 && kol_ord_pred!=kol_ord) 

      if (Sound)PlaySound("connect.wav");

      

   kol_ord_pred=kol_ord;

   

   if (kol_ord==0) kol_ord_pred=-1;

}

//---------------------------------------------------------------

bool Good_ord(int i, int mode)

{

   if (!OrderSelect(i,SELECT_BY_POS,mode))return(0);

   if (OrderSymbol()!=Symbol())return(0);

   if (OrderMagicNumber()==Magic)return(1);

   if (OrderMagicNumber()==0)return(1);

   

   return(0);

}

//---------------------------------------------------------------

double ND(double n)

{

   return(NormalizeDouble(n,Digits));

}

//---------------------------------------------------------------

double ND2(double n)

{

   return(NormalizeDouble(n,2));

}

//---------------------------------------------------------------

double NDL(double n)

{

   return(MathRound(n/n_lot)*n_lot);

}

//---------------------------------------------------------------

bool Open_Buy()

{

   int tik=ust_order(Symbol(), OP_BUY, lot, ND(Ask), Slippage, 0, 0, "", Magic, clrBlue);

   

   return(tik>0);

}

//-------------------------------------------

bool Open_Sell()

{

   int tik=ust_order(Symbol(), OP_SELL, lot, ND(Bid), Slippage, 0, 0, "", Magic, clrRed);



   return(tik>0);

}

//-------------------------------------------

int ust_order(string sym,int Tip, double lot1, double pr, int slippage, double sl, double tp, string com2, int mag, color col=clrNONE, int dt=0)

{

   double tek_lot;

   double ust_lot=lot1;

   int tik=0;

   while (ust_lot>0)

   {

      tek_lot=Ogran_max_lot(ust_lot);

      tik = OrderSend(sym, Tip, tek_lot, pr, slippage, sl, tp, com2, mag, dt, col);

      if (tik<0)break;

      ust_lot-=tek_lot;

   }

   if (tik<0)IsError(tip_str(Tip)+": pr="+DoubleToStr(pr,Digits)+" sl="+DoubleToStr(sl,Digits)+" tp="+DoubleToStr(tp,Digits));



   return(tik);

}

//-----------------------------------------------

string tip_str (int tip)

{

   switch(tip)

   {

      case 0: return("Buy");

      case 1: return("Sell");

      case 2: return("BuyLimit");

      case 3: return("SellLimit");

      case 4: return("BuyStop");

      case 5: return("SellStop");

   }

   return("?");

}

//-----------------------------------------------

int IsError(string Whose)  

{

   int ierr = GetLastError(); 

   

   bool result = (ierr > 1);

   if(result)com_err=com_err+Whose+ " error = "+ IntegerToString(ierr)+ "; desc = "+ error(ierr)+"\n";

      

   return(ierr);

}

//-----------------------------------------------

string error(int eer)

{

   string er;

   switch(eer)

   {

      case 0:   break;

      case 1:   er="5B >H81:8, => @57C;LB0B =58725AB5=";                         break;

      case 2:   er="1I0O >H81:0";                                                break;

      case 3:   er="5?@028;L=K5 ?0@0<5B@K";                                      break;

      case 4:   er="">@3>2K9 A5@25@ 70=OB";                                       break;

      case 5:   er="!B0@0O 25@A8O :;85=BA:>3> B5@<8=0;0";                         break;

      case 6:   er="5B A2O78 A B>@3>2K< A5@25@><";                               break;

      case 7:   er="54>AB0B>G=> ?@02";                                           break;

      case 8:   er="!;8H:>< G0ABK5 70?@>AK";                                      break;

      case 9:   er="54>?CAB8<0O >?5@0F8O =0@CH0NI0O DC=:F8>=8@>20=85 A5@25@0";   break;

      case 64:  er="!G5B 701;>:8@>20=";                                           break;

      case 65:  er="5?@028;L=K9 =><5@ AG5B0";                                    break;

      case 128: er="AB5: A@>: >6840=8O A>25@H5=8O A45;:8";                       break;

      case 129: er="5?@028;L=0O F5=0";                                           break;

      case 130: er="5?@028;L=K5 AB>?K";                                          break;

      case 131: er="5?@028;L=K9 >1J5<";                                          break;

      case 132: er=" K=>: 70:@KB";                                                break;

      case 133: er="">@3>2;O 70?@5I5=0";                                          break;

      case 134: er="54>AB0B>G=> 45=53 4;O A>25@H5=8O >?5@0F88";                  break;

      case 135: er="&5=0 87<5=8;0AL";                                             break;

      case 136: er="5B F5=";                                                     break;

      case 137: er="@>:5@ 70=OB";                                                break;

      case 138: er=">2K5 F5=K -  5:2>B";                                         break;

      case 139: er="@45@ 701;>:8@>20= 8 C65 >1@010BK205BAO";                     break;

      case 140: er=" 07@5H5=0 B>;L:> ?>:C?:0";                                    break;

      case 141: er="!;8H:>< <=>3> 70?@>A>2";                                      break;

      case 145: er=">48D8:0F8O 70?@5I5=0, B0: :0: >@45@ A;8H:>< 1;87>: : @K=:C"; break;

      case 146: er=">4A8AB5<0 B>@3>2;8 70=OB0";                                  break;

      case 147: er="A?>;L7>20=85 40BK 8AB5G5=8O >@45@0 70?@5I5=> 1@>:5@><";      break;

      case 148: er=">;8G5AB2> >B:@KBKE 8 >B;>65==KE >@45@>2 4>AB83;> ?@545;0 ";  break;

      //---- 

      case 4000: er="5B >H81:8";                                                 break;

      case 4001: er="5?@028;L=K9 C:070B5;L DC=:F88";                             break;

      case 4002: er="=45:A <0AA820 - 2=5 480?07>=0";                             break;

      case 4003: er="5B ?0<OB8 4;O AB5:0 DC=:F89";                               break;

      case 4004: er="5@5?>;=5=85 AB5:0 ?>A;5 @5:C@A82=>3> 2K7>20";               break;

      case 4005: er="0 AB5:5 =5B ?0<OB8 4;O ?5@540G8 ?0@0<5B@>2";                break;

      case 4006: er="5B ?0<OB8 4;O AB@>:>2>3> ?0@0<5B@0";                        break;

      case 4007: er="5B ?0<OB8 4;O 2@5<5==>9 AB@>:8";                            break;

      case 4008: er="58=8F80;878@>20==0O AB@>:0";                                break;

      case 4009: er="58=8F80;878@>20==0O AB@>:0 2 <0AA825";                      break;

      case 4010: er="5B ?0<OB8 4;O AB@>:>2>3> <0AA820";                          break;

      case 4011: er="!;8H:>< 4;8==0O AB@>:0";                                     break;

      case 4012: er="AB0B>: >B 45;5=8O =0 =>;L";                                 break;

      case 4013: er="5;5=85 =0 =>;L";                                            break;

      case 4014: er="58725AB=0O :><0=40";                                        break;

      case 4015: er="5?@028;L=K9 ?5@5E>4";                                       break;

      case 4016: er="58=8F80;878@>20==K9 <0AA82";                                break;

      case 4017: er="K7>2K DLL =5 @07@5H5=K";                                    break;

      case 4018: er="52>7<>6=> 703@C78BL 181;8>B5:C";                            break;

      case 4019: er="52>7<>6=> 2K720BL DC=:F8N";                                 break;

      case 4020: er="eK7>2K 2=5H=8E 181;8>B5G=KE DC=:F89 =5 @07@5H5=K";          break;

      case 4021: er="54>AB0B>G=> ?0<OB8 4;O AB@>:8, 2>72@0I05<>9 87 DC=:F88";    break;

      case 4022: er="!8AB5<0 70=OB0";                                             break;

      case 4050: er="5?@028;L=>5 :>;8G5AB2> ?0@0<5B@>2 DC=:F88";                 break;

      case 4051: er="54>?CAB8<>5 7=0G5=85 ?0@0<5B@0 DC=:F88";                    break;

      case 4052: er="=CB@5==OO >H81:0 AB@>:>2>9 DC=:F88";                        break;

      case 4053: er="H81:0 <0AA820";                                             break;

      case 4054: er="5?@028;L=>5 8A?>;L7>20=85 <0AA820-B09<A5@88";               break;

      case 4055: er="H81:0 ?>;L7>20B5;LA:>3> 8=48:0B>@0";                        break;

      case 4056: er="0AA82K =5A>2<5AB8<K";                                       break;

      case 4057: er="H81:0 >1@01>B:8 3;>10;L=K5E ?5@5<Ë%5==KE";                    break;

      case 4058: er=";>10;L=0O ?5@5<5==0O =5 >1=0@C65=0";                        break;

      case 4059: er="$C=:F8O =5 @07@5H5=0 2 B5AB>2>< @568<5";                     break;

      case 4060: er="$C=:F8O =5 ?>4B25@645=0";                                    break;

      case 4061: er="H81:0 >B?@02:8 ?>GBK";                                      break;

      case 4062: er="68405BAO ?0@0<5B@ B8?0 string";                             break;

      case 4063: er="68405BAO ?0@0<5B@ B8?0 integer";                            break;

      case 4064: er="68405BAO ?0@0<5B@ B8?0 double";                             break;

      case 4065: er=" :0G5AB25 ?0@0<5B@0 >68405BAO <0AA82";                      break;

      case 4066: er="0?@>H5==K5 8AB>@8G5A:85 40==K5 2 A>AB>O=88 >1=>2;5=8O";     break;

      case 4067: er="H81:0 ?@8 2K?>;=5=88 B>@3>2>9 >?5@0F88";                    break;

      case 4099: er=">=5F D09;0";                                                break;

      case 4100: er="H81:0 ?@8 @01>B5 A D09;><";                                 break;

      case 4101: er="5?@028;L=>5 8<O D09;0";                                     break;

      case 4102: er="!;8H:>< <=>3> >B:@KBKE D09;>2";                              break;

      case 4103: er="52>7<>6=> >B:@KBL D09;";                                    break;

      case 4104: er="5A>2<5AB8<K9 @568< 4>ABC?0 : D09;C";                        break;

      case 4105: er="8 >48= >@45@ =5 2K1@0=";                                    break;

      case 4106: er="58725AB=K9 A8<2>;";                                         break;

      case 4107: er="5?@028;L=K9 ?0@0<5B@ F5=K 4;O B>@3>2>9 DC=:F88";            break;

      case 4108: er="525@=K9 =><5@ B8:5B0";                                      break;

      case 4109: er="">@3>2;O =5 @07@5H5=0";                                      break;

      case 4110: er=";8==K5 ?>78F88 =5 @07@5H5=K";                               break;

      case 4111: er=">@>B:85 ?>78F88 =5 @07@5H5=K";                              break;

      case 4200: er="1J5:B C65 ACI5AB2C5B";                                      break;

      case 4201: er="0?@>H5=> =58725AB=>5 A2>9AB2> >1J5:B0";                     break;

      case 4202: er="1J5:B =5 ACI5AB2C5B";                                       break;

      case 4203: er="58725AB=K9 B8? >1J5:B0";                                    break;

      case 4204: er="5B 8<5=8 >1J5:B0";                                          break;

      case 4205: er="H81:0 :>>@48=0B >1J5:B0";                                   break;

      case 4206: er="5 =0945=> C:070==>5 ?>4>:=>";                               break;

      case 4207: er="H81:0 ?@8 @01>B5 A >1J5:B><";                               break;

      default:   er="58725AB=0O >H81:0";

   }

   return(er);

}

//==============================================================

string TimeFrameToString(int tf) 

{

   string s = "";

   if (tf==0)tf=Period();

   

   switch (tf) 

   {

      case PERIOD_M1: s = "M1";  break;

      case PERIOD_M5: s = "M5";  break;

      case PERIOD_M15:s = "M15"; break;

      case PERIOD_M30:s = "M30"; break;

      case PERIOD_H1: s = "H1";  break;

      case PERIOD_H4: s = "H4";  break;

      case PERIOD_D1: s = "D1";  break;

      case PERIOD_W1: s = "W1";  break;

      case PERIOD_MN1:s = "MN1";

   }

      

   return (s);

}

//-------------------------------------------------

void Close_ord(int tip=-1)

{

   bool C,usl=true,CL=false;

   while (usl)

   {

      usl=false;

      for(int i=0; i<OrdersTotal(); i++)

      {

         if (!Good_ord(i,MODE_TRADES))continue;

         

         if(OrderType()==OP_BUY && (tip==OP_BUY || tip==-1))

         {

            RefreshRates();

            C=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage);

            CL=true;

            usl=true;

         }

         if (OrderType()==OP_SELL && (tip==OP_SELL || tip==-1))

         {

            RefreshRates();

            C=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage);

            CL=true;

            usl=true;

         }

      }

   }

   if(CL)Orders_Total();

}

//-----------------------------------------------

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---