- Features of the mql5 language, subtleties and tricks
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- PositionsTotal() not 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?
Positions orders that have been filled or open position in a asset. Orders are stuff that is pending to be filled.
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 ...
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?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use