Author: Roman.
Miscellaneous
Uses files from the file systemIt issuies visual alerts to the screenIt reads information from a fileIt writes information to file
0 Views
0 Downloads
0 Favorites
Stage
ÿþ//+------------------------------------------------------------------+

//|                                                      ProjectName |

//|                                      Copyright 2012, CompanyName |

//|                                       http://www.companyname.net |

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

#property strict

#property version     "1.01"

#property copyright   "Roman."

#property link        "qwer1234_4@bk.ru"



#property indicator_chart_window



extern color   cl_M5     =  clrLightBlue;

extern color   cl_H1     =  clrCornflowerBlue;

extern color   cl_D1     =  clrMagenta;



long x_distance;

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

//|                                                                  |

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

int OnInit()

  {

   ChartSetInteger(0,CHART_SHOW_ONE_CLICK,false);

   ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,1);

   ObjectDelete(0,"RectLabel");

   if(!ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0,x_distance))

     {

      Print("5 C40;>AL ?>;CG8BL H8@8=C 3@0D8:0! >4 >H81:8 = ",GetLastError());

      return 0;

     }

   return(INIT_SUCCEEDED);

  }

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

//|                                                                  |

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



void deinit()

  {



  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {



   return(rates_total);

  }

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

//|                                                                  |

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

uint Prev_x,PrevSParam;

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

//|                                                                  |

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

void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)

  {

   if(id==CHARTEVENT_OBJECT_CLICK)

     {

      string clickedChartObject=sparam;



      if(sparam=="Sc")

        {



        }



      if(sparam=="Dt")

        {



        }



      if(sparam=="As")

        {



         ObjectSetInteger(0,"As",OBJPROP_STATE,false);

         Comment("Start Load File");

         ObjectDelete(0,"RectLabel");

         int file_handle=FileOpen(Symbol()+"stage.csv",FILE_CSV|FILE_READ,";");



         if(file_handle!=INVALID_HANDLE) PrintFormat("0?8AL...");  else  Alert("H81:0 >B:@KB8O.");



         string Data[7];



         int Field=0;



         ObjectsDeleteAll(0,"Stage");



         while(!FileIsEnding(file_handle))

           {



            Data[Field]=FileReadString(file_handle);

            Field++;



            if(FileIsLineEnding(file_handle))

              {

               Field=0;

               if(StringToDouble(Data[6])!=1)

                 {

                  RectangleCreate("StageRect"+Data[0]+"TF"+Data[1],// 8<O ?@O<>C3>;L=8:0

                                  (datetime)              StringToInteger(Data[2]),           // 2@5<O ?5@2>9 B>G:8

                                  (datetime)              StringToInteger(Data[3]),           // 2@5<O 2B>@>9 B>G:8                     

                                  StringToDouble(Data[4]),                                    // F5=0 ?5@2>9 B>G:8

                                  StringToDouble(Data[5]),

                                  StringToInteger(Data[1])<60 ? cl_M5 : StringToInteger(Data[1])>60 ? cl_D1 : cl_H1);

                 }

               else

                 {

                  LineCreate("StageLine"+Data[0]+"TF"+Data[1],// 8<O ?@O<>C3>;L=8:0

                             (datetime)              StringToInteger(Data[2]),           // 2@5<O ?5@2>9 B>G:8

                             (datetime)              StringToInteger(Data[3]),           // 2@5<O 2B>@>9 B>G:8                     

                             StringToDouble(Data[4]),                                    // F5=0 ?5@2>9 B>G:8

                             StringToDouble(Data[5]),

                             StringToInteger(Data[1])<60 ? cl_M5 : StringToInteger(Data[1])>60 ? cl_D1 : cl_H1);

                 }



              }

           }



         FileClose(file_handle);

         Comment("Load File Success");

        }



      if(sparam=="Sh")

        {

         ObjectSetInteger(0,"Sh",OBJPROP_STATE,false);



         int tmpRectangle=0;



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

           {

            string b_=ObjectName(i);



            int type=(int) ObjectGetInteger(ChartID(),b_,OBJPROP_TYPE);



            if(!(type==OBJ_RECTANGLE || type==OBJ_TREND)) continue;



            if(!(StringCompare("StageRect",StringSubstr(b_,0,9))==0

               || StringCompare("StageLine",StringSubstr(b_,0,9))==0)) continue;



            b_ = StringSubstr(b_,9,StringLen(b_));

            b_ = StringSubstr(b_,0,StringFind(b_,"TF"));



            tmpRectangle=tmpRectangle<StrToInteger(b_) ? StrToInteger(b_): tmpRectangle;

           }

         bool Index = true;  

         while(Index){

            Index = false;

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

              {

               string b_=ObjectName(i);

   

               int type=(int) ObjectGetInteger(ChartID(),b_,OBJPROP_TYPE);

   

               if(!(type==OBJ_RECTANGLE || type==OBJ_TREND)) continue;

               if(!StringCompare("StageRect",StringSubstr(b_,0,9)) || !StringCompare("StageLine",StringSubstr(b_,0,9)))continue;

               

               Index = true;

               tmpRectangle++;

               if(type!=OBJ_TREND)

                 {

                  string new_name="StageRect"+IntegerToString(tmpRectangle)+"TF"+IntegerToString(Period());

                  ObjectSetString(0,b_,OBJPROP_NAME,0,new_name);

                  RectangleUpdate(new_name,Period()<60 ? cl_M5 : Period()>60 ? cl_D1 : cl_H1);

                 }

               else

                 {

                  string new_name="StageLine"+IntegerToString(tmpRectangle)+"TF"+IntegerToString(Period());

                  ObjectSetString(0,b_,OBJPROP_NAME,0,new_name);

                  LineUpdate(new_name,Period()<60 ? cl_M5 : Period()>60 ? cl_D1 : cl_H1);

                 }

              }

           }

         int iBarsM5=0,iBarsH1=0,iBarsD1=0,iLineM5=0,iLineH1=0,iLineD1=0;

         double dBarsM5=0, dBarsH1=0, dBarsD1=0, dLineM5=0, dLineH1=0, dLineD1=0;

         double hBarsM5=0, hBarsH1=0, hBarsD1=0, hLineM5=0, hLineH1=0, hLineD1=0;



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

           {

            string b_=ObjectName(i);



            int type=(int) ObjectGetInteger(ChartID(),b_,OBJPROP_TYPE);



            if(!(type==OBJ_RECTANGLE || type==OBJ_TREND)) continue;



            if(StringCompare("StageRect",StringSubstr(b_,0,9))!=0 && StringCompare("StageLine",StringSubstr(b_,0,9))!=0)continue;

            int TF=StrToInteger(StringSubstr(b_,StringFind(b_,"TF")+2,StringLen(b_)));



            if(type==OBJ_RECTANGLE)

              {

               switch(TF)

                 {

                  case 5:

                     iBarsM5++;

                     dBarsM5 += MathAbs(iBarShift(NULL,5,ObjectGetInteger(0,b_,OBJPROP_TIME2))-iBarShift(NULL,5,ObjectGetInteger(0,b_,OBJPROP_TIME1)));

                     hBarsM5 += MathAbs(ObjectGetDouble(0,b_,OBJPROP_PRICE1) - ObjectGetDouble(0,b_,OBJPROP_PRICE2));

                     break;

                  case 60:

                     iBarsH1++;

                     dBarsH1 += MathAbs(iBarShift(NULL,60,ObjectGetInteger(0,b_,OBJPROP_TIME2))-iBarShift(NULL,60,ObjectGetInteger(0,b_,OBJPROP_TIME1)));

                     hBarsH1 += MathAbs(ObjectGetDouble(0,b_,OBJPROP_PRICE1) - ObjectGetDouble(0,b_,OBJPROP_PRICE2));

                     break;

                  case 1440:

                     iBarsD1++;

                     dBarsD1 += MathAbs(iBarShift(NULL,1440,ObjectGetInteger(0,b_,OBJPROP_TIME2))-iBarShift(NULL,1440,ObjectGetInteger(0,b_,OBJPROP_TIME1)));

                     hBarsD1 += MathAbs(ObjectGetDouble(0,b_,OBJPROP_PRICE1) - ObjectGetDouble(0,b_,OBJPROP_PRICE2));

                     break;

                 }

              }

            else

              {

               switch(TF)

                 {

                  case 5:

                     iLineM5++;

                     dLineM5 += MathAbs(iBarShift(NULL,5,ObjectGetInteger(0,b_,OBJPROP_TIME2))-iBarShift(NULL,5,ObjectGetInteger(0,b_,OBJPROP_TIME1)));

                     hLineM5 += MathAbs(ObjectGetDouble(0,b_,OBJPROP_PRICE1) - ObjectGetDouble(0,b_,OBJPROP_PRICE2));

                     break;

                  case 60:

                     iLineH1++;

                     dLineH1 += MathAbs(iBarShift(NULL,60,ObjectGetInteger(0,b_,OBJPROP_TIME2))-iBarShift(NULL,60,ObjectGetInteger(0,b_,OBJPROP_TIME1)));

                     hLineH1 += MathAbs(ObjectGetDouble(0,b_,OBJPROP_PRICE1) - ObjectGetDouble(0,b_,OBJPROP_PRICE2));

                     break;

                  case 1440:

                     iLineD1++;

                     dLineD1 += MathAbs(iBarShift(NULL,1440,ObjectGetInteger(0,b_,OBJPROP_TIME2))-iBarShift(NULL,1440,ObjectGetInteger(0,b_,OBJPROP_TIME1)));

                     hLineD1 += MathAbs(ObjectGetDouble(0,b_,OBJPROP_PRICE1) - ObjectGetDouble(0,b_,OBJPROP_PRICE2));

                     break;

                 }

              }

           }

           

         RectLabelCreate( 0, "RectLabel", 0, 3, 12, 160, 115, clrSeaGreen); 

         

         hBarsM5 = MathPow(10,Digits)*((double)hBarsM5)/(iBarsM5!=0?iBarsM5:1);

         dBarsM5 = dBarsM5/(iBarsM5!=0 ? iBarsM5:1);

         hBarsH1 = MathPow(10,Digits)*((double)hBarsH1)/(iBarsH1!=0?iBarsH1:1);

         dBarsH1 = dBarsH1/(iBarsH1!=0 ? iBarsH1:1);

         hBarsD1 = MathPow(10,Digits)*((double)hBarsD1)/(iBarsD1!=0?iBarsD1:1);

         dBarsD1 = dBarsD1/(iBarsD1!=0 ? iBarsD1:1);

         hLineM5 = MathPow(10,Digits)*((double)hLineM5)/(iLineM5!=0?iLineM5:1);

         dLineM5 = dLineM5/(iLineM5!=0 ? iLineM5:1);

         hLineH1 = MathPow(10,Digits)*((double)hLineH1)/(iLineH1!=0?iLineH1:1);

         dLineH1 = dLineH1/(iLineH1!=0 ? iLineH1:1);

         hLineD1 = MathPow(10,Digits)*((double)hLineD1)/(iLineD1!=0?iLineD1:1);

         dLineD1 = dLineD1/(iLineD1!=0 ? iLineD1:1);         

         

         string comm="      Square\n   M5 "+IntegerToString(iBarsM5)+" Avr "+DoubleToString(hBarsM5,((int)(hBarsM5*10))%10!=0?1:0)+" Bar "+DoubleToString(dBarsM5,((int)(dBarsM5*10))%10!=0?1:0)+

                     "\n   H1 "+IntegerToString(iBarsH1)+" Avr "+DoubleToString(hBarsH1,((int)(hBarsH1*10))%10!=0?1:0)+" Bar "+DoubleToString(dBarsH1,((int)(dBarsH1*10))%10!=0?1:0)+

                     "\n   Daily "+IntegerToString(iBarsD1)+" Avr "+DoubleToString(hBarsD1,((int)(hBarsD1*10))%10!=0?1:0)+" Bar "+DoubleToString(dBarsD1,((int)(dBarsD1*10))%10!=0?1:0)+

                     "\n\n      Line \n   M5 "+IntegerToString(iLineM5)+" Avr "+DoubleToString(hLineM5,((int)(hLineM5*10))%10!=0?1:0)+" Bar "+DoubleToString(dLineM5,((int)(dLineM5*10))%10!=0?1:0)+

                     "\n   H1 "+IntegerToString(iLineH1)+" Avr "+DoubleToString(hLineH1,((int)(hLineH1*10))%10!=0?1:0)+" Bar "+DoubleToString(dLineH1,((int)(dLineH1*10))%10!=0?1:0)+

                     "\n   Daily "+IntegerToString(iLineD1)+" Avr "+DoubleToString(hLineD1,((int)(hLineD1*10))%10!=0?1:0)+" Bar "+DoubleToString(dLineD1,((int)(dLineD1*10))%10!=0?1:0);

                     

         Comment(comm);

        }



      if(sparam=="Ps")

        {

         ObjectSetInteger(0,"Ps",OBJPROP_STATE,false);

         ObjectDelete(0,"RectLabel");

         Comment("Start Save File");



         int file_handle=FileOpen(Symbol()+"stage.csv",FILE_WRITE|FILE_CSV);



         if(file_handle!=INVALID_HANDLE) PrintFormat("0?8AL...");  else  Alert("H81:0 >B:@KB8O.");



         int CountRectangle=0;



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

           {

            string b_=ObjectName(i);



            int type=(int) ObjectGetInteger(ChartID(),b_,OBJPROP_TYPE);



            if(!(type==OBJ_RECTANGLE || type==OBJ_TREND))continue;



            if(!(StringCompare("StageRect",StringSubstr(b_,0,9))==0

               || StringCompare("StageLine",StringSubstr(b_,0,9))==0))continue;



            CountRectangle++;



            FileWrite(file_handle,IntegerToString(CountRectangle),

                      StringSubstr(b_,StringFind(b_,"TF")+2,StringLen(b_)),

                      IntegerToString(ObjectGetInteger(0,b_,OBJPROP_TIME1)),

                      IntegerToString(ObjectGetInteger(0,b_,OBJPROP_TIME2)),

                      DoubleToString(ObjectGetDouble(0,b_,OBJPROP_PRICE1)),

                      DoubleToString(ObjectGetDouble(0,b_,OBJPROP_PRICE2)),

                      type!=OBJ_RECTANGLE?1:2);

           }



         FileClose(file_handle);

         Comment("Save File Success");

        }



      if(sparam=="Sg")

        {



        }



      if(sparam=="Vl")

        {



        }

     }



   if(id==CHARTEVENT_MOUSE_MOVE)

     {

      if(x_distance/2-120<(int)lparam && x_distance/2+120>(int)lparam && 0<(int)dparam && 40>(int)dparam)

        {

         if(ObjectFind(0,"Sc")<0)

           {

            //ButtonCreate(0,"Sc",0,int(x_distance/2)-120+15,12,29,20,"Load");

           }

         if(ObjectFind(0,"Dt")<0)

           {

            //ButtonCreate(0,"Dt",0,int(x_distance/2)-90+15,12,29,20,"Insert");

           }

         if(ObjectFind(0,"As")<0)

           {

            ButtonCreate(0,"As",0,int(x_distance/2)-60+15,12,29,20,"Load");

           }

         if(ObjectFind(0,"Sh")<0)

           {

            ButtonCreate(0,"Sh",0,int(x_distance/2)-30+15,12,29,20,"Insert");

           }

         if(ObjectFind(0,"Ps")<0)

           {

            ButtonCreate(0,"Ps",0,int(x_distance/2)+15,12,29,20,"Save");

           }

         if(ObjectFind(0,"Sg")<0)

           {

            //ButtonCreate(0,"Sg",0,int(x_distance/2)+30+15,12,29,20,"");

           }

         if(ObjectFind(0,"Vl")<0)

           {

            //ButtonCreate(0,"Vl",0,int(x_distance/2)+60+15,12,29,20,"");

           }

           } else {

         if(!(ObjectFind(0,"Sc")<0))ObjectDelete("Sc");

         if(!(ObjectFind(0,"Dt")<0))ObjectDelete("Dt");

         if(!(ObjectFind(0,"As")<0))ObjectDelete("As");

         if(!(ObjectFind(0,"Sh")<0))ObjectDelete("Sh");

         if(!(ObjectFind(0,"Ps")<0))ObjectDelete("Ps");

         if(!(ObjectFind(0,"Sg")<0))ObjectDelete("Sg");

         if(!(ObjectFind(0,"Vl")<0))ObjectDelete("Vl");

        }

     }



   if(id==CHARTEVENT_CHART_CHANGE)

     {

      if(!ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0,x_distance))

        {

         Print("5 C40;>AL ?>;CG8BL H8@8=C 3@0D8:0! >4 >H81:8 = ",GetLastError());

         return;

        }

     }

  }

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

//|                                                                  |

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

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 int               x=50,                     // :>>@48=0B0 ?> >A8 X

                  const int               y=80,                     // :>>@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 ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // C3>; 3@0D8:0 4;O ?@82O7:8

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

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

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

                  const color             back_clr=C'236,233,216',  // F25B D>=0

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

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

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

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

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

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

  {

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

//--- A>74048< :=>?:C



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

     {

      Print(__FUNCTION__,": =5 C40;>AL A>740BL :=>?:C! >4 >H81:8 = ",GetLastError()); //return(false); 

     }



   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);//--- CAB0=>28< :>>@48=0BK :=>?:8

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

//--- CAB0=>28< @07<5@ :=>?:8

   ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);

   ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);

//--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8

   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

//--- CAB0=>28< B5:AB

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

//--- CAB0=>28< H@8DB B5:AB0

   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);

//--- CAB0=>28< @07<5@ H@8DB0

   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);

//--- CAB0=>28< F25B B5:AB0

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- CAB0=>28< F25B D>=0

   ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);

//--- CAB0=>28< F25B 3@0=8FK

   ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,border_clr);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- ?5@52545< :=>?:C 2 7040==>5 A>AB>O=85

   ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O :=>?:8 <KHLN

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);



   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);//--- 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

   ObjectSet(name,OBJPROP_BORDER_TYPE,BORDER_FLAT);

   ObjectSet(name,OBJPROP_BACK,false);

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

   return(true);

  }

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

bool RectangleUpdate(const string          name="Rectangle",  // 8<O ?@O<>C3>;L=8:0

                     const color           clr=clrRed,        // F25B ?@O<>C3>;L=8:0

                     const ENUM_LINE_STYLE style=STYLE_SOLID, // AB8;L ;8=89 ?@O<>C3>;L=8:0

                     const int             width=1,           // B>;I8=0 ;8=89 ?@O<>C3>;L=8:0

                     const bool            fill=false,        // 70;82:0 ?@O<>C3>;L=8:0 F25B><

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

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

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

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

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

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

  {



//--- CAB0=>28< F25B ?@O<>C3>;L=8:0

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- CAB0=>28< AB8;L ;8=89 ?@O<>C3>;L=8:0

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);

//--- CAB0=>28< B>;I8=C ;8=89 ?@O<>C3>;L=8:0

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< 70;82:8 ?@O<>C3>;L=8:0

   ObjectSetInteger(chart_ID,name,OBJPROP_FILL,fill);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< 2K45;5=8O ?@O<>C3>;L=8:0 4;O ?5@5<5I5=89

//--- ?@8 A>740=88 3@0D8G5A:>3> >1J5:B0 DC=:F859 ObjectCreate, ?> C<>;G0=8N >1J5:B

//--- =5;L7O 2K45;8BL 8 ?5@5<5I0BL. =CB@8 65 MB>3> <5B>40 ?0@0<5B@ selection

//--- ?> C<>;G0=8N @025= true, GB> ?>72>;O5B 2K45;OBL 8 ?5@5<5I0BL MB>B >1J5:B

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,true);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

//--- 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_HIDDEN,hidden);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

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

   return(true);

  }

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

//|                                                                  |

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

bool RectangleCreate(const string          name="Rectangle",  // 8<O ?@O<>C3>;L=8:0

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

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

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

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

                     const color           clr=clrRed,        // F25B ?@O<>C3>;L=8:0

                     const ENUM_LINE_STYLE style=STYLE_SOLID, // AB8;L ;8=89 ?@O<>C3>;L=8:0

                     const int             width=1,           // B>;I8=0 ;8=89 ?@O<>C3>;L=8:0

                     const bool            fill=false,        // 70;82:0 ?@O<>C3>;L=8:0 F25B><

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

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

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

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

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

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

  {



//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

//--- A>74048< ?@O<>C3>;L=8: ?> 7040==K< :>>@48=0B0<

   if(!ObjectCreate(chart_ID,name,OBJ_RECTANGLE,sub_window,time1,price1,time2,price2)){}

//     {

//      Print(__FUNCTION__,

//            ": =5 C40;>AL A>740BL ?@O<>C3>;L=8:! >4 >H81:8 = ",GetLastError());

//      return(false);

//     }

//--- CAB0=>28< F25B ?@O<>C3>;L=8:0

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- CAB0=>28< AB8;L ;8=89 ?@O<>C3>;L=8:0

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);

//--- CAB0=>28< B>;I8=C ;8=89 ?@O<>C3>;L=8:0

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< 70;82:8 ?@O<>C3>;L=8:0

   ObjectSetInteger(chart_ID,name,OBJPROP_FILL,fill);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< 2K45;5=8O ?@O<>C3>;L=8:0 4;O ?5@5<5I5=89

//--- ?@8 A>740=88 3@0D8G5A:>3> >1J5:B0 DC=:F859 ObjectCreate, ?> C<>;G0=8N >1J5:B

//--- =5;L7O 2K45;8BL 8 ?5@5<5I0BL. =CB@8 65 MB>3> <5B>40 ?0@0<5B@ selection

//--- ?> C<>;G0=8N @025= true, GB> ?>72>;O5B 2K45;OBL 8 ?5@5<5I0BL MB>B >1J5:B

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,true);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

//--- 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_HIDDEN,hidden);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

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

   return(true);

  }

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

//|                                                                  |

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

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

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

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

                double                price1=0,          // F5=0 ?5@2>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=false,// 2K45;8BL 4;O ?5@5<5I5=89

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

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

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

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

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

  {

   ResetLastError();

//--- A>74048< B@5=4>2CN ;8=8N ?> 7040==K< :>>@48=0B0<

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

     {



     }

//--- CAB0=>28< F25B ;8=88

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- CAB0=>28< AB8;L >B>1@065=8O ;8=88

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);

//--- CAB0=>28< B>;I8=C ;8=88

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O ;8=88 <KHLN

//--- ?@8 A>740=88 3@0D8G5A:>3> >1J5:B0 DC=:F859 ObjectCreate, ?> C<>;G0=8N >1J5:B

//--- =5;L7O 2K45;8BL 8 ?5@5<5I0BL. =CB@8 65 MB>3> <5B>40 ?0@0<5B@ selection

//--- ?> C<>;G0=8N @025= true, GB> ?>72>;O5B 2K45;OBL 8 ?5@5<5I0BL MB>B >1J5:B

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,true);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

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

   ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,ray_right);

//--- 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_HIDDEN,hidden);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

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

   return(true);

  }

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

//|                                                                  |

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

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

                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=false,// 2K45;8BL 4;O ?5@5<5I5=89

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

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

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

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

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

  {



   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- CAB0=>28< AB8;L >B>1@065=8O ;8=88

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);

//--- CAB0=>28< B>;I8=C ;8=88

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O ;8=88 <KHLN

//--- ?@8 A>740=88 3@0D8G5A:>3> >1J5:B0 DC=:F859 ObjectCreate, ?> C<>;G0=8N >1J5:B

//--- =5;L7O 2K45;8BL 8 ?5@5<5I0BL. =CB@8 65 MB>3> <5B>40 ?0@0<5B@ selection

//--- ?> C<>;G0=8N @025= true, GB> ?>72>;O5B 2K45;OBL 8 ?5@5<5I0BL MB>B >1J5:B

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,true);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

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

   ObjectSetInteger(chart_ID,name,OBJPROP_RAY_RIGHT,ray_right);

//--- 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_HIDDEN,hidden);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

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

   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 int              x=0,                      // :>>@48=0B0 ?> >A8 X

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

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

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

                     const color            back_clr=C'236,233,216',  // F25B D>=0

                     const ENUM_BORDER_TYPE border=BORDER_SUNKEN,     // B8? 3@0=8FK

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

                     const color            clr=clrRed,               // 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

  {

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

//--- A>74048< ?@O<>C3>;L=CN <5B:C

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

     {

      Print(__FUNCTION__,

            ": =5 C40;>AL A>740BL ?@O<>C3>;L=CN <5B:C! >4 >H81:8 = ",GetLastError());

      return(false);

     }

//--- CAB0=>28< :>>@48=0BK <5B:8

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

//--- CAB0=>28< @07<5@K <5B:8

   ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);

   ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);

//--- CAB0=>28< F25B D>=0

   ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);

//--- CAB0=>28< B8? 3@0=8FK

   ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_TYPE,border);

//--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8

   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

//--- CAB0=>28< F25B ?;>A:>9 @0<:8 (2 @568<5 Flat)

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- CAB0=>28< AB8;L ;8=88 ?;>A:>9 @0<:8

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);

//--- CAB0=>28< B>;I8=C ?;>A:>9 3@0=8FK

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,line_width);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O <5B:8 <KHLN

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

//--- 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_HIDDEN,hidden);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

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

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