Check for duplicate magic numbers
-
Hi everyone,
Is there a simple way (including using custom code) to check if another EA with the same magic numbers are running on the MT4/MT5 client?
I want to use my EA with multiple charts but need to keep them separate of each other, and the easiest is to just stop it running if a duplicate magic number was detected.Appreciate any help, thanks.
-
@breeeeen If on the same terminal then a block that checks for running trades will check for any running the same magic number, at least if you have the settings set that way.
-
Hi again @jstap

I suspect that may cause issues if there are existing trades and the EA is being re-initialized or was removed and subsequently re-added.After doing quite a bit of reading and thinking, I managed to implement something half-acceptable: I added a terminal variable (which changes based on group ID) and a condition to check the terminal variable.
The condition runs first, and if there is an existing terminal variable with the same value, an alert pops up (although nothing stops the EA from continuing to run). Not the most refined but it works I guess. Main trouble I find now is that terminal variable doesn't update when I change the settings on the EA. In fact, nothing on the "On Init" tab runs after changing a parameter, which was counter to my understanding of what "on init" would represent.I'll leave this topic open in case someone has a more refined solution than what I have.
Cheers.