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
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
Forum on trading, automated trading systems and testing trading strategies
When you post code please use the CODE button (Alt-S)!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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;
}
}