I would like a button that moves along a horizontal line below the price high and low, to choose to hide it or see it .I have attached code MQL5 indicator

 

I'd like a button that moves along a horizontal line below the price high and low, to choose to hide it or see it,

but if you can I'm happy to put it on the chart above.

I'm learning as a hobby MQL5

Then I'd hide a button with only the description of the line and not the whole chart

I enclose MQL5 indicators

thanks if you give me some advice

frank

//------code Indicator MQL5 FRanco------------

/*

I'd like a button that moves along a horizontal line below the price high and low, to choose to hide it or see it,

but if you can I'm happy to put it on the chart above.

I'm learning as a hobby MQL5

Then I'd hide a button with only the description of the line and not the whole chart

I enclose MQL5 indicators

thanks if you give me some advice

frank

*/





#property copyright "Franco from Italy Taormina"

#property link "https://www.mql5.com/en/users/antgio51"

#property description "io"



//---- indicator version number

#property version   "1.00"

//---- drawing the indicator in the main window

#property indicator_chart_window



#include <GetFontName.mqh>



input bool            Show_DESCRIZIONI=false; 

input string I1______________________________="______________________________";

input bool            Show_Current=true;

 input bool            Notes=true;





input string I3______________________________="______________________________";





type_font FontType=Font10; 



input ENUM_LINE_STYLE  mml_style_m_1_8 = STYLE_DASHDOTDOT; // Style_Linea_Typo_1



input color  mml_clr_0_8   = Aqua;       // Linea_Corrent



MqlRates mrate[]; 

 bool            InpBack1=false;       // Background line

 bool            InpSelection1=true;   // Highlight to move

 bool            InpHidden1=true;      // Hidden in the object list

 long            InpZOrder1=0;         // Priority for mouse click 

 



 ENUM_LINE_STYLE InpStyle2=STYLE_DASH; // Line style

 int             InpWidth2=0;          // Line width

 bool            InpBack2=false;       // Background line

 bool            InpSelection2=true;   // Highlight to move

 bool            InpHidden2=true;      // Hidden in the object list

 long            InpZOrder2=0;         // Priority for mouse click                 

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



void OnInit()

  {

//----

   CFontName FONT;

   

   Deinit();

   

  

 

  }

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

//| Custom indicator deinitialization function                       |

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

void OnDeinit(const int reason)

  {

//----

   Deinit();

//----

  }

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

//| Custom indicator deinitialization function                       |

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

void Deinit()

  {
//----
         ObjectDelete(0,  "LineLow");
         ObjectDelete(0,"LineHigh");
//----
  }

//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
int OnCalculate(
                const int rates_total,    // amount of history in bars at the current tick
                const int prev_calculated,// amount of history in bars at the previous tick
                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[]
                )

  {

//----

 // rende le descrizioni degli oggetti visibili nonHide 



   long currCharts=ChartFirst();
   int iI=0;
   while(iI<CHARTS_MAX)
     {
     if(Show_DESCRIZIONI){  
     ChartSetInteger(currCharts,CHART_SHOW_OBJECT_DESCR,true);
    }
    else
    ChartSetInteger(currCharts,CHART_SHOW_OBJECT_DESCR,false);

      ChartRedraw(currCharts);
      currCharts=ChartNext(currCharts);
      if(currCharts==-1) break;
      iI++;
     } 
//-------------------------------------------------------

//-----------------------Linea PERIOD-------------------------

 if(Show_Current){
  ArraySetAsSeries(mrate,true); 
  if( CopyRates(_Symbol,_Period,0,3,mrate)==-1 )return(false); 
   double priceLow=mrate[0].low;
   double priceHigh=mrate[0].high;
 /*ChartSetInteger(currCharts,CHART_SHOW_OBJECT_DESCR,false);
 if(Notes_OnOff){  
     ChartSetInteger(currCharts,CHART_SHOW_OBJECT_DESCR,true);
    ChartRedraw();}
 */
 ObjectCreate(0,"LineLow",OBJ_HLINE,0,0,priceLow); 
 ObjectSetInteger(0,"LineLow",OBJPROP_COLOR,mml_clr_0_8);
 ObjectSetInteger(0,"LineLow",OBJPROP_STYLE,mml_style_m_1_8);
 ObjectSetInteger(0,"LineLow",OBJPROP_SELECTABLE,InpSelection1);
 ObjectSetInteger(0,"LineLow",OBJPROP_SELECTED,InpSelection1);
 ObjectSetInteger(0,"LineLow",OBJPROP_ZORDER,InpZOrder1);
 ObjectSetString(0,"LineLow",OBJPROP_TEXT,"Low");
 ObjectCreate(0,"LineHigh",OBJ_HLINE,0,0,priceHigh);
 ObjectSetInteger(0,"LineHigh",OBJPROP_COLOR,mml_clr_0_8);
 ObjectSetInteger(0,"LineHigh",OBJPROP_STYLE,mml_style_m_1_8);
 ObjectSetInteger(0,"LineHigh",OBJPROP_SELECTABLE,InpSelection1);
 ObjectSetInteger(0,"LineHigh",OBJPROP_SELECTED,InpSelection1);
 ObjectSetInteger(0,"LineHigh",OBJPROP_ZORDER,InpZOrder1);
 ObjectSetString(0,"LineHigh",OBJPROP_TEXT,"High");
 }

/*  
 //---------------------Linea Verticale Inizio Nuovo Giorno------
  // if(!time)
    datetime  timeORA=TimeCurrent();
    datetime Times[];
int bars=(int)ChartGetInteger(0,CHART_FIRST_VISIBLE_BAR);
CopyTime(NULL,PERIOD_D1,0,3,Times);
  ObjectCreate(0,"Line_NewDAY",OBJ_VLINE,0,0,Times[2],0);
  // ObjectCreate(0,"Line_NewDAY",OBJ_VLINE,0,0,time,0);
 ObjectSetInteger(0,"Line_NewDAY",OBJPROP_COLOR,mml_clr_8_8);
    ObjectSetInteger(0,"Line_NewDAY",OBJPROP_STYLE,mml_style_m_1_8);
   ObjectSetInteger(0,"Line_NewDAY",OBJPROP_SELECTABLE,InpSelection1);
 ObjectSetInteger(0,"Line_NewDAY",OBJPROP_SELECTED,InpSelection1);
 ObjectSetInteger(0,"Line_NewDAY",OBJPROP_ZORDER,InpZOrder1); 
 ObjectSetString(0,"Line_NewDAY",OBJPROP_TEXT,"Line_NewDAY");
*/

/*
//------------------------crea pulsante----------------------
 long              chart_ID=0;               // chart's ID
                   string            name="Puls1";            // button name
                   int               sub_window=0;            // subwindow index
                   ENUM_BASE_CORNER Posizione=CORNER_LEFT_UPPER;
                   int               Altezza=18;
                   int               Lunghezza=50;
                   int               Dist_x=150;                     // X coordinate
                   int               Dist_y=50;                      // Y coordinate
                  // int               width=50;                 // button width
                  // int               height=18;                // button height
                  // ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER; // chart corner for anchoring
                   string            text="Show_5m";            // text
                   string            font="Arial";             // font
                   int               font_size=7;             // font size
                   color             clr=clrBlack;             // text color
                   color             back_clr= Gray;  // background color
                   color             border_clr=clrNONE;       // border color
                   bool              state=false;              // pressed/released
                   bool              back=false;               // in the background
                   bool              selection=false;          // highlight to move
                   bool              hidden=true;              // hidden in the object list
                   long              z_order=0;               // priority for mouse click

 //if(!ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0))  
ObjectCreate(0,"Puls1",OBJ_BUTTON,0,0,0);
//--- set button coordinates
ObjectSetInteger(0,"Puls1",OBJPROP_XSIZE,Lunghezza);
ObjectSetInteger(0,"Puls1",OBJPROP_YSIZE,Altezza);
ObjectSetInteger(0,"Puls1",OBJPROP_CORNER,Posizione);
   ObjectSetInteger(0,"Puls1",OBJPROP_XDISTANCE,Dist_x);
   ObjectSetInteger(0,"Puls1",OBJPROP_YDISTANCE,Dist_y);
   //--- set the text
   ObjectSetString(0,"Puls1",OBJPROP_TEXT,text);
//--- set button size
 //  ObjectSetInteger(0,"Puls1",OBJPROP_XSIZE,width);
 //  ObjectSetInteger(0,"Puls1",OBJPROP_YSIZE,height);
//--- set the chart's corner, relative to which point coordinates are defined
 //  ObjectSetInteger(0,"Puls1",OBJPROP_CORNER,corner);
//--- set text font
   ObjectSetString(0,"Puls1",OBJPROP_FONT,font);
//--- set font size
   ObjectSetInteger(0,"Puls1",OBJPROP_FONTSIZE,font_size);
//--- set text color
   ObjectSetInteger(0,"Puls1",OBJPROP_COLOR,clr);
//--- set background color
   ObjectSetInteger(0,"Puls1",OBJPROP_BGCOLOR,back_clr);
//--- set border color
   ObjectSetInteger(0,"Puls1",OBJPROP_BORDER_COLOR,border_clr);
//--- display in the foreground (false) or background (true)
   ObjectSetInteger(0,"Puls1",OBJPROP_BACK,back);
//--- set button state
   ObjectSetInteger(0,"Puls1",OBJPROP_STATE,state);
//--- enable (true) or disable (false) the mode of moving the button by mouse
   ObjectSetInteger(0,"Puls1",OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(0,"Puls1",OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list
   ObjectSetInteger(0,"Puls1",OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart
   ObjectSetInteger(0,"Puls1",OBJPROP_ZORDER,z_order);
//--- successful execution

//----
   ChartRedraw(0);
                     int id;
                   long lparam;
                   double dparam;
                   string sparam;
                   string buttonID=name;
                  string labelID="Info";
                  int broadcastEventID=5000;
 if(id==CHARTEVENT_OBJECT_CLICK)
     {
      string clickedChartObject=sparam;
      //--- If you click on the object with the name buttonID
      if(clickedChartObject==buttonID)
        {
         //--- State of the button - pressed or not
         bool selected=ObjectGetInteger(0,buttonID,OBJPROP_STATE);
         //--- log a debug message
         Print("Button pressed = ",selected);
         int customEventID; // Number of the custom event to send
         string message;    // Message to be sent in the event
         //--- If the button is pressed
         if(selected)
           {
            message="Button pressed";
            customEventID=CHARTEVENT_CUSTOM+1;
           }
         else // Button is not pressed
           {
            message="Button in not pressed";
            customEventID=CHARTEVENT_CUSTOM+999;
           }
         //--- Send a custom event "our" chart
         EventChartCustom(0,customEventID-CHARTEVENT_CUSTOM,0,0,message);
         ///--- Send a message to all open charts
         //BroadcastEvent(ChartID(),0,"Broadcast Message");
         //--- Debug message
         Print("Sent an event with ID = ",customEventID);
        }
      ChartRedraw();// Forced redraw all chart objects
     }

 int eventID=broadcastEventID-CHARTEVENT_CUSTOM;
   long currChart=ChartFirst();
   int i=0;
   while(i<CHARTS_MAX)                 // We have certainly no more than CHARTS_MAX open charts
     {
      EventChartCustom(currChart,eventID,lparam,dparam,sparam);
      currChart=ChartNext(currChart); // We have received a new chart from the previous
      if(currChart==-1) break;        // Reached the end of the charts list
      i++;// Do not forget to increase the counter
     }
*/

//----   
   return(rates_total);

  }

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