OpenOrders shows 0 despite I have 13 open positions??

 

I have on a demo account 13 open positions:

13 positions

but OrdersTotal() shows zero(?):

    uint o = OrdersTotal();
    Comment("OrdTotal ",o);

How do you get the open positions in MQL5?

 
Documentation on MQL5: Trade Functions / PositionsTotal
Documentation on MQL5: Trade Functions / PositionsTotal
  • www.mql5.com
Trade Functions / PositionsTotal - Reference on algorithmic/automated trading language for MetaTrader 5
 

Ah - I understand.

Coming from MQL4 I was baffled by the example in the reference:

uint     total=OrdersTotal(); 
//--- gehen wir im Zyklus durch alle Ordern  
   for(uint i=0;i<total;i++) 
     { 
      //--- erhalten wir Orderticket in Bezug auf seine Position in der Liste  
      if((ticket=OrderGetTicket(i))>0) 
        { 
....
 
Carl Schreiber:

Ah - I understand.

Coming from MQL4 I was baffled by the example in the reference:

In MQL5 OrdersTotal() returns count of pending orders.

Reason: