Difference between PositionsTotal() and OrdersTotal()

 
Hi, I found that in MQL5 there's PositionsTotal() and OrdersTotal(). From the documentation PositionsTotal() returns open position, does it means that PositionsTotal() only count buy and sell order while OrdersTotal () also count stop and limit order?
 
Luandre Ezra:
Hi, I found that in MQL5 there's PositionsTotal() and OrdersTotal(). From the documentation PositionsTotal() returns open position, does it means that PositionsTotal() only count buy and sell order while OrdersTotal () also count stop and limit order?

Positions orders that have been filled or open position in a asset. Orders are stuff that is pending to be filled.

 
Luandre Ezra: Hi, I found that in MQL5 there's PositionsTotal() and OrdersTotal(). From the documentation PositionsTotal() returns open position, does it means that PositionsTotal() only count buy and sell order while OrdersTotal () also count stop and limit order?

No! In a way to try to explain it, consider the Orders as the "requests", Positions as the "results", and Deals as the "actions" between the requests and the results. MT5 trading functionality is totally different to MT4.

Read the following article for a better understanding ...

Articles

Orders, Positions and Deals in MetaTrader 5

MetaQuotes, 2011.02.01 16:13

Creating a robust trading robot cannot be done without an understanding of the mechanisms of the MetaTrader 5 trading system. The client terminal receives the information about the positions, orders, and deals from the trading server. To handle this data properly using the MQL5, it's necessary to have a good understanding of the interaction between the MQL5-program and the client terminal.
 

I already read the article and if I want my EA to look for open order I could use OrdersTotal() or PositionsTotal() even though PositionsTotal() could have a different volume then the volume of order execution, but if I want to look for pending order I can only use OrdersTotal(). Is this correct?

 
No. It is like Fernando wrote: The order is only a request, the position is the result of said request. As soon as an order gets filled, it is deleted from OrdersTotal and a position is opened.
 
Tobias Johannes Zimmer #:
No. It is like Fernando wrote: The order is only a request, the position is the result of said request. As soon as an order gets filled, it is deleted from OrdersTotal and a position is opened.
Ok I understand now, thanks for make it clear
Reason: