How to turn on/off automated trading by ea?

 

Hello,everyone

Is there a function that able to set live trading  on/off ?

It is same as turn on/off live trading by click on terminal.

thank you

 
Kittamet Sirinyamas: Hello,everyone. Is there a function that able to set live trading  on/off? It is same as turn on/off live trading by click on terminal. thank you

There is no such button on MetaTrader for turning "live trading" on/off.

There is only a button for turning "Algo Trading" on/off.

There is also no function in MQL for either option.

 
Kittamet Sirinyamas:

Hello,everyone

Is there a function that able to set live trading  on/off ?

It is same as turn on/off live trading by click on terminal.

thank you

You could try "return;" at the beginning of each OnTick() or under certain conditions. It will skip rest of codes of the function.

 
William William #:

You could try "return;" at the beginning of each OnTick() or under certain conditions. It will skip rest of codes of the function.

Thank for replying 

But I cannot access to robot’s code.

I will create risk management ea that run at the same terminal with trading robot.

The task is when equity/balance reaches into drawdown I set. The risk MM ea will stop all trading ea  and not allow to trade anymore in that terminal.

Thank you


 
Kittamet Sirinyamas #: But I cannot access to robot’s code. I will create risk management ea that run at the same terminal with trading robot. The task is when equity/balance reaches into drawdown I set. The risk MM ea will stop all trading ea  and not allow to trade anymore in that terminal.
You can only turn of the "Algo Trading" button with the use of Windows API via DLL call. Search the CodeBase. If I remember correctly there should be some code there about it.
 

I found one at least ...

Code Base

How to Disable/Enable Auto/Algo-Trading in both MT5 and MT4.

Kailash Bai Mina, 2022.04.21 07:38

Just simple codes to Disable/Enable Auto/Algo-Trading in both MT5 and MT4. Of course, DLLs must be allowed, This cannot be done without DLLs