mql4 function to turn on and off autotrading

 

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.

 
What about ExpertRemove()?
 
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. 

 
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. 

 


 
7325453863:

Thanks for the suggestions. I think I will use expertremove function.
Reason: