I tried many times to check OrdersTotal(), but I found it did not work.
In my demo account, I always get "0" when I use the function to get the total orders of the account.
So what's the problem? How to use the function correctly?
Any information will be appreciated.
In MT-5, OrdersTotal(0) returns number of pending orders, where OrdersTotal() in MT-4 returned number of both market and pending orders.
Try using PositionsTotal() for number of open positions.
To find open position for specific Symbol(), try this.
int OpenPos() { int total=PositionsTotal(); int count=0; for (int cnt=0; cnt<=total; cnt++) { if(PositionSelect(Symbol()) ) { if(PositionGetInteger(POSITION_MAGIC)==MagicNumber) { count++; } } } return(count); }
In MT-5, OrdersTotal(0) returns number of pending orders, where OrdersTotal() in MT-4 returned number of both market and pending orders.
Try using PositionsTotal() for number of open positions.
To find open position for specific Symbol(), try this.
I got it. Thanks a lot.
int OpenPos() { int total=PositionsTotal(); int count=0; for (int cnt=0; cnt<=total-1; cnt++) { if(PositionSelect(Symbol()) ) { if(PositionGetInteger(POSITION_MAGIC)==MagicNumber) { count++; } } } return(count); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I tried many times to check OrdersTotal(), but I found it did not work.
In my demo account, I always get "0" when I use the function to get the total orders of the account.
So what's the problem? How to use the function correctly?
Any information will be appreciated.