PositionsTotal returns the TOTAL number of positions.
You need to count the number of positions for EACH of the three symbols. Counting is done in a cycle: all positions are bypassed. If necessary, enable filter by Magic Number.
![Documentation on MQL5: Trade Functions / PositionsTotal Documentation on MQL5: Trade Functions / PositionsTotal](https://c.mql5.com/36/44/documentation-on-mql5-trade-functions__1.png)
- www.mql5.com
Agree on @Vladimir Karputov. Also you should use StringCompare to compare Strings. PositionsTotal will give you the count of all open positions in the current symbol.
You could save the ticket number wenn you place the order. This way the expert advisor can check on whether "his" position is open or closed in the current symbol.
Does this help?
Agree on @Vladimir Karputov. Also you should use StringCompare to compare Strings. PositionsTotal will give you the count of all open positions in the current symbol.
You could save the ticket number wenn you place the order. This way the expert advisor can check on whether "his" position is open or closed in the current symbol.
Does this help?
Thank you both gentlemen. I will try and see if it works.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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,
I have three different EAs and insert them on three different symbols. However, at a time just one of them can open trade. I want all of them can work independently. I have used bellow code to open trade in all my programs:
**************
if (signal=="sell" && PositionsTotal()<1)
*************
I also have raed that PositionsTotal() refers to positions in current symbol, so there should be no problem. Please advise.