TorgPlus_v1.0_MT4

Author: Copyright 2020, Reutskiy Dmitriy.
Price Data Components
Series array that contains the lowest prices of each barSeries array that contains the highest prices of each barSeries array that contains open prices of each barSeries array that contains close prices for each bar
Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersChecks for the total of closed ordersIt Closes Orders by itself
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites
TorgPlus_v1.0_MT4
ÿþ//+------------------------------------------------------------------+

//|                                               TorgPlus_v1.0.mq4  |

//|                         |

//|                                                                  |

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

#property copyright "Copyright 2020, Reutskiy Dmitriy."

#property strict



extern string line1="||________________________________Input Parameters________________________________________||";

extern double lot = 0.01;

extern int intDays = 120; // 4=59 87 :>B>@KE AG8B05BAO A@54=55

extern string line4 = "________________________Volatility 1 = middle; 2 = minimum_______________________________";

extern int intSpred = 2;

extern string line5 = "________________________Hours in flat period_______________________________";

extern int intFlatTime = 7;

extern string line6 = "________________________Moving avarage_______________________________";

extern int intIma1 = 10; // A>:;L7OIOO A@54=OO

extern int intIma2 = 20; // A>:;L7OIOO A@54=OO

extern int intIma3 = 30; // A>:;L7OIOO A@54=OO

extern string line7 = "________________________Procent start take profit_______________________________";

extern double dblPnt = 1;

extern string line8 = "________________________Procent - 4 take profit_______________________________";

extern int intProce = 10;



double dblLot, dblTP_Points,  dblBL, dblMin, dblMax, dblSum, dblSpred,dblMSpred,dblTP_buy,dblSL_buy,dblOP_buy, dblTP_sell,dblSL_sell,dblOP_sell, dblProfit, dblIma1 ,dblIma2,dblIma3;

int intConnectLoss, intOrd, intX, intY, intHR, intHR1, intHR3, intI, intBuffBuy,intBuffSell, intJ,intSum, intMagicNumber, max_profit,intCount_line,intK,intDm,intDt,ticket_buy, intSell,intBuy;

bool blSpredSymbol, blTorg, blDelline, blFlat, blBuyIma, blSellIma;

string strSpredSymbol, strNameObject, sManday, sTuesday, sWednesday, sFursday,sFriday ;

datetime LastTime, Bar_time,timeprev;







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

//| expert initialization function                                   |

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

int init()

{

   //---- ?0@0<5B@K ?@O<>C3>;L=8:0

 intX = 20;

 intY = 20;

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

   //blDelline = false;

 dblProfit = 1-100;

 blTorg = true;

 dblLot = lot;

 intSell = 0;

 intBuy = 0;

 intDt = 1;

 return(0);

}



int deinit()

 {

//---

  dblMSpred = 2000;

  intK = 0;

  dblSpred = 0;

  blFlat = false;

//----

  return(0);

 }

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

//| start function                                            |

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

int start()

{



 

if(!CheckVolumeValue(lot)) return 0; 

 

blSpredSymbol=SymbolInfoInteger(Symbol(),SYMBOL_SPREAD_FLOAT);

strSpredSymbol=StringFormat("Spred %s = %I64d", blSpredSymbol?"random":"fixed",SymbolInfoInteger(Symbol(),SYMBOL_SPREAD));

    

//---------------- AG8B05 A?@54 ?> 8AB>@88 --------------//

if(dblSpred == 0) // ?5@2K9 70?CA:

 {

  int Min_Dist=MarketInfo(Symbol(),MODE_STOPLEVEL); // I5< =08<5=LHCN <8=8<0;L=CN 2>;0B8;L=>ABL

  if(intSpred == 1) dblSpred = f_dbl_spred( intDays,"dblAvargeSpred"); // 8A?>;L7C5< A?@54 1 =  A@54=89; 

  else dblSpred = f_dbl_spred( intDays,"dblMinSpred"); // 8=0G5 = <8=8<0;L=K9 (2,3...)

 }

   

   // C25;8G5=85 ;>B0 2 A;CG05 ?@>18B8O 450?07>=0 <8=8<0;L=>3> D;5B0

if(CountTrades(1) == 1 ) // ?@>25@:0 >B:@KB sell

 {

  //7<5=O5< 7=0G5=85 AB>? ;>AA0 4;O ?>:C?: - <8=8<0;L=>5 7=0G5=85

  if(Close[0] < dblSL_buy) dblSL_buy = Close[0]; // =>2K9 109 AB>?

  if(Close[0] >  dblSL_sell) // 5A;8 ?@>18;8 AB>?

   {

    CloseThisSymbolAll(); // 70:@K205< >@45@0

    dblTP_Points =  Closed_ord()*(-1); //?@8102;O5< ?>B5@N 2 ?C=:B0E

    intOrd = intSell + intBuy;

    if(intOrd > 2){dblTP_Points = dblTP_Points - dblTP_Points*intProce/100;} // 5A;8 >@45@>2 1>;LH5 3-E B> C<5=LH05< B59: 2 ?@>F5=B0E

    dblTP_buy = Close[0] + dblTP_Points*Point;

            

    if(CountTrades(2) == 0) // ?@>25@:0 >@45@>2 =0 ?@>406C

    {   

     // ?KB05<AO 2KAB028BL >@45@

     ticket_buy=OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,dblTP_buy,"My order ",intMagicNumber,0,Blue); //dblSL_buy

     if(ticket_buy<0)

      {

       Print("OrderSend failed with error #",GetLastError());

       return(0);

      }

       else

      {

       intBuy++;    // :>;8G5AB2> >@45@>2

       lot = lot*2; // C25;8G8205< ;>B

       //@8AC5< =>2K9 AB>? ;>AA

       f_Drow_Trend_line(iTime(0,PERIOD_H1,0),iTime(0,PERIOD_H1,intFlatTime),dblSL_sell,dblSL_sell,Blue,STYLE_SOLID,1);

      }

    } 

   }

 }

      

if(CountTrades(2) == 1 ) // ?@>25@:0 >B:@KB buy 5A;8 B@C B> >B:@K205< A5;;

 {

  if(Close[0] > dblSL_sell) dblSL_sell = Close[0]; // =>2K9 AB>? ?@8 =0;G88 >@45@0 =0 109

  if(Close[0] < dblSL_buy) // 5A;8 ?@>18;8 ?@54K4CI89 AB>?

   {

    CloseThisSymbolAll();// 70:@K205< >@45@0

    dblTP_Points =  Closed_ord()*(-1) ; // ?>B5@O >@45@0 2 ?C=:B0E

    intOrd = intSell + intBuy;

    if(intOrd > 2){dblTP_Points = dblTP_Points - dblTP_Points*intProce/100;}   

    dblTP_sell = Close[0] - dblTP_Points*Point; // =>2K9 A5;;

    if(CountTrades(1) == 0) // ?@>25@:0 >@45@>2 =0 ?@>406C

     {

      // ?KB05<AO 2KAB028BL >@45@

      ticket_buy=OrderSend(Symbol(),OP_SELL,lot,Bid,3,0,dblTP_sell,"My order ",intMagicNumber,0,Red);// dblSL_sell

      if(ticket_buy<0)

       {

        Print("OrderSend failed with error #",GetLastError());

        return(0);

       }

      else

       {

        intSell++; // :>;8G5AB2> Sell

        lot = lot*2; // :>;8G5AB2> buy

        f_Drow_Trend_line(iTime(0,PERIOD_H1,0),iTime(0,PERIOD_H1,intFlatTime),dblSL_buy,dblSL_buy,Blue,STYLE_SOLID,1);

       }

      }

    } 

 }

      

   // @07 2 G0A ?5@5AB02;OBL AB>? 5A;8 B>@3C5< A ?;020NI8<

   /*

   if(!blTakeStop) {

         if(Hour() != intHR)

            {

               even_point();

               intHR = Hour();

            }    

    }

   */

   

if(CountTrades(6) == 0) // 5A;8 =5B >@45@>2 CountTrades(6) == 0  

 {

  // @07 2 G0A, 5A;8 =5B D;5B0

  if(Hour() != intHR1 && !blFlat ) 

   {

    dblMin = iLow(0,PERIOD_H1,intFlatTime); // 8=8<C< D;5B>2>9 A25G8 (480?07>= intFlatTime)

    dblMax = iHigh(0,PERIOD_H1,intFlatTime); // 0:A8<C< D;5B>2>9 A25G8 (480?07>= intFlatTime)

    blFlat = true; // 5ABL D;5B 

    // ?@>25@O5< ?@>1820;0AL ;8 A25G0 70:@KB>9 A25G59

    for(intI = intFlatTime-1; intI > 0; intI--) // 480?07>= D;5B0 intFlatTime

     {

      if(iClose(0,PERIOD_H1,intI) > dblMax || iOpen(0,PERIOD_H1,intI)> dblMax || iClose(0,PERIOD_H1,intI) < dblMin || iOpen(0,PERIOD_H1,intI)< dblMin) blFlat = false;

     }

      if(blFlat) // 5A;8 D;5B >AB0;AO true @8AC5< ;8=88 D;5B0

       { 

        dblBL = (dblMax - dblMin)/Point;

        f_Drow_Trend_line(iTime(0,PERIOD_H1,0),iTime(0,PERIOD_H1,intFlatTime),dblMin,dblMin,Blue,STYLE_SOLID,1);// G5@B8< ;8=8N =0 9 10@>2

        f_Drow_Trend_line(iTime(0,PERIOD_H1,0),iTime(0,PERIOD_H1,intFlatTime),dblMax,dblMax,Blue,STYLE_SOLID,1);// G5@B8< ;8=8N =0 9 10@>2

        dblTP_buy =  dblMax + dblBL*Point;   // dblMin + NormalizeDouble(dblSpred*dblPnt,0)*Point; //  dblSpred 0:>9 A?@54 8A?>;L7C5< <8=8<0;L=K9

        dblSL_buy = dblMin;

        f_Drow_Trend_line(iTime(0,PERIOD_H1,0),iTime(0,PERIOD_H1,15),dblTP_buy,dblTP_buy,Red,STYLE_SOLID,1);

        dblTP_sell = dblMin - dblBL*Point;  // dblMax - NormalizeDouble(dblSpred*dblPnt,0)*Point; // 0 200 ?C=:B>2 A428=C;8 Bp

        dblSL_sell =  dblMax;

        f_Drow_Trend_line(iTime(0,PERIOD_H1,0),iTime(0,PERIOD_H1,15),dblTP_sell,dblTP_sell,Red,STYLE_SOLID,1);// dblTP_sell

        dblTP_Points = NormalizeDouble(dblSpred*dblPnt,0); // "59: ?@>D8B 2 ?C=:B0E

        // ?@>25@O5< @0725@=CBK5 ima 4;O ?>;>28=K D;5B0

        blBuyIma = true; // A@54=85 @0725@=CBK 2 25@E

        blSellIma = true; // A@54=85 @0725@=CBK 2=87

        for(intI = 0  ; intI < NormalizeDouble(intFlatTime/2,0); intI++)//         

         {

          dblIma1 = iMA(NULL,0,intIma1,0,MODE_SMA,PRICE_CLOSE,intI);

          dblIma2 = iMA(NULL,0,intIma2,0,MODE_SMA,PRICE_CLOSE,intI);

          dblIma3 = iMA(NULL,0,intIma3,0,MODE_SMA,PRICE_CLOSE,intI);

          if(!(dblIma1 > dblIma2 && dblIma2 > dblIma3)){ blBuyIma = false; }

          if(!(dblIma1 < dblIma2 && dblIma2 < dblIma3)){ blSellIma = false; }

         }  

                 // blDelline == true; // C40;5=85 ;8=89

        }

      intHR1 = Hour();

    } 

 

   

 if(Hour() >= 0 && Hour() <= 23) // 5A;8 25@<O A 0 4> 23

  {

   if(intOrd > 0)

    {

     dblProfit = Closed_ord();

    }

  // 2KAB02;5=85 ?5@2KE >@54@>2

   if(iClose(0,PERIOD_H1,0) > dblMax  && dblProfit < 1  && dblBL*2 < dblSpred  && blFlat && blBuyIma  ) 

    { 

     if(CountTrades(7) < 1)

      {

       // ?> B5:CI59 F5=5

       ticket_buy=OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,dblTP_buy,"My order ",intMagicNumber,0,Blue); //dblSL_buy

       if(ticket_buy<0)

        {

         Print("OrderSend failed with error #",GetLastError());

         return(0);

        }

      else

       {

        // @8AC5< ;8=88 480?07>=0 4>1028BL

        intBuy++;  // :>;8G5AB2> >@45@>2

        lot = lot*2;//if(lot != 0.8)

       }

      }

     }

   if(iClose(0,PERIOD_H1,0) < dblMin && dblProfit < 1   && dblBL*2 < dblSpred  && blFlat && blSellIma )  

    { 

     if(CountTrades(8) < 1)

      {

      // 2KAB02;O5< >@54@

       ticket_buy=OrderSend(Symbol(),OP_SELL,lot,Bid,3,0,dblTP_sell,"My order ",intMagicNumber,0,Red);// dblSL_sell

       if(ticket_buy<0)

        {

         Print("OrderSend failed with error #",GetLastError());

         return(0);

        }

       else

        {

         intSell++;

         lot = lot*2;

        }

       }

     }

   intOrd = intSell + intBuy;

   if(iClose(0,PERIOD_H1,0) < dblMin  || iClose(0,PERIOD_H1,0) > dblMax ) blFlat = false; 

  }

   

 if(Hour() == 23 && intOrd > 0)  // c 23 ?> 24 C40;O5< ;8=88 5A;8 =5B >@45@>2

  {

     // C40;O5< ;8=88 

     // for(intI=0 ; intI <= intCount_line; intI++)

     //   {

     //    ObjectDelete("line_" + IntegerToString(intI));

     //   } 

   dblProfit = 1-100; // @07@5H8BL B>@3>2;N

   intOrd=0;

   intBuffBuy = intBuffBuy + intBuy;

   intBuffSell = intBuffSell + intSell;

   intSell = 0;

   intBuy = 0;

   blTorg = true;

   //blDelline = false;

   if(intSpred == 1) dblSpred = f_dbl_spred( intDays,"dblAvargeSpred"); // 8A?>;L7C5< A?@54 1 =  A@54=89; 2(else) = <8=8<0;L=K9

   else dblSpred = f_dbl_spred( intDays,"dblMinSpred");

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

   lot = dblLot; // >1=C;8;8 ;>B

   intDt = 1;   //intCount_line = 0; // >1=C;8BL ?@8 C40;5=88 ;8=89;

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

  }

 } 

 

 //1K; 2KAB02;5= >@45@. 2 MB8 24 G0A0

 

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

// Min_Dist=MarketInfo(Symbol(),MODE_SPREAD);

// Str_time = TimeToStr(TimeCurrent(),TIME_MINUTES);



//--------------------@0D8G5A:0O G0ABL----------------------//

if(Hour() != intHR)

 {

// ?KB05<AO A>740BL >1L5:B ?@O<>C3>;L=8:0

  if(ObjectFind(0,"objRect") < 0) // 5A;8 =5B ?@O<>C3>;L=8:0

   {

    if(!ObjectCreate(0,"objRect",OBJ_RECTANGLE_LABEL,0,0,0))

     {

      Print(__FUNCTION__,"=5 C40;>AL A>740BL B5:AB>2CN <5B:C. >4 >H81:8 =",GetLastError());

      //return(false);

     }

    else // 5A;8 ?>;CG8;>AL A>740BL >1L5:B

     { 

      ObjectSetInteger(0,"objRect",OBJPROP_XDISTANCE,intX); //x

      ObjectSetInteger(0,"objRect",OBJPROP_YDISTANCE,intY); //y

      ObjectSetInteger(0,"objRect",OBJPROP_BGCOLOR,clrWhite); // F25B D>=0

      ObjectSetInteger(0,"objRect",OBJPROP_XSIZE,270); // H8@8=0

      ObjectSetInteger(0,"objRect",OBJPROP_YSIZE,190); // 2KA>B0

      ObjectSetInteger(0,"objRect",OBJPROP_CORNER,CORNER_LEFT_UPPER); // C3>;

      ObjectSetInteger(0,"objRect",OBJPROP_BORDER_TYPE,BORDER_FLAT); // B8? @0<:8

      ObjectSetInteger(0,"objRect",OBJPROP_COLOR,clrOrange); // F25B @0<:8

      ObjectSetInteger(0,"objRect",OBJPROP_STYLE,STYLE_SOLID); // AB8;L @0<:8

      ObjectSetInteger(0,"objRect",OBJPROP_WIDTH,3); // H8@8=0 @0<:8

      ObjectSetInteger(0,"objRect",OBJPROP_BACK,false);// =0 ?5@54=89 ?;0=

     }

   }

       

  for(intI = 1; intI<=7; intI++) // ?@>25@O5< =0;8G85 =04?8A59 objText1,2,3,4,5

   {

    if(ObjectFind(0,"objText" + intI) < 0) // 5A;8 =04?8AL >BACBAB2CN5B

     {

      // A>7405< 

      strNameObject = "objText" + intI;

      ObjectCreate(strNameObject, OBJ_LABEL, 0, 0, 0); 

      ObjectSet(strNameObject, OBJPROP_CORNER, CORNER_LEFT_UPPER);

      ObjectSet(strNameObject, OBJPROP_XDISTANCE, intX+10);

      ObjectSet(strNameObject, OBJPROP_YDISTANCE, intY+intI*20); 

      // 70?>;=O5< 

      if(intI==1) ObjectSetText(strNameObject,"__TorgPlusMT4__ v1.0"  ,12,"Arial",clrBlack);

      if(intI==2) ObjectSetText(strNameObject,"Day volatility " + dblSpred  ,12,"Arial",clrBlack);

      if(intI==3) ObjectSetText(strNameObject,"Buys  " + intBuffBuy   ,12,"Arial",clrBlack);

      if(intI==4) ObjectSetText(strNameObject,"Sells " + intBuffSell  ,12,"Arial",clrBlack);

      if(intI==5) ObjectSetText(strNameObject,"Current lot " + lot  ,12,"Arial",clrBlack);

      if(intI==6) ObjectSetText(strNameObject,"Balance " + AccountBalance()  ,12,"Arial",clrBlack); 

      if(intI==7) ObjectSetText(strNameObject,"Spred " + strSpredSymbol  ,12,"Arial",clrBlack); 

      //if(intI==8) ObjectSetText(strNameObject,"Connection losses " + intConnectLoss  ,12,"Arial",clrBlack);   

     }  

    else //  ACI5AB2C5B 

     {

      strNameObject = "objText" + intI;

      if(intI==1) ObjectSetText(strNameObject,"__TorgPlusMT4__ v1.0"  ,12,"Arial",clrBlack);

      if(intI==2) ObjectSetText(strNameObject,"Min Spred " + dblSpred  ,12,"Arial",clrBlack);

      if(intI==3) ObjectSetText(strNameObject,"Sells  " + intBuffBuy   ,12,"Arial",clrBlack);

      if(intI==4) ObjectSetText(strNameObject,"Buys " + intBuffSell  ,12,"Arial",clrBlack);

      if(intI==5) ObjectSetText(strNameObject,"Current lot " + lot  ,12,"Arial",clrBlack);

      if(intI==6) ObjectSetText(strNameObject,"Balance " + AccountBalance()  ,12,"Arial",clrBlack);

      // if(intI==8) ObjectSetText(strNameObject,"Connection losses " + intConnectLoss  ,12,"Arial",clrBlack);

     }   

   }

  intHR = Hour();// ?@8A208205< 7=0G5=85 G0A0

 }  

 // A?@54 ?5@5AG8BK205< :064K9 B8:

ObjectSetText("objText7","Spred " + strSpredSymbol  ,12,"Arial",clrBlack);

return(0);

}



//+---------------------$C=:F88------------------------------------+

//  0AAG8BK205B A?@54

// C45< @0AAG8BK20BL 8AE>4O 87 3-E <5AOF52

// 120 4=59 = ?>; 3>40

double f_dbl_spred(int intDs,string param)

  {

   int  FintK = 0;

   int  Fi = 0;

   

   double Fdbl, FdblArr[300], FdblMSpred, FdblSum, FdblSpredAV , FintK1;



   for(Fi = 0; Fi<intDs; Fi++)

     {

      Fdbl = iHigh(0,PERIOD_D1,Fi) - iLow(0,PERIOD_D1,Fi);

      Fdbl = Fdbl/Point;

      FdblArr[FintK] = Fdbl;

      FintK++; // :>;8G5AB2> 4=59 2 A?@545

     }

     

   FdblMSpred = FdblArr[1];

   for(Fi = 1; Fi <  FintK; Fi++)

     {

      if(FdblMSpred > FdblArr[Fi])

         FdblMSpred = FdblArr[Fi] ;

     }



   for(Fi = 0; Fi<intDs; Fi++)

     {

      FdblSum =  FdblSum + FdblArr[Fi];

     }

     

   FintK1 = FintK;    

   FdblSpredAV = NormalizeDouble(FdblSum/FintK1,0);

   

   if(param == "intK")

     {

      return FintK1;

     }

   if(param == "dblMinSpred")

     {

      return FdblMSpred;

     }

   if(param == "dblAvargeSpred")

     {

      return FdblSpredAV;

     }

   else return 0;

}





// >4AG8BK205B >@45@0  param = 1,2,3,4

// 1 - open ords

// 2 - open sell

// 3 - open buy

// 4 - pending order

// 5 - pending buy

// 6 - pending sell

// 7 or other => whole sum

int CountTrades(int param)

{

   int FintFBuyStop = 0,FintSellStop = 0, FintBuy = 0, FintSell=0;



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

     {

      OrderSelect(trade, SELECT_BY_POS, MODE_TRADES);

      if(OrderMagicNumber() != intMagicNumber) continue;

      if(OrderMagicNumber() == intMagicNumber)

      if(OrderType() == OP_BUYSTOP) FintFBuyStop++;

      if(OrderType() == OP_SELLSTOP)  FintSellStop++;

      if(OrderType() == OP_BUY)  FintBuy++;

      if(OrderType() == OP_SELL) FintSell++;

     }



    if(param == 0)  return (FintBuy + FintSell);

     //return 0;

    if(param == 1)  return (FintSell);

    if(param == 2)  return (FintBuy);

    if(param == 3)  return (FintSellStop + FintFBuyStop);

    if(param == 4)  return (FintSellStop);

    if(param == 5)  return (FintSellStop);

    if(param == 6)  return (FintBuy + FintSell + FintSellStop + FintFBuyStop);

    if(param == 7)  return (FintFBuyStop + FintBuy);

    if(param == 8)  return (FintSellStop + FintSell);

    if(param > 8)   return (FintBuy + FintSell + FintSellStop + FintSellStop);

    else return 0;

}











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

//|--------------------f_Drow_Trend_line-----------------------------+                                                  |

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

// 2>72@0I05B true 5A;8 C40;>AL =0@8A>20BL ;8=8N B@5=40

bool f_Drow_Trend_line(datetime FdtT1, datetime FdtT2, double FdblP1, double FdblP2, color FclrCLine, const ENUM_LINE_STYLE Fstyle, int FwidthL)

  {

// =0G0;L=>5 2@5<O

// :>=5G=>5 2@5<O

// =0G0;L=0O F5=0

// :>=5G=0O F5=0

// F25B clrRed

// AB8;L STYLE_SOLID

// H8@8=0 1

   intCount_line++; // 3;>10;L=0O ?5@5<5==0O :>;8G5AB20 ;8=89

   string FNameL = "line_" + intCount_line;

   ResetLastError();

   if(!ObjectCreate(0,FNameL,OBJ_TREND,0,FdtT1,FdblP1,FdtT2,FdblP2))

     {

      Print(__FUNCTION__, ": =5 C40;>AL A>740BL ;8=8N B@5=40! >4 >H81:8 = ",GetLastError());

      return(false);

     }

   ObjectSetInteger(0,FNameL,OBJPROP_COLOR,FclrCLine);      //CAB0=>28< F25B ;8=88

   ObjectSetInteger(0,FNameL,OBJPROP_STYLE,Fstyle);         //CAB0=>28< AB8;L >B>1@065=8O ;8=88

   ObjectSetInteger(0,FNameL,OBJPROP_WIDTH,FwidthL);        //CAB0=>28< B>;I8=C ;8=88

   ObjectSetInteger(0,FNameL,OBJPROP_BACK,true);           //>B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(0,FNameL,OBJPROP_RAY_RIGHT,false); //2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?@>4>;65=8O >B>1@065=8O ;8=88 2?@02>

   ObjectSetInteger(0,FNameL,OBJPROP_HIDDEN,false);    //A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

//ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);  //CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

//--- CA?5H=>5 2K?>;=5=85

   return(true);

  }







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

//|------------------Drow_line------------------------------------                                                          |

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

void Drow_line(double PR, color color_line)

  {

   intCount_line++;

   string Line_name = "line_" + intCount_line;

   bool Line = ObjectCreate(Line_name,OBJ_HLINE,0,0,PR);

   ObjectSet(Line_name,OBJPROP_COLOR,color_line); // F25B LimeGreen

   ObjectSet(Line_name,OBJPROP_WIDTH,1); //B>;I8=0

  }

//----Finde hight Close price

double hight_price(int Bars_period)

  {

   double max_close = Close[1];

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

     {

      if(Close[i] > max_close)

         max_close = Close[i];



     }

   return max_close;

  }







//----Closed orders

double Closed_ord()

  {

// for (int trade = OrdersTotal(); trade >= 0; trade--) {

   OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS, MODE_HISTORY);

   if(OrderSymbol() == Symbol() && OrderMagicNumber() == intMagicNumber)

     {

      if(OrderType() == OP_BUY)

        {

         return ((OrderClosePrice() - OrderOpenPrice())/Point);

        }   

      if(OrderType() == OP_SELL)

        {

         return ((OrderOpenPrice() - OrderClosePrice())/Point);

        }

       else {return 0;}

     }

    else {return 0;}



  }



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

//|                                                                  |

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

void CloseThisSymbolAll()

  {

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

     {

      OrderSelect(trade, SELECT_BY_POS, MODE_TRADES);

      if(OrderSymbol() == Symbol())

        {

         if(OrderMagicNumber() == intMagicNumber)

           {

            if(OrderType() == OP_BUY)

               OrderClose(OrderTicket(),OrderLots(),Bid,2);

            if(OrderType() == OP_SELL)

               OrderClose(OrderTicket(),OrderLots(),Ask,2);

           }

       // Sleep(1000);

        }

     }

  }



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

//|  @>25@O5B >1J5< >@45@0 =0 :>@@5:B=>ABL                          |

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

bool CheckVolumeValue(double volume)

  {

//--- <8=8<0;L=> 4>?CAB8<K9 >1J5< 4;O B>@3>2KE >?5@0F89

   string description;

   double min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);

   if(volume<min_volume)

     {

      description=StringFormat("1J5< <5=LH5 <8=8<0;L=> 4>?CAB8<>3> SYMBOL_VOLUME_MIN=%.2f",min_volume);

      return(false);

     }



//--- <0:A8<0;L=> 4>?CAB8<K9 >1J5< 4;O B>@3>2KE >?5@0F89

   double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);

   if(volume>max_volume)

     {

      description=StringFormat("1J5< 1>;LH5 <0:A8<0;L=> 4>?CAB8<>3> SYMBOL_VOLUME_MAX=%.2f",max_volume);

      return(false);

     }



//--- ?>;CG8< <8=8<0;L=CN 3@040F8N >1J5<0

   double volume_step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);



   int ratio=(int)MathRound(volume/volume_step);

   if(MathAbs(ratio*volume_step-volume)>0.0000001)

     {

      description=StringFormat("1J5< =5 O2;O5BAO :@0B=K< <8=8<0;L=>9 3@040F88 SYMBOL_VOLUME_STEP=%.2f, 1;8609H89 :>@@5:B=K9 >1J5< %.2f",

                               volume_step,ratio*volume_step);

      return(false);

     }

   description=">@@5:B=>5 7=0G5=85 >1J5<0";

   return(true);

  }

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 ---