Would adding those 2 lines into the OnTimer() function fix this?
- OnTimer changes nothing.
- Your problem is you need a mutex for the test (PositionsTotal) and then open, to be atomic across multiple threads (EAs).
Prevent EA from opening trades at the same time across 2 or more pairs? - MQL4 programming forum - Page%nbsp;2 #11 (2022)
William Roeder #:
- OnTimer changes nothing.
- Your problem is you need a mutex for the test (PositionsTotal) and then open, to be atomic across multiple threads (EAs).
Prevent EA from opening trades at the same time across 2 or more pairs? - MQL4 programming forum - Page%nbsp;2 #11 (2022)
will check it out. thanks.
William Roeder #:
- OnTimer changes nothing.
- Your problem is you need a mutex for the test (PositionsTotal) and then open, to be atomic across multiple threads (EAs).
Prevent EA from opening trades at the same time across 2 or more pairs? - MQL4 programming forum - Page%nbsp;2 #11 (2022)
sometimes i use code from eabuilder and that will often open multiple trades. Q... will the above avoid this from happening, also? i mean: if i add the mySend function from eabuilder... to the function at the bottom.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have my ea on all the fx pairs that my broker has, but I want to limit trading to only a single pair only eg I want each ea to check that there it is allowed to open a trade before sending the order. If my ea on GBPUSD has 1 or more trades open, then only that ea is allowed to open a new trade.
I have found that if multiple eas has a signal, on the same tick, when there is 0 trades open, then, i can have a trade open, on multiple pairs. This is exactly what I want to avoid from happening.
This is the 2 lines of code that I have in the OnTick() function.
As i said, this seems to work for the most part, but the issue i have is that if there is 0 trades open, and multiple eas have a signal, then, each ea will open a trade.
Can you suggest a better way?