I am trying to add some code to my EA so that it only has one trade open per currency pair at a time.
I found this code online and tried it but I'm now getting the following errors:
Could anyone possibly give me advice on how to resolve this issue?
Thanks in advance!
I have been extremely busy with work so haven't been able to spend much on my code last week. Even when I add what you recommended, the code still opens multiple trades per currency pair.
Do you maybe have an idea why it does this?
If you don't want you code to do anything else if a position is already open (so you don't want it to manage any open positions etc) then change this to:
Thanks a ton Honest!!
If I add the return; and link my code to multiple charts, for example: EURUSD and GBPUSD, then will the code trade the charts completely independent of each other? provided of course there is enough in my account balance to fund both?
Yes, each instance of the EA will be working independently unless you code it otherwise.
If you have one EURUSD order open:
This is because you are testing for Symbol.
The only caveat: if you have 2 charts of the same symbol open (e.g. 2 x EURUSD charts) then they will only trade 1 order combined... in theory. You may find some oddities through processing delays if they are both are trading the same logic at the same time. This is where Magic Numbers could be useful.