I'm writing an multipair EA, that should only have one single trade open two avoid excessive drawdown.
What I did is looping through all open trades and counted orders with the same magicNr (All pairs on this EA use the same magicNr).
and then placing an order if there is an entry signal.
But this doesn't always work, because two or more instances of the EA might check for open orders at the same and as there are no open orders, they are placing new orders at the same time.
To check if this might happen, I've made an EA that always sends a new order, if the count of open trades is zero. And the problem really happens when I close and reopen the terminal, or when I close all open orders. I always encounter multiple trades from different pairs ;-(
What can I do to handle this properly?
Thanks in advance