OrdersTotal()

 

I have opened an buy-order, confirmed by the server and running.

 

int x = OrdersTotal();

 

x = 1

x = 0

x = 0 ........

OrdersTotal() returns first 1, then 0, although there is an open position. 

 

Don't mix a position and an order. They are different. You can have only one open position and many orders. See HistorySelect.



 
Maybe your problem is because you are using OrdersTotal() as in mql4, instead of PositionsTotal(). See PositionsTotal().
Reason: