Download MetaTrader 5

Can you please give me sample code of OBJ_BUTTON because MQL documentation SUCKS

To add comments, please log in or register
Musngi
307
Musngi  

Can you please give me sample code of OBJ_BUTTON because MQL documentation SUCKS. MQL documentation show long example of bloated code.

There's example code that show many user defined function that not related to OBJ_BUTTON. I want documentation to be clean and short as much as possible to understand clearly, and likes flow of a river.

Give me sample code of OBJ_BUTTON including the size, border, corner, etc.

I created an indicator that used OBJ_LABEL but I want to turn it in BUTTON to use the background color to change the color depending on prices. 

Keith Watford
Moderator
10646
Keith Watford  
   int x=5,y=10,width=80,height=20,corner=0,font_size=10;
   string name="Button",text="Press";
   color text_clr=clrBlack,back_clr=clrSilver,border_clr=clrBrown;
   if(ObjectCreate(0,name,OBJ_BUTTON,0,0,0))
     {
      ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
      ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
      ObjectSetInteger(0,name,OBJPROP_XSIZE,width);
      ObjectSetInteger(0,name,OBJPROP_YSIZE,height);
      ObjectSetInteger(0,name,OBJPROP_CORNER,corner);
      ObjectSetString(0,name,OBJPROP_TEXT,text);
      ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size);
      ObjectSetInteger(0,name,OBJPROP_COLOR,text_clr);
      ObjectSetInteger(0,name,OBJPROP_BGCOLOR,back_clr);
      ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,border_clr);
     }

I would usually have this as a function, much simpler if there are going to be more than 1 button.

whroeder1
15727
whroeder1  
Musngi: Can you please give me sample code of OBJ_BUTTON because MQL documentation SUCKS.
See my GUI: Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 5
Musngi
307
Musngi  
GumRai:

I would usually have this as a function, much simpler if there are going to be more than 1 button.

What are the difference between ObjectSet() and ObjectSetInteger()?
whroeder1
15727
whroeder1  

RTFM. https://www.mql5.com/en/forum/160381/page2#1042947

Please do not feed the troll. When you respond, you give the troll power. When you ignore the troll, he starves for attention and eventually dies.



Musngi
307
Musngi  
WHRoeder:

RTFM. https://www.mql5.com/en/forum/160381/page2#1042947

Please do not feed the troll. When you respond, you give the troll power. When you ignore the troll, he starves for attention and eventually dies.



This is serious question. I used ObjectSet() in OBJ_LABEL, then switching to OBJ_BUTTON. That's why I'm asking that question.
Musngi
307
Musngi  

 I discovered that ObjectSet() don't work in OBJ_BUTTON. I spend a lot of time to make it work: For example this function1 don't work in OBJ_LABEL, or this function2 don't work in OBJ_BUTTON.

Why MQL documentation did not tell this? 

To add comments, please log in or register