How to get the total number of opened orders and select them in MQL4?

 

Hello Guys, i am little confused in finding the total no. of opened positions. I am only seeing OrderTotal, which is total no of opened and pending positions. It's occurring in Mql4. In Mql5 we simply get opened positions by PositionsTotal(); and pending positions by OrdersTotal(); . If any one have solution please respond. Thank You in advance.

 
Abhishek Yadav: Hello Guys, i am little confused in finding the total no. of opened positions. I am only seeing OrderTotal, which is total no of opened and pending positions. It's occurring in Mql4. In Mql5 we simply get opened positions by PositionsTotal(); and pending positions by OrdersTotal(); . If any one have solution please respond. Thank You in advance.

In MQL4,there are only "Orders" which includes Pending Orders and Market Orders, where Market Orders are equivalent to "Positions" in MQL5.

So to count Market Orders ("Positions"), you have to loop over all the "Orders" and count all the Market Orders (which are identified as having a OrderType() of either OP_BUY or OP_SELL).

OrderType - Trade Functions - MQL4 Reference
OrderType - Trade Functions - MQL4 Reference
  • docs.mql4.com
OrderType - Trade Functions - MQL4 Reference
 
Fernando Carreiro #:

In MQL4,there are only "Orders" which includes Pending Orders and Market Orders, where Market Orders are equivalent to "Positions" in MQL5.

So to count Market Orders ("Positions"), you have to loop over all the "Orders" and count all the Market Orders (which have a OrderType() of either OP_BUY or OP_SELL).

Thank You so much Fernando. it was helpful.