Download MetaTrader 5

mql4 function to turn on and off autotrading

To add comments, please log in or register
Prataprai Kaneria
328
Prataprai Kaneria  

Happy New Year to everyone!


I want to turn off auto-trading from within my mql4 ea when a target equity is reached. I know there is a mql4 function to do this but I can not find it. I tried searching with no success.

I would appreciate if someone can tell me where I find some documentation or example.


Thanks.

Carl Schreiber
6787
Carl Schreiber  
What about ExpertRemove()?
honest_knave
Moderator
2408
honest_knave  
7325453863:

Happy New Year to everyone!


I want to turn off auto-trading from within my mql4 ea when a target equity is reached. I know there is a mql4 function to do this but I can not find it. I tried searching with no success.

I would appreciate if someone can tell me where I find some documentation or example.


Thanks.

 

Not my knowledge. You can find out if AutoTrading is enabled:

TerminalInfoInteger(TERMINAL_TRADE_ALLOWED);

 

You can also remove an EA from your chart:

ExpertRemove();

 

 Even more extreme, you can also force your terminal to close:

TerminalClose(1);

 

But it may be better to code your EA so that it doesn't trade if your equity is above a certain level using

AccountEquity();

 

Depending on what your EA is doing, you can run this check before a trade is placed, or at the start of OnTick().

 

Hope that helps. 

Prataprai Kaneria
328
Prataprai Kaneria  
honest_knave:

 

Not my knowledge. You can find out if AutoTrading is enabled:

 

You can also remove an EA from your chart:

 

 Even more extreme, you can also force your terminal to close:

 

But it may be better to code your EA so that it doesn't trade if your equity is above a certain level using

 

Depending on what your EA is doing, you can run this check before a trade is placed, or at the start of OnTick().

 

Hope that helps. 

 


Prataprai Kaneria
328
Prataprai Kaneria  
7325453863:

Thanks for the suggestions. I think I will use expertremove function.
To add comments, please log in or register