Your code is the equivalent of ExpertRemove. Of course, it terminates the current chart's EA.
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.
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); }
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..
- 2011.01.04
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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 ..