Disallow multiple EA instances in one terminal

 

am trying to disallow multiple running of EAs in one terminal and am finding alittle bit hard..

i have try to use this code but it rather terminate my current EA name on the chart ..

#include <WinUser32.mqh>
   
int hndl = WindowHandle(Symbol(),Period());
   if (WindowExpertName() == "niceprofit")
      {
      PostMessageA(hndl,WM_QUIT,0,0);
      }
 
chukwudi joshua obiekwe: i have try to use this code but it rather terminate my current EA name on the chart ..

Your code is the equivalent of ExpertRemove. Of course, it terminates the current chart's EA.

 
chukwudi joshua obiekwe:

am trying to disallow multiple running of EAs in one terminal and am finding alittle bit hard..

i have try to use this code but it rather terminate my current EA name on the chart ..

You need to iterate through all open charts, get chart ID, get window handle with ChartGetInteger(chartID, CHART_WINDOW_HANDLE) and then call your function. And of course exclude the current chart not to kill the killer before the job is done.

 
William Roeder #:

Your code is the equivalent of ExpertRemove. Of course, it terminates the current chart's EA.

i did a little research on this request got your code,but got few error..

#include <WinUser32.mqh>       
datetime EAstart;
int init(){
    EAstart = TimeCurrent(); 
}
int start(){
    datetime prevStart = GetGVDT("EAstart");
    if (prevStart > EAstart){
        // Another instantance has started, terminate THIS one.
        PostMessageA( WindowHandle( Symbol(), Period()), WM_COMMAND, 33050, 0);
        return;
    if (prevStart < EAstart){
        // Terminal was restarted or other
        SetGVDT("EAstart", EAstart);
    }
    :
}
void SetGVDT(string name, datetime t);
    // Global variables are doubles - can't store a datetime with full precision
    int tod = t % 86400, // Time of day
        day = t / 86400;
    GlobalVariableSet(name+"1", day);
    GlobalVariableSet(name+"2", tod);
}
datetime GetGVDT(string name);
set(GV1) = tod; set (gv2) = day;
    if (!GlobalVariableCheck(name+"1")) return(0);
    return( Int(GlobalVariableGet((name+"1")) * 86400
          + Int(GlobalVariableGet((name+"2")) 
          );
}
int Int(double d){ return(d); }
 
chukwudi joshua obiekwe #:

i did a little research on this request got your code,but got few error..

does this work?

 
Chioma Obunadike #:

does this work?

yes but the code need to be work on..


but you can put more effort here

https://www.mql5.com/en/forum/130970


but i think some updates has been done on windows/upgrades which makes

opening or writing some files on

C:\windows\system32\

 hard to work on some windows..

but on mt4 code above should be nearest to work on mt4 code structure...

i have implement a lot of my own codes and other research codes solutions, they compile well after rewriting some lines , but will not actually be effective and responsive..

but if @William Roeder #:  will help i think it will be fine cause its his code specifically for mt4 code structure, but a times he make code

complex in loops through the lines..

Disallowing multiple EA instances in one terminal - Can anyone think of way to disallow more than 1 instances of the same EA at once?
Disallowing multiple EA instances in one terminal - Can anyone think of way to disallow more than 1 instances of the same EA at once?
  • 2011.01.04
  • www.mql5.com
Hi, can anyone think of a way to disallow the user to run more than 1 instance of the same ea in one mt4 terminal at once (not only 2 forward testing instances, but also forward testing + backtesting )