how to close and open an EA with another EA

 


I want to stop or start an EA when a requirement is true or false example:if spread > 5 stop EA else start EA I made this script but to no avail

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict



#include <WinUser32.mqh>

 #import "user32.dll"

 

 int GetAncestor(int, int);

 #define MT4_WMCMD_EXPERTS  987456 


 #import

 extern bool Run=true;



 void OnStart()

  {

 Comment("olar");

 int main = GetAncestor(WindowHandle(Symbol(), Period()), 2/*GA_ROOT*/);

 if(spred >10)

 if(!Run)

 {

 PostMessageA(main, WM_COMMAND,  MT4_WMCMD_EXPERTS, 0 ) ;    // // Toggle Expert Advisor button 

 

Run=true;

  }

  }


 
messiassantos:


I want to stop or start an EA when a requirement is true or false example:if spread > 5 stop EA else start EA I made this script but to no avail

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict



#include <WinUser32.mqh>

 #import "user32.dll"

 

 int GetAncestor(int, int);

 #define MT4_WMCMD_EXPERTS  987456 


 #import

 extern bool Run=true;



 void OnStart()

  {

 Comment("olar");

 int main = GetAncestor(WindowHandle(Symbol(), Period()), 2/*GA_ROOT*/);

 if(spred >10)

 if(!Run)

 {

 PostMessageA(main, WM_COMMAND,  MT4_WMCMD_EXPERTS, 0 ) ;    // // Toggle Expert Advisor button 

 

Run=true;

  }

  }


Hi,

you can use ChartSaveTemplate(), ChartClose() / ChartOpen() and ChartApplyTemplate() functions for your task.

 

Andrey Barinov:

thanks I'll try
 
Andrey Barinov:

Hi,

you can use ChartSaveTemplate(), ChartClose() / ChartOpen() and ChartApplyTemplate() functions for your task.


thank you I made this code:

  void openM30(){

  if(i==0){

 IDChart = ChartOpen("EURUSD", PERIOD_M1 ); // opens new chart

   i = 1;

   }

  }

 void eaON(){

   ChartApplyTemplate(IDChart , "eaON.tpl"); 

 }

   void eaOF(){

    ChartApplyTemplate(IDChart , "eaOF.tpl"); 

  

   thank you


 
messiassantos:

...

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


Reason: