Hello
I want to Disable / Enable Expert (Auto Trading) button programmably as if i click on it to enable or disable Expert according to condition. I am searching MQL4 code to do that but i did not find.
Any help please.
Hello
I want to Disable / Enable Expert (Auto Trading) button programmably as if i click on it to enable or disable Expert according to condition. I am searching MQL4 code to do that but i did not find.
Any help please.
What so hard doing that ?
void OnTick(void) { if ( whatever == happen ) { Print("Whatever has happen. Expert is disabled"); return; //<<-- here's the secret, this return simulated that the EA is disabled, the rest of EA code will never executed } }
If you're need button on EA, there's a sample on MetaEditor called SamplePanel.mq4 found on Indicators/Examples/SimplePanel that I think can be use on EA as well.
Not possible with mql4.
But i need to close EA at certain condition, because i am using the same EA as basket, so if i use condition for stopping one EA the others will not stop. for this reason i want one EA disable auto trading as if i click on Auto trading
I found solution as following codes
#include <WinUser32.mqh> #import "user32.dll" int GetAncestor(int, int); #define MT4_WMCMD_EXPERTS 33020 #import extern bool Run=true; void OnTick() { int main = GetAncestor(WindowHandle(Symbol(), Period()), 2/*GA_ROOT*/); if(!Run) { PostMessageA(main, WM_COMMAND, MT4_WMCMD_EXPERTS, 0 ) ; // // Toggle Expert Advisor button Run=true; }
I did make Run=true to stop toggling the auto trading button from on to off and so on.
But i want to toggle Run after change it from true to false, to true again without click on Run to select true again on the EA.
So how to do that with MQL4 ?
I found solution as following codes
I did make Run=true to stop toggling the auto trading button from on to off and so on.
But i want to toggle Run after change it from true to false, to true again without click on Run to select true again on the EA.
So how to do that with MQL4 ?
Hello,
Using this Code Disables the Expert button, Its ok.
But I want to Re-Enable it, How to do it..?
Hello,
Using this Code Disables the Expert button, Its ok.
But I want to Re-Enable it, How to do it..?
Opposite to all the denying postings here this has been possible *from* MQL since more than 10 years (not *with* pure MQL). To re-enable disabled experts just call the function again.
PostMessageA(main, WM_COMMAND, MT4_WMCMD_EXPERTS, 0 ) ;
In fact the command toggles the EA status: enabled => disabled => enabled => disabled and so on.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello
I want to Disable / Enable Expert (Auto Trading) button programmably as if i click on it to enable or disable Expert according to condition. I am searching MQL4 code to do that but i did not find.
Any help please.