how to work with the buttons
-
hello i am trying to grasp the idea of buttons in chart and object menu i have tried using the button but it always start doing the intended job as soon as its attached to the chart , but what i wanna do is , whenever i click on the button then it should perform the intended task ....
so if anyone can point me to a tutorial or something like that it would be great -
https://fxdreema.com/shared/wMaMALJbd
The problem with buttons is that they act more like switches, they are either pressed or de-pressed (down or up). They don't automatically move up when you press them and I don't know for an opton to do that.
-
Thanks for the help!
-
When you create the button ensure that under the "adjust" settings the it is set to not pressed. Then under "on tick" or "on chart" depending on the function you want to control, put the select button and check button state blocks. From the orange connector run whatever function you want to happen when the button is pushed. This will continue to run as the button remains pressed - unless - after the functions you add a "Custom MQL4 code" and insert the following:
ObjectSet(LoadedObjectName(),OBJPROP_STATE,0);
This will reset the button to off (i.e. 0, when on is 1). You could also use the block to change the button colour when pressed by changing the properties etc.
I hope that helps.
Regards
Colin
-
@fxdreema said in how to work with the buttons:
https://fxdreema.com/shared/wMaMALJbd
The problem with buttons is that they act more like switches, they are either pressed or de-pressed (down or up). They don't automatically move up when you press them and I don't know for an opton to do that.
Hi Ad,
How to creat 2 buttons?
I made 2 button, but both 2 button active when I press 1 only
https://fxdreema.com/shared/lX9JLZeG -
@khacdiepvnc I recommend you use 'Filter object by name' option in blocks 847 and 850. Use different names for both.
-
@l-andorrà yes I see,
many thanks -
@khacdiepvnc You're welcome.
-
@cpbonzo is there an equivalent code for mq5? to do the same, reset the state of the button?
-
@sosel Yes, you can use the same blocks for MT5.
-
I was getting an error about the syntax, i went to de documentation for MQL5 and the code is a little bit different, i used this, and is working well:
ObjectSetInteger(0,"buy",OBJPROP_STATE,false); -
@sosel Interesting. I'm not a programmer, sorry. Thank you for sharing.