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.
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 |
I would usually have this as a function, much simpler if there are going to be more than 1 button.
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.
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.
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?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.