For every single there is a ticket for that position, but there is also a unique identifier ticket ( POSITION_IDENTIFIER ), which also happens to be the ticket number of the first order that created the original position. This identifier is used by all orders, deals and positions that affect the original position.
So, in essence each order has its own ticket, each deal has its own ticket, and each position has its own ticket, but they are all connected by the Position Identifier ticket.
Position identifier is a unique number assigned to each re-opened position. It does not change throughout its life cycle and corresponds to the ticket of an order used to open a position.
Position identifier is specified in each order (ORDER_POSITION_ID) and deal (DEAL_POSITION_ID) used to open, modify, or close it. Use this property to search for orders and deals related to the position.
When reversing a position in netting mode (using a single in/out trade), POSITION_IDENTIFIER does not change. However, POSITION_TICKET is replaced with the ticket of the order that led to the reversal. Position reversal is not provided in hedging mode.
For every single there is a ticket for that position, but there is also a unique identifier ticket ( POSITION_IDENTIFIER ), which also happens to be the ticket number of the first order that created the original position. This identifier is used by all orders, deals and positions that affect the original position.
So, in essence each order has its own ticket, each deal has its own ticket, and each position has its own ticket, but they are all connected by the Position Identifier ticket.
Position identifier is a unique number assigned to each re-opened position. It does not change throughout its life cycle and corresponds to the ticket of an order used to open a position.
Position identifier is specified in each order (ORDER_POSITION_ID) and deal (DEAL_POSITION_ID) used to open, modify, or close it. Use this property to search for orders and deals related to the position.
When reversing a position in netting mode (using a single in/out trade), POSITION_IDENTIFIER does not change. However, POSITION_TICKET is replaced with the ticket of the order that led to the reversal. Position reversal is not provided in hedging mode.
Hello Fernando,
ok thank you for your explantation. So with the "Position_identifier" i can find all orders, deals and position wich belong to "one complete trade" - correct?
With wich function i can find the datas form order,deals,positions?
If i start with a ticketid (example "2") , what will be the next steps to get the "Position_identifier" and how i can find with this the other Positions, Orders, Deals and also get their own datas?
Also i read thats important to select position/deals/orders at first...!?
If "ticketid" is for the very first order, that created the position, then it is also the Position_identifier.
So, obtain your history by that identifier ...
Requests the history of deals with a specified position identifier.
You can then process all the Orders and Deals for that position ...
Scarning the orders with:
Returns the number of orders in the history
Return order ticket of a corresponding order in the history
Scanning the deals with:
Returns the number of deals in the history
Returns a ticket of a corresponding deal in the history

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
i try to understand the logic of mt5 how to do and handle trades ( Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles)
At the moment i'm really confused.
If i see it correctly, there is no kind of id, wich marks the first trade to open a order and his positions and the positions of the trade to close a order - is it correctly?
How i can find the related position for example:
I have a ticketid "2" this is a buy order.
Later the position is closed by a new opposite, sell order.
How i get the ticketid and informations of the last closing order/position?
I see the different kind of "HistorySelect()", "HistorySelectByPosition()" or "HistoryDealSelect()" etc. but im totaly confused about all this thinks...
May its simple, but i need to understand the logic after all these...
Hope someone can help and explain a bit.
Thank a lot!