Set a flag. PositionsTotal() can be out of sync.
[edit] You are using OrdersTotal(), it is for orders not positions.
Hello,
I am using the following function within my EA to only open trades at the start of a new bar if the entry criteria are met.
This is used with the following logic:
Because I am running the EA on a few different charts, there have been instances where on the start of a new bar, the EA has opened a position on two different Symbols, bypassing the orders total condition.
What could I implement to avoid this happening?
Not sure if I understand your requirement, but could it be you need to check positions also?
if(OrdersTotal() == 0 && PositionsTotal() == 0 && new_bar(PERIOD_H1) && entry_criteria == true) { OPEN TRADE }
If you are doing this across different charts and you are trying to limit the transactions for the current symbol, you may need to scan the positions and orders and count how many exist for your current _Symbol - depends on what your are aiming to do

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I am using the following function within my EA to only open trades at the start of a new bar if the entry criteria are met.
This is used with the following logic:
Because I am running the EA on a few different charts, there have been instances where on the start of a new bar, the EA has opened a position on two different Symbols, bypassing the orders total condition.
What could I implement to avoid this happening?