Download MetaTrader 5
To add comments, please log in or register
Trade like successful traders - subscribe to their signals!
Musngi
281
Musngi 2016.10.19 08:30 

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
8014
Keith Watford 2016.10.19 09:45  
   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
13644
whroeder1 2016.10.19 12:30  
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
281
Musngi 2016.10.19 13:13  
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
13644
whroeder1 2016.10.19 14:12  

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
281
Musngi 2016.10.19 14:48  
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
281
Musngi 2016.10.19 16:27  

 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