I was trying to execute only one EA per _Symbol, i tried mutex and winapi, but that was very ugly...
Asking to MQL5 support they report me this interesting condition:
FileOpen when not used with shared write or shared read will open file with exclusive lock, including the FILE_COMMON flag you could use a lock file to block two EA :) check it:
int FP;
intOnInit(){
FP=FileOpen(_Symbol+".lock",FILE_WRITE | FILE_COMMON);
if(FP<0){
Alert("More than one EA using this Symbol ["+_Symbol+"]");
return(INIT_FAILED);
}
return(INIT_SUCCEEDED);
}
voidOnDeinit(constint reason){
FileClose(FP);
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I was trying to execute only one EA per _Symbol, i tried mutex and winapi, but that was very ugly...
Asking to MQL5 support they report me this interesting condition:
FileOpen when not used with shared write or shared read will open file with exclusive lock, including the FILE_COMMON flag you could use a lock file to block two EA :) check it: