- Position Ticket on open and close
- Tracking Order trigger
- Separate report for different EA
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Forum on trading, automated trading systems and testing trading strategies
how can Orders, Positions and Deals be linked together?
Fernando Carreiro, 2023.11.18 13:31
They are linked by their respective tickets and especially overall by their Position Identifier ticket which is usually the same as the Order ticket that first created the position.
All subsequent orders and deals that affect that position, will reference that unique identifier that is assigned to all orders and deals executed for the entire lifetime of the position.
ENUM_POSITION_PROPERTY_INTEGER
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.
long
Position identifier that is set to an order as soon as it is executed. Each executed order results in a deal that opens or modifies an already existing position. The identifier of exactly this position is set to the executed order at this moment.
long
Identifier of a position, in the opening, modification or closing of which this deal took part. Each position has a unique identifier that is assigned to all deals executed for the symbol during the entire lifetime of the position.
long
Also, please read the following ...
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.
The previous post is about MQL5, but the same applies to Python, using the equivalent functions for Python instead of MQL5.
Where is the "position_id"?
Your table only has the order id and deal id, but not the Position identifier. That is the whole point of my previous post.
If you need help with your code, then please show it.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use