Author: Copyright © 2020, Vladimir Hlystov
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
2 Views
0 Downloads
0 Favorites
cm LINES
ÿþ//+------------------------------------------------------------------+

//|                                               SendCloseOrder.mq4 |

//|                               Copyright © 2009, Vladimir Hlystov |

//|  v 1.00 #AB0=02;8205B 8;8 70:@K205B >@45@0 ?@8 ?5@5A5G5=88 ;8=89 |

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

#property copyright "Copyright © 2020, Vladimir Hlystov"

#property link      "cmillion@narod.ru"

string ver=" 2.0";

#property strict

#property description "#AB0=02;8205B 8;8 70:@K205B >@45@0 :>340 70:@KB0O A25G0 ?5@5A5G5B ;8=8N 8;8 :>A=5BAO 55"

/*!>25B=8: >B:@K205B ?>78F88 ?> B@5=4>2K< ;8=8O<.

0 3@0D8:5 :=>?:8   109, A5;, AB>?, ?@>D8B

;3>@8B< =0 ?@8<5@5 :>@>B:>9 A45;:8;

1. K18@05<  Sell. >A;5 MB>3> ?>O2;O5BAO ;8=8O 8 =0< =C6=> CAB0=>28BL 55 B0: :0: =C6=>.

2. <5< :=>?:C AB>? ;>AA, 2K18@05< 8 AB028< =C6=CN ;8=8N.

3. <5< :=>?:C B.?@>D8B 8 AB@>8< =C6=CN ;8=8N.

B:@KB85 >@45@0 ?@>8AE>48B, 5A;8 A25G0 70:@K205BAO =865 ;8=88. A;8 CAB0=>2;5=> B>;L:> :0A0=85, B> ?>78F8O >B:@>5BAO =5 4>6840OAL 70:@KB8O A25G8 2 B>B <><5=B, :>340 F5=0 :>A=5BAO ;8=88.

>6=> ?@>872>48BL 4>;82:8 ?> =>2K< ;8=8O<, AB>? 8 ?@>D8B, 2 MB>< A;CG05, ?@82O7K205BAO : B5< 65 ;8=8O< SL 8;8 TP. A;8 CAB0=>2;5=> @07<5I0BL AB>?K C 1@>:5@0, B> A>25B=8: 2KAB02;O5B @50;L=K9 SL 8 TP ?> ;8=88 8 ?5@5<5I05B 53>, 5A;8 ;8=8O =0:;>==0O.

>7<>6=> >B:@KB85 >@45@>2 2@CG=CN. 'B>1K A>25B=8: 8E ?>4E20B8;, CAB0=>28B5 <038: = 0.

8=88 AB>? ;>AA 8 B59: ?@>D8B <>6=> ?5@5<5I0BL 2@CG=CN.



https://youtu.be/jN7BDORmPz0

 

 

*/

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

extern int    levelOpen    = 50;     //=0G0;L=>5 @0AAB>O=85 4> ;8=88 >B:@KB8O

extern int    levelClose   = 80;     //=0G0;L=>5 @0AAB>O=85 4> ;8=88 70:@KB8O

extern double lot          = 0.10;   //;>B

extern bool   intersection_touch = true;//?5@5A5G5=85 8;8 :0A0=85

extern bool   BrokerStop = false;//CAB0=>28BL @50;L=K5 AB>?K C 1@>:5@0

extern int    Magic        = 0;           

extern int    MaxOrdersCandl = 1;  //=0 >4=>9 A25G5 >B:@K20BL =5 1>;55         

extern color  colorBuy     = clrBlue;

extern color  colorSell    = clrOrangeRed;

extern color  clorClose    = clrDarkRed;

int slippage = 20;

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

int OnInit()

{

   int X=5,Y=30;

   RectLabelCreate(0,"LINES _fon0",0,X-3,Y,116,120,clrGray,clrLightGray);Y+=5;

   LabelCreate(0,"LINES intersection_touch",0,X+5,Y,CORNER_LEFT_UPPER,intersection_touch?"intersection":"touch","Arial",10,clrWhite,0,ANCHOR_LEFT_UPPER);Y+=20;

   RectLabelCreate(0,"LINES _fon",0,X,Y,110,90,clrGray,clrLightGray);

   X+=5;

   Y+=5;



   ButtonCreate(0,"LINES Buy" ,0,X,Y,50,40,"BUY");

   ButtonCreate(0,"LINES SL B",0,X+50,Y,50,20,"SL");Y+=20;

   ButtonCreate(0,"LINES TP B",0,X+50,Y,50,20,"TP");Y+=20;

   

   ButtonCreate(0,"LINES Sell",0,X,Y,50,40,"SELL");

   ButtonCreate(0,"LINES SL S",0,X+50,Y,50,20,"SL");Y+=20;

   ButtonCreate(0,"LINES TP S",0,X+50,Y,50,20,"TP");Y+=20;

   EventSetTimer(1);

   OnTick();

   //Comment("Start ",WindowExpertName());

   return(INIT_SUCCEEDED);

}

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

void OnDeinit(const int reason)

{

   switch(reason) 

   { 

   case REASON_ACCOUNT: //:B828@>20= 4@C3>9 AG5B ;81> ?@>87>H;> ?5@5?>4:;NG5=85 : B>@3>2><C A5@25@C 2A;54AB285 87<5=5=8O =0AB@>5: AG5B0

      ObjectsDeleteAll(0,"LINES");break; 

   case REASON_CHARTCHANGE: //!8<2>; 8;8 ?5@8>4 3@0D8:0 1K; 87<5=5=

      break; 

   case REASON_CHARTCLOSE: //@0D8: 70:@KB

      ObjectsDeleteAll(0,"LINES");break; 

   case REASON_PARAMETERS: //E>4=K5 ?0@0<5B@K 1K;8 87<5=5=K ?>;L7>20B5;5<

      ObjectsDeleteAll(0,"LINES");break; 

   case REASON_RECOMPILE: //@>3@0<<0 ?5@5:><?8;8@>20=0

      break; 

   case REASON_REMOVE: //@>3@0<<0 C40;5=0 A 3@0D8:0

      ObjectsDeleteAll(0,"LINES");break; 

   case REASON_TEMPLATE: //@8<5=5= 4@C3>9 H01;>= 3@0D8:0

      ObjectsDeleteAll(0,"LINES");break; 

   case REASON_PROGRAM://-:A?5@B ?@5:@0B8; A2>N @01>BC, 2K7202 DC=:F8N ExpertRemove()

      ObjectsDeleteAll(0,"LINES");break; 

   default:ObjectsDeleteAll(0,"LINES"); 

   } 

}

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

void OnTick() {OnTimer();}

void OnTimer()

{

   int i,b=0,s=0,tip;

   double price,OSL,OTP,OOP;

   double SLB=ObjectGetValueByShift("LINES BUY SL",0);

   double SLS=ObjectGetValueByShift("LINES SELL SL",0);

   double TPB=ObjectGetValueByShift("LINES BUY TP",0);

   double TPS=ObjectGetValueByShift("LINES SELL TP",0);



   //LabelCreate(0,"LINES SLB",0,400,40,CORNER_LEFT_UPPER,DoubleToString(SLB,Digits),"Arial",10,clrRed);



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

   {    

      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

      { 

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

         { 

            tip = OrderType(); 

            OSL = NormalizeDouble(OrderStopLoss(),Digits);

            OTP = NormalizeDouble(OrderTakeProfit(),Digits);

            OOP = NormalizeDouble(OrderOpenPrice(),Digits);

            if (tip==OP_BUY)             

            {  

               if (OrderOpenTime()>=Time[0]) b++; //MaxOrdersCandl

               if (Bid<=SLB && SLB!=0) {if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),slippage,clrNONE)) continue;}

               if (Bid>=TPB && TPB!=0) {if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),slippage,clrNONE)) continue;}

               if (BrokerStop)

               {

                  if (OSL != SLB || OTP != TPB)

                  {  

                     if (!OrderModify(OrderTicket(),OOP,SLB,TPB,0,clrNONE)) Print("Error OrderModify <<",GetLastError(),">> ");

                  }

               }

               else

               {

                  if (OSL != 0 || OTP != 0)

                  {  

                     if (!OrderModify(OrderTicket(),OOP,0,0,0,clrNONE)) Print("Error OrderModify <<",GetLastError(),">> ");

                  }

               }   

            }                                   

            if (tip==OP_SELL)        

            {

               if (OrderOpenTime()>=Time[0]) s++;

               if (Ask>=SLS && SLS!=0) {if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),slippage,clrNONE)) continue;}

               if (Ask<=TPS && TPS!=0) {if (OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),slippage,clrNONE)) continue;}

               if (BrokerStop)

               {

                  if (OSL != SLS || OTP != TPS)

                  {  

                     if (!OrderModify(OrderTicket(),OOP,SLS,TPS,0,clrNONE)) Print("Error OrderModify <<",GetLastError(),">> ");

                  }

               }

               else

               {

                  if (OSL != 0 || OTP != 0)

                  {  

                     if (!OrderModify(OrderTicket(),OOP,0,0,0,clrNONE)) Print("Error OrderModify <<",GetLastError(),">> ");

                  }

               }   

            } 

         }

      }

   } 

   bool BUY=ObjectGetInteger(0,"LINES Buy",OBJPROP_STATE);

   bool SELL=ObjectGetInteger(0,"LINES Sell",OBJPROP_STATE);

   bool SLb=ObjectGetInteger(0,"LINES SL B",OBJPROP_STATE);

   bool TPb=ObjectGetInteger(0,"LINES TP B",OBJPROP_STATE);

   bool SLs=ObjectGetInteger(0,"LINES SL S",OBJPROP_STATE);

   bool TPs=ObjectGetInteger(0,"LINES TP S",OBJPROP_STATE);

   

   //---

   

   if (BUY)

   {

      if (ObjectFind("LINES _BUY")==-1)

      {

         price=MathMax(Ask,High[1])+levelOpen*Point;

         TrendCreate(0,"LINES _BUY",0,Time[10],price,Time[0],price,colorBuy,STYLE_SOLID,2);

      }

   }

   else ObjectsDeleteAll(0,"LINES _BUY");

   if (SLb)

   {

      price=MathMin(Bid,Low[1])-levelClose*Point;

      if (ObjectFind("LINES BUY SL")==-1) 

       TrendCreate(0,"LINES BUY SL",0,Time[10],price,Time[0],price+Point,clorClose,STYLE_SOLID,1);

   }

   else ObjectsDeleteAll(0,"LINES BUY SL");

   if (TPb)

   {

      price=MathMax(Ask,High[1])+levelClose*Point;

      if (ObjectFind("LINES BUY TP")==-1) 

       TrendCreate(0,"LINES BUY TP",0,Time[10],price,Time[0],price+Point,clorClose,STYLE_SOLID,1);

   }

   else ObjectsDeleteAll(0,"LINES BUY TP");

   

   //---

   

   if (SELL)

   {

      if (ObjectFind("LINES _SELL")==-1)

      {

         price=MathMin(Bid,Low[1])-levelOpen*Point;

         TrendCreate(0,"LINES _SELL",0,Time[10],price,Time[0],price,colorSell,STYLE_SOLID,2);

      }

   }

   else ObjectsDeleteAll(0,"LINES _SELL");

   if (SLs)

   {

      price=MathMax(Ask,High[1])+levelClose*Point;

      if (ObjectFind("LINES SELL SL")==-1)

       TrendCreate(0,"LINES SELL SL",0,Time[10],price,Time[0],price-Point,clorClose,STYLE_SOLID,1);

   }

   else ObjectsDeleteAll(0,"LINES SELL SL");

   if (TPs)

   {

      price=MathMin(Bid,Low[1])-levelClose*Point;

      if (ObjectFind("LINES SELL TP")==-1)

       TrendCreate(0,"LINES SELL TP",0,Time[10],price,Time[0],price-Point,clorClose,STYLE_SOLID,1);

   }

   else ObjectsDeleteAll(0,"LINES SELL TP");

   

   //---

   

   int order = checkapp();

   if (order==0) CLOSEORDER();

   if (order== 1 && b<MaxOrdersCandl) 

   {

      if(OrderSend(Symbol(),OP_BUY, lot,Ask,50,0,0,"LINES BUY",Magic,0,clrBlue)!=-1) 

         ObjectSetInteger(0,"LINES Buy",OBJPROP_STATE,false);

      Sleep(2000);

   }

   if (order==-1 && s<MaxOrdersCandl) 

   {

      if(OrderSend(Symbol(),OP_SELL,lot,Bid,50,0,0,"LINES SELL",Magic,0,clrRed)!=-1) 

         ObjectSetInteger(0,"LINES Sell",OBJPROP_STATE,false);

      Sleep(2000);

   }

}

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

void CLOSEORDER()

{

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

   {                                               

      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))

      {

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

         { 

            if (OrderType()==OP_BUY)

               if(!OrderClose(OrderTicket(),OrderLots(),Bid,30,CLR_NONE)) Print("Error close buy");

            if (OrderType()==OP_SELL)

               if(!OrderClose(OrderTicket(),OrderLots(),Ask,30,CLR_NONE)) Print("Error close sell");

         } 

      }  

   }

}

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

bool TrendCreate(const long            chart_ID=0,        // ID 3@0D8:0 

                 const string          name="TrendLine",  // 8<O ;8=88 

                 const int             sub_window=0,      // =><5@ ?>4>:=0 

                 datetime              time1=0,           // 2@5<O ?5@2>9 B>G:8 

                 double                price1=0,          // F5=0 ?5@2>9 B>G:8 

                 datetime              time2=0,           // 2@5<O 2B>@>9 B>G:8 

                 double                price2=0,          // F5=0 2B>@>9 B>G:8 

                 const color           clr=clrRed,        // F25B ;8=88 

                 const ENUM_LINE_STYLE style=STYLE_SOLID, // AB8;L ;8=88 

                 const int             width=1,           // B>;I8=0 ;8=88 

                 const bool            back=false,        // =0 704=5< ?;0=5 

                 const bool            selection=true,    // 2K45;8BL 4;O ?5@5<5I5=89 

                 const bool            ray_right=true,   // ?@>4>;65=85 ;8=88 2?@02> 

                 const bool            hidden=true,       // A:@KB 2 A?8A:5 >1J5:B>2 

                 const long            z_order=0)         // ?@8>@8B5B =0 =060B85 <KHLN 

  { 

   ResetLastError(); 

   if(!ObjectCreate(chart_ID,name,OBJ_TREND,sub_window,time1,price1,time2,price2)) 

     { 

      Print(__FUNCTION__, 

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

      return(false); 

     } 

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style); 

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width); 

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); 

   ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,ray_right); 

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); 

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 

   return(true); 

  } 

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

int checkapp()

{

   datetime X_1;

   double Y_1,Y_2,PriceLine;

   double shift_Y = (WindowPriceMax()-WindowPriceMin()) / 50;

   color col;

   for(int n=ObjectsTotal()-1; n>=0; n--) 

   {

      string Name=ObjectName(n);

      if (ObjectType(Name)!=OBJ_TREND) continue;

      if (StringFind(Name,"LINES ",0)!=-1)

      {

         X_1 = (datetime)ObjectGetInteger(0,Name, OBJPROP_TIME1); 

         //X_2 = (datetime)ObjectGetInteger(0,Name, OBJPROP_TIME2); 

         ObjectDelete (Name+" n");

         //if (X_1>X_2 ||  X_2<Time[0]) {continue;}

         Y_1 = ObjectGet(Name, OBJPROP_PRICE1);

         Y_2 = ObjectGet(Name, OBJPROP_PRICE2);

         col = (color)ObjectGetInteger(0,Name, OBJPROP_COLOR);

         ObjectCreate (Name+" n", OBJ_TEXT,0,X_1-Period()*60,Y_1+shift_Y,0,0,0,0);

         ObjectSetText(Name+" n",StringSubstr(Name,6) ,7,"Arial");

         ObjectSet    (Name+" n", OBJPROP_COLOR, col);

         //if (X_1<=Time[0] && X_2>=Time[0])//?>?0405B 2> 2@5<5==>9 480?07>=

         //{

            PriceLine=ObjectGetValueByShift(Name,0);

            if (PriceLine==0) continue;

            if (intersection_touch) 

            {

               if (PriceLine>=Low[1] && PriceLine<=High[1]) 

               {

                  //if (StringFind(Name,"LINES CLOSE",0)!=-1) return(0);

                  Comment(Name);

                  if (Name=="LINES _BUY" ) return(1);

                  if (Name=="LINES _SELL") return(-1);

                  

               }

            }

            else

            {

               if (Ask>=PriceLine && Name=="LINES _BUY" ) return(1);

               if (Bid<=PriceLine && Name=="LINES _SELL") return(-1);

            }

         //}

      }

   }

   return(100);

}

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

bool ButtonCreate(const long              chart_ID=0,               // ID 3@0D8:0

                  const string            name="Button",            // 8<O :=>?:8

                  const int               sub_window=0,             // =><5@ ?>4>:=0

                  const long               x=0,                     // :>>@48=0B0 ?> >A8 X

                  const long               y=0,                     // :>>@48=0B0 ?> >A8 y

                  const int               width=50,                 // H8@8=0 :=>?:8

                  const int               height=18,                // 2KA>B0 :=>?:8

                  const string            text="Button",            // B5:AB

                  const string            font="Arial",             // H@8DB

                  const int               font_size=10,             // @07<5@ H@8DB0

                  const color             clr=clrBlack,

                  const color             back_clr=clrLightGray,

                  const bool              state=false)              // =060B0/>B60B0

  {

   if (ObjectFind(chart_ID,name)==-1)

   {

      ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0);

      ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);

      ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);

      ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);

      ObjectSetString(chart_ID,name,OBJPROP_FONT,font);

      ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);

      ObjectSetInteger(chart_ID,name,OBJPROP_BACK,0);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,0);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,0);

      ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,1);

      ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,0);

      ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state);

      ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,clrNONE);

   }

   ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

   return(true);

}

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

bool RectLabelCreate(const long             chart_ID=0,               // ID 3@0D8:0

                     const string           name="RectLabel",         // 8<O <5B:8

                     const int              sub_window=0,             // =><5@ ?>4>:=0

                     const long              x=0,                     // :>>@48=0B0 ?> >A8 X

                     const long              y=0,                     // :>>@48=0B0 ?> >A8 y

                     const int              width=50,                 // H8@8=0

                     const int              height=18,                // 2KA>B0

                     const color            back_clr=clrNONE,         // F25B D>=0

                     const color            clr=clrNONE,              //F25B ?;>A:>9 3@0=8FK (Flat)

                     const ENUM_LINE_STYLE  style=STYLE_SOLID,        // AB8;L ?;>A:>9 3@0=8FK

                     const int              line_width=1,             // B>;I8=0 ?;>A:>9 3@0=8FK

                     const bool             back=false,               // =0 704=5< ?;0=5

                     const bool             selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89

                     const bool             hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2

                     const long             z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN

  {

   ResetLastError();

   if (ObjectFind(chart_ID,name)==-1)

   {

      ObjectCreate(chart_ID,name,OBJ_RECTANGLE_LABEL,sub_window,0,0);

      ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_TYPE,BORDER_FLAT);

      ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);

      ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);

      ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,line_width);

      ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

      ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

      ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

   }

   ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

   ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);

   ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

   return(true);

}

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

bool LabelCreate(const long              chart_ID=0,               // ID 3@0D8:0

                 const string            name="Label",             // 8<O <5B:8

                 const int               sub_window=0,             // =><5@ ?>4>:=0

                 const long              x=0,                      // :>>@48=0B0 ?> >A8 X

                 const long              y=0,                      // :>>@48=0B0 ?> >A8 y

                 const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // C3>; 3@0D8:0 4;O ?@82O7:8

                 const string            text="Label",             // B5:AB

                 const string            font="Arial",             // H@8DB

                 const int               font_size=10,             // @07<5@ H@8DB0

                 const color             clr=clrNONE,      

                 const double            angle=0.0,                // =0:;>= B5:AB0

                 const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // A?>A>1 ?@82O7:8

                 const bool              back=false,               // =0 704=5< ?;0=5

                 const bool              selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89

                 const bool              hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2

                 const long              z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN

{

   ResetLastError();

   if (ObjectFind(chart_ID,name)==-1)

   {

      if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))

      {

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

         return(false);

      }

      ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

      ObjectSetString(chart_ID,name,OBJPROP_FONT,font);

      ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);

      ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);

      ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);

      ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

      ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

      ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

   }

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

   return(true);

  }

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

bool EditCreate(const long             chart_ID=0,               // ID 3@0D8:0 

                const string           name="Edit",              // 8<O >1J5:B0 

                const int              sub_window=0,             // =><5@ ?>4>:=0 

                const long              x=0,                      // :>>@48=0B0 ?> >A8 X 

                const long              y=0,                      // :>>@48=0B0 ?> >A8 Y 

                const int              width=50,                 // H8@8=0 

                const int              height=18,                // 2KA>B0 

                const string           text="Text",              // B5:AB 

                const string           font="Arial",             // H@8DB 

                const int              font_size=8,             // @07<5@ H@8DB0 

                const ENUM_ALIGN_MODE  align=ALIGN_CENTER,       // A?>A>1 2K@02=820=8O 

                const bool             read_only=true,// 2>7<>6=>ABL @540:B8@>20BL 

                const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER,// C3>; 3@0D8:0 4;O ?@82O7:8 

                const color            clr=clrBlack,             // F25B B5:AB0 

                const color            back_clr=clrWhite,        // F25B D>=0 

                const color            border_clr=clrNONE,       // F25B 3@0=8FK 

                const bool             back=false,               // =0 704=5< ?;0=5 

                const bool             selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89 

                const bool             hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2 

                const long             z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN 

  {

   ResetLastError();

   if(ObjectFind(chart_ID,name)!=-1) ObjectDelete(chart_ID,name);

   //{

      if(!ObjectCreate(chart_ID,name,OBJ_EDIT,sub_window,0,0))

      {

         return(false);

      }

      ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);

      ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);

      ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

      ObjectSetString(chart_ID,name,OBJPROP_FONT,font);

      ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);

      ObjectSetInteger(chart_ID,name,OBJPROP_ALIGN,align);

      ObjectSetInteger(chart_ID,name,OBJPROP_READONLY,read_only);

      ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

      ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

      ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);

      ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,border_clr);

      ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

      ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

      ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

   //}

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

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