Can I code in MQL to turn on and off an already running EA? - page 3

 
SendMessage((GetParent(GetParent(GetParent(WindowHandle(Symbol(), 0))))), 273, 33020, 0);

This will send the control-E to the terminal and disable ALL EA's on ALL charts. As opposed to removing the EA from one chart

alternative, self documenting code:

#include <WinUser32.mqh>
#import "user32.dll"
  int GetAncestor(int, int);
#import
#define MT4_WMCMD_EXPERTS         33020 // Toggle Expert Advisor button
int main = GetAncestor(WindowHandle(Symbol(), Period()), 2/*GA_ROOT*/);
SendMessage(main, WM_COMMAND, MT4_WMCMD_EXPERTS, 0);
 
WHRoeder:

This will send the control-E to the terminal and disable ALL EA's on ALL charts. As opposed to removing the EA from one chart

alternative, self documenting code:


thank you very much

 

qjol:


u mean the no. 33020 ? if the answer is yes, this is not a calculation

microsoft spyxx giving u this no.

u can download it from here



hi
you are the first programer in world

thank you very much

i use Winspector for find the code 33020

if you can,explain us how do we find code 33020 by spyxx ?

if you want

thank you my professor

 
sahlih2000:
Ctrl + E for which equal 33,020
pls how to calculate it or how to get this value
See #define's for known commands that can be used for PostMessageA() - MQL4 forum
 
sahlih2000:


hi
you are the first programer in world

thank you very much

i use Winspector for find the code 33020

if you can,explain us how do we find code 33020 by spyxx ?

if you want

thank you my professor

i sent u a PM with a video attached
 

thank you very ery much my friend WHRoerder
 
qjol:
i sent u a PM with a video attached


you are very great programmer in the world

thank you my professor

 
William Roeder:

This will send the control-E to the terminal and disable ALL EA's on ALL charts. As opposed to removing the EA from one chart

alternative, self documenting code:


I changed a little your code with change SendMessage to SendMessageA and define it.

#include <WinUser32.mqh>
#import "user32.dll"
int GetAncestor(int, int);
int SendMessageA(int, int, int, int);
#import
#define MT4_WMCMD_EXPERTS 33020 //Toggle Expert Advisor button

void AllowAutoTrading()
  {
   if(!IsTradeAllowed())
     {
      int main = GetAncestor(WindowHandle(Symbol(), Period()), 2/*GA_ROOT*/);
      SendMessageA(main, WM_COMMAND, MT4_WMCMD_EXPERTS, 0);
     }
  }

void OnStart()
  {
   AllowAutoTrading();
  }
Reason: