Search code examples
mql5metatrader5

How to get an amount of open trades in MQL5


I want to get the amount of open trades in MQL5 on a demo account during strategy testing.

PositionsTotal() and OrdersTotal() always return 0 even if there are open trades.

The solution suggested here does not work.

Any help will be appreciated.


Solution

  • The problem occurred when running the code in the Metatrader 5 downloaded from Metaquotes' website. Running the same code in a Metatrader 5 instance from a forex broker resolved the issue.