Multiple postions for a symbol problem
PositionGetTicket
The function returns the ticket of a position with the specified index in the list of open positions and automatically selects the position to work with using functions PositionGetDouble, PositionGetInteger, PositionGetString.
ulong PositionGetTicket(
int index // The number of a position in the list ); |
Parameters
index
[in] The index of a position in the list of open positions, numeration starts with 0.
Return Value
The ticket of the position. Returns 0 if the function fails.
Note
For the "netting" interpretation of positions (ACCOUNT_MARGIN_MODE_RETAIL_NETTING and ACCOUNT_MARGIN_MODE_EXCHANGE), only one position can exist for a symbol at any moment of time. This position is a result of one or more deals. Do not confuse positions with valid pending orders, which are also displayed on the Trading tab of the Toolbox window.
If individual positions are allowed (ACCOUNT_MARGIN_MODE_RETAIL_HEDGING), multiple positions can be open for one symbol.
To ensure receipt of fresh data about a position, it is recommended to call PositionSelect() right before referring to them.
See also
PositionGetSymbol(), PositionSelect(), Position Properties
https://www.mql5.com/en/docs/trading/positiongetsymbol

- www.mql5.com

- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The current MQL5 reference for PositionSelect states that “only one position can exist for a symbol at any moment of time”.
In fact, the latest version of MT5 allows more than one position to be opened for a symbol at the same time.
Apart from grabbing the ticket number of each position as it is opened and storing them for further use, how do I find out the ticket numbers for all the open positions for a symbol?