How To Disable Algo trading in MT5?

 
I want to disable trading for a .ex5 file on a specified condition using EA.

Can Someone please help Me in disabling Algo-Trading via Code?

Help Will be really really appreciated and By helping me you will help many other peoples too because there is no previous forum of any detail about doing it on MT5. 
 
i would love to know how to enable algo trading via code. 
 

I would also like to know how this could be done.

 
Ismael Martiny #: I would also like to know how this could be done.

It is not possible to enable/disable Auto/Algo-trading from within standard MQL code. It can only be achieved via a DLL call to the Windows API.

 
Fernando Carreiro #:

It is not possible to enable/disable Auto/Algo-trading from within standard MQL code. It can only be achieved via a DLL call to the Windows API.

It's possible for MT4 using the user32.dll. I would also like to know how it works for MT5. Can anyone help?

 

Follow script below:

//+------------------------------------------------------------------+
//|                                              TestAlgoTrading.mq5 |
//|                                                   Tiago Praxedes |
//|                                         tepraxedes2020@gmail.com |
//+------------------------------------------------------------------+
#define MT_WMCMD_EXPERTS   32851
#define WM_COMMAND 0x0111
#define GA_ROOT    2
#include <WinAPI\winapi.mqh>

//+------------------------------------------------------------------+
//| Toggle auto-trading button                                       |
//+------------------------------------------------------------------+
void AlgoTradingStatus(bool Enable)
  {
   bool Status = (bool) TerminalInfoInteger(TERMINAL_TRADE_ALLOWED);

   if(Enable != Status)
     {
      HANDLE hChart = (HANDLE) ChartGetInteger(ChartID(), CHART_WINDOW_HANDLE);
      PostMessageW(GetAncestor(hChart, GA_ROOT), WM_COMMAND, MT_WMCMD_EXPERTS, 0);
     }
  }  
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---   
   AlgoTradingStatus(false);   
  }
//+------------------------------------------------------------------+
 
It is working perfectly. Thanks a lot.
 

Hello,


Anyway to disable algo trading of current chart EA only?


Thank you

 
Sunfire #:

Hello,


Anyway to disable algo trading of other EA found in other chart of the same terminal?

No, algo trading is universal for all EA's 
You will have to find any other way.
 
TIAGO EMMANUEL PRAXEDES SILVA Praxedes #:

Follow script below:

thanks :)

 
Sunfire #: Anyway to disable algo trading of current chart EA only?
  1. Remove the current chart EA from the current chart. (Templates can assist.)
  2. Add an input or button to the EA.