Hi, what do you want to do?
If EA 1 running, EA 2 have to sleep?
Hi, what do you want to do?
If EA 1 running, EA 2 have to sleep?
Cannot be done. Possible solutions would be outside the scope of mql4.
Yes it's possible:
applying a magicnumber to the first, exemple 300.
Orderstotal() for(....) Orderselect(....) if(OrderMagicNumber() ==300) // Looking for orders with Magic 300 { EA1= 1 }// It means that there is an order by the first EA. If (EA1 != 1) { Allowed to trade with the second EA. } else { Print("The first EA is running") }
The only way that I can think of with out looking for is through global variables.
#include "shared_file.mq4"; int number = 12345; void init() { StartEA(number); } void deinit() { StopEA(number); } void start() { if(OtherEA(number))return; // rest of code }
shared_file.mq4:
void StartEA(int number){ if(GlobalVariableCheck("EAcheck_"+number))GlobalVariableSet("EAcheck_"+number,WindowHandle(Symbol(),Period())); } void StopEA(int number){ if(GlobalVariableCheck("EAcheck_"+number))GlobalVariableDel("EAcheck_"+number); } bool OtherEA(int number) { for(int i=GlobalVariablesTotal()-1;i>=0;i--) { if(StringFind(GlobalVariableName(i),"EAcheck")>-1){if(GlobalVariableName(i)=="EAcheck_"+number)continue;return(true);} } return(false); }
The have the code on all the EA which your likely to run at the same time. You could also modify it to check against a set list ie. 1 EA is good to trade while another isn't.
Yes it's possible:
applying a magicnumber to the first, exemple 300.
Thanks everybody for your comments and ideas.
The idea is having a group of users doing a trading contest where the EAs are not allowed.
I think by reading the Magic Number would it possible to know it.
Regards
An EA not necessarily sets a magic number. If omitted, it is 0 like for manual trades.
An EA not necessarily sets a magic number. If omitted, it is 0 like for manual trades.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everybody,
Is it possible than an EA detect if other EAs are running on the same terminal?
If so, could you show me the routine?
Thanks in advance