Author: Roman.
0 Views
0 Downloads
0 Favorites
Pro Box 5
ÿþ//+------------------------------------------------------------------+

//|                                                     Futprint.mq4 |

//|                        Copyright 2018, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

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

#property strict

#property version     "1.0"

#property copyright   "Roman."



#property description "If you like the indicator, you can thank the author"

#property description "Webmoney: Z330494414179, R222585888867"

#property description " "

#property description "Thank you very much."

#property indicator_chart_window



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

//| Custom indicator initialization function                         |

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

enum PColor

  {

   C1=0, // Mono Color

   C2=1  // Gauss Bell Color

  };



enum enum_bUp

  {

   U1=1, // Draw on Back

   U2=2  // Hide on Top

  };



extern string ID_Chart="Box";//Indicator unique ID



extern enum_bUp bUp = U1; //Draw on Top/Back

extern string KeyTop="A";  //Key Change Draw Top/Back



extern PColor Color = C2;  //Color Scheme

extern string KeyRoll="Q";  //Key Change Color Scheme



extern color MainClr = clrTomato;  //Mono/Gauss 68 % Color

extern color Rate1 = clrYellow;   //Gauss 95 % Color

extern color Rate2 = clrAqua;   //Over 5 % Color



extern color POCClr = clrGreen;  //POC Color

extern ENUM_LINE_STYLE  POC     =  STYLE_SOLID;//POC Style

extern color Line25Clr = clrMagenta;   //2.5 % Color

extern ENUM_LINE_STYLE  Line25     =  STYLE_DOT;//2.5 % Style

extern color Line87Clr = clrGold;   //16 % Color

extern ENUM_LINE_STYLE  Line87     =  STYLE_DASHDOT; //16 % Style



extern int Percent = 80; //Length as Percentage of Box



extern string KeyFix="Z"; //Key Change Fix 1:1



extern string HShowLevels="W"; //On/Off Extend Line

extern bool bHShowLevels=true; //Extend Line



extern int div = 10;//Tick Per Row



input color ColorPointerLines=clrBrown;            //Color Pointer Lines

input color ColorBox  = clrGreen;                  //Color Box



input color ColorText   = clrBlack;                //Color Button Text

input color ColorBack   = clrYellow;               //Color Button Back

input color ColorBorder = clrMagenta;                 //Color Button Border







int Box[], DrawHigh[];

string NameBox[];

double doubleStartBox[], doubleEndBox[];

datetime dtStartBox[], dtEndBox[];



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

//|                                                                  |

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

void Draw()

  {

   bool ReDrawFlage = false;

   int intObjTotal=ObjectsTotal(), subIndex = ArraySize(NameBox), ind;



   double H[], L[], F[];

   long V[];

   string Redraw[];



   ArrayFree(Redraw);



   for(ind = 0; ind < subIndex; ind ++)

      if(ObjectGetInteger(0,"Button2" + NameBox[ind],OBJPROP_STATE))

        {

         ReDrawFlage = true;

         ObjectDelete(0,"Button" + NameBox[ind]);

         ObjectDelete(0,"Button2" + NameBox[ind]);

         ObjectDelete(0,"Button3" + NameBox[ind]);

         ObjectDelete(0,NameBox[ind]);

        }



   for(ind = 0; ind < subIndex; ind ++)

      if(ObjectFind(0,NameBox[ind])<0)

        {

         ReDrawFlage = true;

         ObjectDelete(0,"Button" + NameBox[ind]);

         ObjectDelete(0,"Button2" + NameBox[ind]);

         ObjectDelete(0,"Button3" + NameBox[ind]);

        }



   string St = ID_Chart+" Rect ";



   if(!ReDrawFlage)

      for(ind = 0; ind < intObjTotal; ind ++)

        {

         string stName = ObjectName(ind);



         if(ObjectGetInteger(0,stName,OBJPROP_TYPE)!=OBJ_RECTANGLE||StringFind(stName,St)<0)

            continue;



         if(ArraySize(NameBox) < 1)

           {

            ReDrawFlage = true;

            break;

           }



         ReDrawFlage = true;



         for(subIndex = 0; subIndex < ArraySize(NameBox); subIndex++)

           {

            if(NameBox[subIndex] == stName)

              {

               ReDrawFlage = false;

               break;

              }

           }



         ReDrawFlage=(ObjectFind(0,"Button" + stName)>-1)?((bool)ObjectGetInteger(0,"Button" + stName,OBJPROP_STATE)):ReDrawFlage;

         if(ReDrawFlage)

            break;

         ReDrawFlage= ((!(ObjectFind(0,"RectLabel"+ID_Chart + "_" + stName + "_0")>-1))              //ABL 8;8 =5B : 5B

                       &&

                       (ObjectFind(0,"Button" + stName)>-1))

                      ?

                      (!(bool)ObjectGetInteger(0,"Button" + stName,OBJPROP_STATE)):ReDrawFlage;



         if(ReDrawFlage)

            break;



         if(dtStartBox[subIndex]!=ObjectGetInteger(0,NameBox[subIndex],OBJPROP_TIME1)||

            dtEndBox[subIndex]!=ObjectGetInteger(0,NameBox[subIndex],OBJPROP_TIME2)||

            doubleStartBox[subIndex]!=ObjectGetDouble(0,NameBox[subIndex],OBJPROP_PRICE1)||

            doubleEndBox[subIndex]!=ObjectGetDouble(0,NameBox[subIndex],OBJPROP_PRICE2)||

            (MathMin(dtStartBox[subIndex], dtEndBox[subIndex])<Time[0] && MathMax(dtStartBox[subIndex], dtEndBox[subIndex])>Time[0]))

           {

            ArrayResize(Redraw,ArraySize(Redraw)+1);

            Redraw[ArraySize(Redraw)-1] = stName;

            dtStartBox[subIndex]=(datetime)ObjectGetInteger(0,NameBox[subIndex],OBJPROP_TIME1);

            dtEndBox[subIndex]=(datetime)ObjectGetInteger(0,NameBox[subIndex],OBJPROP_TIME2);

            doubleStartBox[subIndex]=ObjectGetDouble(0,NameBox[subIndex],OBJPROP_PRICE1);

            doubleEndBox[subIndex]=ObjectGetDouble(0,NameBox[subIndex],OBJPROP_PRICE2);

           }

        }



   int StartVisibleBar = ChartFirstVisibleBar(), CountVisibleBars = ChartVisibleBars(), EndVisibleBar = StartVisibleBar-CountVisibleBars;

   EndVisibleBar = (EndVisibleBar < 0) ? 0: EndVisibleBar;



   datetime StartVisibleTime = Time[StartVisibleBar], EndVisibleTime = Time[EndVisibleBar];

   subIndex = ArraySize(DrawHigh);



   if(subIndex == 0 || (!(subIndex == CountVisibleBars|| subIndex == CountVisibleBars + 1)))

      ReDrawFlage = true;

   else

     {

      subIndex = -1;

      for(ind = StartVisibleBar; ind >= EndVisibleBar; ind --)

        {

         int x,y;

         subIndex++;

         ChartTimePriceToXY(0,0,Time[ind],High[ind],y,x);

         if(DrawHigh[subIndex] != x)

           {

            ReDrawFlage = true;

            break;

           }

        }

     }



   if(ReDrawFlage)

     {

      //#40;O5< 2A5

      ObjectsDeleteAll(0,"RectLabel"+ID_Chart);

      ArrayFree(DrawHigh);

      for(ind = StartVisibleBar; ind >= EndVisibleBar; ind --)

        {

         int x,y;

         ArrayResize(DrawHigh,ArraySize(DrawHigh)+1);

         ChartTimePriceToXY(0,0,Time[ind],High[ind],y,x);

         DrawHigh[ArraySize(DrawHigh)-1]=x;

        }

     }



   if(ReDrawFlage)

     {

      ArrayFree(NameBox);

      ArrayFree(dtStartBox);

      ArrayFree(dtEndBox);

      ArrayFree(doubleStartBox);

      ArrayFree(doubleEndBox);

      ArrayFree(Redraw);

      for(ind = 0; ind < intObjTotal; ind ++)

        {

         string stName = ObjectName(ind);

         if(ObjectGetInteger(0,stName,OBJPROP_TYPE)!=OBJ_RECTANGLE||StringFind(stName,St)<0)

            continue;

         ArrayResize(NameBox,ArraySize(NameBox)+1);

         ArrayResize(dtStartBox,ArraySize(dtStartBox)+1);

         ArrayResize(dtEndBox,ArraySize(dtEndBox)+1);

         ArrayResize(doubleStartBox,ArraySize(doubleStartBox)+1);

         ArrayResize(doubleEndBox,ArraySize(doubleEndBox)+1);

         ArrayResize(Redraw,ArraySize(Redraw)+1);

         NameBox[ArraySize(NameBox)-1] = Redraw[ArraySize(Redraw)-1] = stName;

         dtStartBox[ArraySize(dtStartBox)-1]=(datetime)ObjectGetInteger(0,stName,OBJPROP_TIME1);

         dtEndBox[ArraySize(dtEndBox)-1]=(datetime)ObjectGetInteger(0,stName,OBJPROP_TIME2);

         doubleStartBox[ArraySize(doubleStartBox)-1]=ObjectGetDouble(0,stName,OBJPROP_PRICE1);

         doubleEndBox[ArraySize(doubleEndBox)-1]=ObjectGetDouble(0,stName,OBJPROP_PRICE2);

        }

     }



   ulong  star = GetMicrosecondCount(), ulong_ = 200 * 800;

   subIndex = ArraySize(Redraw);



   for(ind = 0; ind < subIndex ; ind ++)

     {

      datetime Start = (datetime)MathMin(ObjectGetInteger(0, Redraw[ind], OBJPROP_TIME1),ObjectGetInteger(0, Redraw[ind], OBJPROP_TIME2)),

               End = (datetime)MathMax(ObjectGetInteger(0, Redraw[ind], OBJPROP_TIME1),ObjectGetInteger(0, Redraw[ind], OBJPROP_TIME2));



      double Up =  MathMax(ObjectGetDouble(0, Redraw[ind], OBJPROP_PRICE1),ObjectGetDouble(0, Redraw[ind], OBJPROP_PRICE2));



      int x, y, w, dy;



      ChartTimePriceToXY(0,0,End,Up,x,y);



      ButtonCreate(0, "Button" + Redraw[ind], 0, x-15 - 18, y-15, 15, 10, CORNER_LEFT_UPPER,"Dr","Arial",6,ColorText,ColorBack,ColorBorder);             // ?@8>@8B5B =0 =060B85 <KHLN

      ButtonCreate(0, "Button2" + Redraw[ind], 0, x - 15, y-15, 15, 10, CORNER_LEFT_UPPER,"Cl","Arial",6,ColorText,ColorBack,ColorBorder);             // ?@8>@8B5B =0 =060B85 <KHLN

      ButtonCreate(0, "Button3" + Redraw[ind], 0, x - 15 - 36, y-15, 15, 10, CORNER_LEFT_UPPER,"Ah","Arial",6,ColorText,ColorBack,ColorBorder);             // ?@8>@8B5B =0 =060B85 <KHLN



      if(ObjectGetInteger(0, "Button" + Redraw[ind], OBJPROP_STATE) && ObjectGetInteger(0, "Button3" + Redraw[ind], OBJPROP_STATE))

        {

         //#40;O5< 5A;8 2AQ 2<5AB5.

         ObjectsDeleteAll(0,"RectLabel"+ID_Chart + "_" + Redraw[ind]);

         ObjectsDeleteAll(0,"RectLabel"+ID_Chart + "_Line" + Redraw[ind]);

         continue;

        }



      if(ObjectGetInteger(0, "Button" + Redraw[ind], OBJPROP_STATE))

        {

         //#40;O5< 5A;8 2AQ 2<5AB5.

         ObjectsDeleteAll(0,"RectLabel"+ID_Chart + "_" + Redraw[ind]);

        }



      if(ObjectGetInteger(0, "Button3" + Redraw[ind], OBJPROP_STATE))

        {

         //#40;O5< 5A;8 2AQ 2<5AB5.

         ObjectsDeleteAll(0,"RectLabel"+ID_Chart + "_Line" + Redraw[ind]);

        }





      if(ulong_ < GetMicrosecondCount() - star)

         return;



      if(CopyTickVolume(_Symbol, PERIOD_M1, Start, End + PeriodSeconds() - 1, V) <= 0 ||

         CopyHigh(_Symbol, PERIOD_M1, Start, End + PeriodSeconds() - 1, H) <= 0 ||

         CopyLow(_Symbol, PERIOD_M1, Start, End + PeriodSeconds() - 1, L) <= 0)

         continue;



      ArrayFree(F);



      double  Min = MathMin(ObjectGetDouble(0, Redraw[ind], OBJPROP_PRICE1),ObjectGetDouble(0, Redraw[ind], OBJPROP_PRICE2)),

              Max = MathMax(ObjectGetDouble(0, Redraw[ind], OBJPROP_PRICE1),ObjectGetDouble(0, Redraw[ind], OBJPROP_PRICE2)),

              TMin = Min - Point*((int)(Min/Point)%(int)div);



      ArrayResize(F,(int)((Max-TMin)/(Point*div))+1);



      int iArraySize = ArraySize(V);

      int Size = ArraySize(F);



      for(int j = 0; j < iArraySize; j ++)

        {

         if(H[j]!=L[j])

           {

            double tmp = (H[j]-L[j])/Point, g = V[j]/tmp;

            for(int k = 0; k < (int)tmp; k++)

              {

               int Nubmer = (int)((L[j]+Point*k-TMin)/(Point*div));

               if(Nubmer < Size && Nubmer >= 0)

                  F[Nubmer] += g;

              }

           }

         else

           {

            int Nubmer= (int)((L[j]-TMin)/(Point*div));

            if(Nubmer < Size && Nubmer >= 0)

               F[Nubmer] += (double)V[j];

           }

        }



      ChartTimePriceToXY(0,0,Start,TMin,x,y);

      ChartTimePriceToXY(0,0,End,TMin+Point*div,w,dy);



      int t = MathAbs(y-dy), dt=t<0?0:t>3?t-2:t;



      double MaxV =  F[ArrayMaximum(F)];



      if(MaxV<1)

         continue;



      w = MathAbs(w-x);



      MaxV = w > 12? (w-3) / MaxV: w / MaxV;

      MaxV = (MaxV * Percent) / 100.0;



      iArraySize = ArraySize(F);

      double PrevSumm = 0, SummValue = 0, Line = 0, MaxVal=INT_MIN;

      int RectLine = -1, MaxEl = 0;



      for(int j = 0; j < iArraySize; j ++)

        {

         if(MaxVal<F[j])

           {

            MaxVal = F[j];

            MaxEl = j;

           }

         SummValue+=F[j];

        }

      ObjectsDeleteAll(0,"RectLabel"+ID_Chart + "_" + Redraw[ind]);



      for(int j = 0; j < iArraySize; j ++)

        {

         int Horizontal= (int)(MaxV * F[j]);

         if(Horizontal==0)

            continue;

         ChartTimePriceToXY(0, 0, Start, TMin + Point * j * div, x, y);



         if(!ObjectGetInteger(0, "Button" + Redraw[ind], OBJPROP_STATE))

           {

            string name = "RectLabel"+ID_Chart + "_" + Redraw[ind] + "_" + IntegerToString(j);

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

            ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);

            ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y - t);

            ObjectSetInteger(0,name,OBJPROP_XSIZE,Horizontal);

            ObjectSetInteger(0,name,OBJPROP_YSIZE,3+dt);

            ObjectSetInteger(0,name,OBJPROP_WIDTH,0);

            ObjectSetInteger(0,name,OBJPROP_BACK,bUp!=U2?true:false);



            switch(Color)

              {

               case C1:

                  ObjectSetInteger(0,name,OBJPROP_BGCOLOR,MainClr);

                  break;

               case C2:

                  PrevSumm += F[j];

                  if(PrevSumm / SummValue < 0.025f || PrevSumm / SummValue > 0.975f)

                     ObjectSetInteger(0,name,OBJPROP_BGCOLOR,Rate2);

                  else

                    {

                     if(PrevSumm / SummValue < 0.16f  || PrevSumm / SummValue > 0.84f)

                        ObjectSetInteger(0,name,OBJPROP_BGCOLOR,Rate1);

                     else

                        ObjectSetInteger(0,name,OBJPROP_BGCOLOR,MainClr);

                    }

                  break;

              }

           }

         if(!ObjectGetInteger(0, "Button3" + Redraw[ind], OBJPROP_STATE))

           {

            Line+=F[j];

            string name = "RectLabel"+ID_Chart + "_Line" + Redraw[ind] + "_";

            switch(RectLine)

              {

               case -1:

                  DrawLine(name+"POC",Start,TMin + Point * MaxEl * div,End);

                  ObjectCreate(name+"POC",OBJ_HLINE,0,Start,TMin + Point * MaxEl * div);

                  ObjectSetInteger(0,name+"POC",OBJPROP_COLOR,POCClr);

                  ObjectSetInteger(0,name+"POC",OBJPROP_STYLE,POC);

                  RectLine = 0;

               case 0:

                  if(Line / SummValue > 0.025f)

                    {

                     DrawLine(name+"25",Start,TMin + Point * j * div,End);

                     ObjectCreate(name+"25",OBJ_HLINE,0,Start,TMin + Point * j * div);

                     ObjectSetInteger(0,name+"25",OBJPROP_COLOR,Line25Clr);

                     ObjectSetInteger(0,name+"25",OBJPROP_STYLE,Line25);

                     RectLine = 1;

                    }

                  break;

               case 1:

                  if(Line / SummValue > 0.16f)

                    {

                     DrawLine(name+"16",Start,TMin + Point * j * div,End);

                     ObjectCreate(name+"16",OBJ_HLINE,0,Start,TMin + Point * j * div);

                     ObjectSetInteger(0,name+"16",OBJPROP_COLOR,Line87Clr);

                     ObjectSetInteger(0,name+"16",OBJPROP_STYLE,Line87);

                     RectLine = 2;

                    }

                  break;

               case 2:

                  if(Line / SummValue > 0.84f)

                    {

                     DrawLine(name+"84",Start,TMin + Point * j * div,End);

                     ObjectSetInteger(0,name+"84",OBJPROP_COLOR,Line87Clr);

                     ObjectSetInteger(0,name+"84",OBJPROP_STYLE,Line87);

                     RectLine = 3;

                    }

                  break;

               case 3:

                  if(Line / SummValue > 0.975f)

                    {

                     DrawLine(name+"975",Start,TMin + Point * j * div,End);

                     ObjectSetInteger(0,name+"975",OBJPROP_COLOR,Line25Clr);

                     ObjectSetInteger(0,name+"975",OBJPROP_STYLE,Line25);

                     RectLine = 4;

                    }

                  break;

              }

           }

        }

     }

  }









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

//|                                                                  |

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

void DrawLine(string name,datetime Start,double L,datetime End)

  {

   if(bHShowLevels)

     {

      ObjectCreate(name,OBJ_TREND,0,Start,L,End,L);

     }

   else

     {

      ObjectCreate(name,OBJ_HLINE,0,Start,L);

     }

     ObjectSetString(0,name,OBJPROP_TOOLTIP,"Level is\n"+DoubleToString(L,Digits));

     ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);

     ObjectSetInteger(0,name,OBJPROP_SELECTED,false);

  }



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

//|                                                                  |

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

void OnTimer()

  {

   Draw();

  }

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

//|                                                                  |

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

int StartDraw;

int OnInit()

  {

//--- indicator buffers mapping

   StartDraw=0;

   EventSetMillisecondTimer(200);

   ChartSetInteger(0,CHART_EVENT_MOUSE_MOVE,true);

//---

   return(INIT_SUCCEEDED);

  }



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

//|                                                                  |

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

void OnDeinit(const int reason)

  {

   EventKillTimer();

   ObjectsDeleteAll(0,"RectLabel"+ID_Chart);

  }

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

//| 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[])

  {

//---

   Draw();

//--- return value of prev_calculated for next call

   return(rates_total);

  }

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

//| $C=:F8O ?>;CG05B =><5@ ?5@2>3> 2848<>3> 10@0 =0 3@0D8:5.         |

//| =45:A0F8O :0: 2 B09<A5@88, ?>A;54=85 10@K 8<5NB <5=LH85 8=45:AK.|

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

int ChartFirstVisibleBar(const long chart_ID=0)

  {

//--- ?>43>B>28< ?5@5<5==CN 4;O ?>;CG5=8O 7=0G5=8O A2>9AB20

   long result=-1;

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

   ResetLastError();

//--- ?>;CG8< 7=0G5=85 A2>9AB20

   if(!ChartGetInteger(chart_ID,CHART_FIRST_VISIBLE_BAR,0,result))

     {

      //--- 2K2545< A>>1I5=85 >1 >H81:5 2 6C@=0; "-:A?5@BK"

      Print(__FUNCTION__+", Error Code = ",GetLastError());

     }

//--- 25@=5< 7=0G5=85 A2>9AB20 3@0D8:0

   return((int)result);

  }

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

//| $C=:F8O ?>;CG05B :>;8G5AB2> 10@>2, :>B>@K5 >B>1@060NBAO (2848<K )|

//| 2 >:=5 3@0D8:0.                                                  |

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

int ChartVisibleBars(const long chart_ID=0)

  {

//--- ?>43>B>28< ?5@5<5==CN 4;O ?>;CG5=8O 7=0G5=8O A2>9AB20

   long result=-1;

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

   ResetLastError();

//--- ?>;CG8< 7=0G5=85 A2>9AB20

   if(!ChartGetInteger(chart_ID,CHART_VISIBLE_BARS,0,result))

     {

      //--- 2K2545< A>>1I5=85 >1 >H81:5 2 6C@=0; "-:A?5@BK"

      Print(__FUNCTION__+", Error Code = ",GetLastError());

     }

//--- 25@=5< 7=0G5=85 A2>9AB20 3@0D8:0

   return((int)result);

  }

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

bool ChartScaleFix11Get(bool &result,const long chart_ID=0)

  {

//--- ?>43>B>28< ?5@5<5==CN 4;O ?>;CG5=8O 7=0G5=8O A2>9AB20

   long value;

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

   ResetLastError();

//--- ?>;CG8< 7=0G5=85 A2>9AB20

   if(!ChartGetInteger(chart_ID,CHART_SCALEFIX,0,value))

     {

      //--- 2K2545< A>>1I5=85 >1 >H81:5 2 6C@=0; "-:A?5@BK"

      Print(__FUNCTION__+", Error Code = ",GetLastError());

      return(false);

     }

//--- 70?><=8< 2 ?5@5<5==CN 7=0G5=85 A2>9AB20 3@0D8:0

   result=value;

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

   return(true);

  }

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

//| $C=:F8O 2:;NG05B/2K:;NG05B @568< <0AHB010 "1:1"                  |

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

bool ChartScaleFix11Set(const bool value,const long chart_ID=0)

  {

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

   ResetLastError();

//--- CAB0=>28< 7=0G5=85 A2>9AB20

   if(!ChartSetInteger(chart_ID,CHART_SCALEFIX,0,value))

     {

      //--- 2K2545< A>>1I5=85 >1 >H81:5 2 6C@=0; "-:A?5@BK"

      Print(__FUNCTION__+", Error Code = ",GetLastError());

      return(false);

     }

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

   return(true);

  }

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

int u = 0, kd = 1;

ulong ui;

double lprice;

datetime ltime;



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

//|                                                                  |

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

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

  {

   if(id==CHARTEVENT_MOUSE_MOVE)

     {

      int xlast=(int)lparam, ylast=(int)dparam;

      if(StartDraw>1)

        {

         datetime dt=0;

         double   price=0;

         int x=(int)lparam;

         int y=(int)dparam;

         int window=0;

         if(ChartXYToTimePrice(0,x,y,window,dt,price))

           {

            ObjectDelete(0,ID_Chart+" R Line");

            ObjectCreate(0,ID_Chart+" R Line",OBJ_HLINE,window,dt,price);

            ObjectSetInteger(0,ID_Chart+" R Line",OBJPROP_COLOR,ColorPointerLines);

            ObjectSetString(0,ID_Chart+" R Line",OBJPROP_TOOLTIP,DoubleToString(price,Digits));

            ObjectSetInteger(0,ID_Chart+" R Line",OBJPROP_SELECTABLE,false);

            ObjectSetInteger(0,ID_Chart+" R Line",OBJPROP_SELECTED,false);

            ObjectSetInteger(0,ID_Chart+" R Line",OBJPROP_STYLE,STYLE_DOT);

            ObjectDelete(0,ID_Chart+" P Line");

            ObjectCreate(0,ID_Chart+" P Line",OBJ_VLINE,window,dt,price);

            ObjectSetInteger(0,ID_Chart+" P Line",OBJPROP_COLOR,ColorPointerLines);

            ObjectSetString(0,ID_Chart+" P Line",OBJPROP_TOOLTIP,DoubleToString(price,Digits));

            ObjectSetInteger(0,ID_Chart+" P Line",OBJPROP_SELECTED,false);

            ObjectSetInteger(0,ID_Chart+" P Line",OBJPROP_STYLE,STYLE_DOT);

            ObjectDelete(0, ID_Chart+" Rect "+(string)kd);

            RectangleCreate(0, ID_Chart+" Rect "+(string)kd, 0, ltime, lprice, dt, price,ColorBox);

           }

        }

     }



   if(id==CHARTEVENT_CLICK)

     {

      if(StartDraw>1)

        {

         StartDraw=0;

         ObjectDelete(0,ID_Chart+" R Line");

         ObjectDelete(0,ID_Chart+" P Line");

         ObjectDelete(0,ID_Chart+" H Line");

         ObjectDelete(0,ID_Chart+" V Line");

         kd ++;

         return;

        }



      u++;

      if(!(GetMicrosecondCount() - 400000 < ui))

         u = 1;



      if(u == 1)

        {

         ui = GetMicrosecondCount();

         return;

        }



      if(u < 2)

         return;



      u = 0;



      datetime dt=0;

      double   price=0;

      int window=0;

      if(ChartXYToTimePrice(0,(int)lparam,(int)dparam,window,dt,price))

        {

         ObjectDelete(0,ID_Chart+" H Line");

         ObjectDelete(0,ID_Chart+" V Line");

         ObjectCreate(0,ID_Chart+" H Line",OBJ_HLINE,window,dt,price);

         ObjectCreate(0,ID_Chart+" V Line",OBJ_VLINE,window,dt,price);

         ObjectSetInteger(0,ID_Chart+" V Line",OBJPROP_COLOR,ColorPointerLines);

         ObjectSetString(0,ID_Chart+" V Line",OBJPROP_TOOLTIP,DoubleToString(price,Digits));

         ObjectSetInteger(0,ID_Chart+" V Line",OBJPROP_SELECTED,false);

         ObjectSetInteger(0,ID_Chart+" V Line",OBJPROP_STYLE,STYLE_DOT);

         ObjectSetInteger(0,ID_Chart+" H Line",OBJPROP_COLOR,ColorPointerLines);

         ObjectSetString(0,ID_Chart+" H Line",OBJPROP_TOOLTIP,DoubleToString(price,Digits));

         ObjectSetInteger(0,ID_Chart+" H Line",OBJPROP_SELECTED,false);

         ObjectSetInteger(0,ID_Chart+" H Line",OBJPROP_STYLE,STYLE_DOT);

         ChartRedraw(0);

         StartDraw=2;

         lprice=price;

         ltime=dt;

        }

     }



   if(id==CHARTEVENT_OBJECT_CLICK)

     {

      u = 0;

     }



   if(id==CHARTEVENT_KEYDOWN)

     {

      if((int)lparam==StringGetChar(KeyRoll,0))

        {

         switch(Color)

           {

            case C1:

               Color = C2;

               break;

            case C2:

               Color = C1;

               break;

           };

         ArrayFree(NameBox);

         Draw();

        }

      if((int)lparam==StringGetChar(HShowLevels,0))

        {

         bHShowLevels=!bHShowLevels;

         ArrayFree(NameBox);

         Draw();

        }

      if((int)lparam==StringGetChar(KeyTop,0))

        {

         bUp=bUp!=U1?U1:U2;

         ArrayFree(NameBox);

         Draw();

        }

      if((int)lparam==StringGetChar(KeyFix,0))

        {

         bool tmp;

         ChartScaleFix11Get(tmp);

         ChartScaleFix11Set(!tmp);

         ArrayFree(NameBox);

         Draw();

        }

     }

  }



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

bool RectangleCreate(const long            chart_ID=0,

                     const string          name="Rectangle",

                     const int             sub_window=0,

                     datetime              time1=0,

                     double                price1=0,

                     datetime              time2=0,

                     double                price2=0,

                     const color           clr=clrAliceBlue,

                     const bool            fill=false,

                     const ENUM_LINE_STYLE style=STYLE_DOT,

                     const int             width=0,

                     const bool            back=false,

                     const bool            selection=false,

                     const bool            hidden=true,

                     const long            z_order=0)

  {

   ResetLastError();

   if(ObjectFind(name)==-1)

      ObjectCreate(chart_ID,name,OBJ_RECTANGLE,sub_window,time1,price1,time2,price2);

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

   ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,clr);

   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);

   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);

   ObjectSetInteger(chart_ID,name,OBJPROP_FILL,fill);

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,true);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

   return(true);

  }

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

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

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

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

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

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

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

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

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

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

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

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

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

                  const bool              back=true,                // =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< :=>?:C

   if(!ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0)) {};

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

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

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



   ObjectSet(name,OBJPROP_BORDER_TYPE,BORDER_FLAT);



//--- 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);

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