MT5 Trade Request Correlation and Historical Execution Evidence After a Lost Response
MT5 Trade Request Correlation and Historical Execution Evidence After a Lost Response
Hello MetaQuotes team and MQL5 community,
I am researching the reliability of trade-execution reconciliation in an application integrating with MetaTrader 5.
The specific problem concerns a trade request submitted to an MT5 trading server where the application loses its execution response due to a network interruption, terminal failure or process crash.
The application must subsequently determine whether the request was executed, partially executed, rejected, cancelled or remains unresolved, using available MT5 order and deal history.
I have reviewed the official MQL5 documentation for "MqlTradeResult", "HistorySelect()", historical orders and deals, and trade transaction events. I would appreciate clarification on the following platform-level questions.
1. Durable request correlation
- Is "MqlTradeResult.request_id" persisted in historical order or deal records?
- Can an application recover that request ID after a terminal restart or lost response?
- Are "ORDER_MAGIC", "ORDER_COMMENT", "DEAL_MAGIC" and "DEAL_COMMENT" reliably preserved and retrievable in historical records?
- Can any of these fields serve as a guaranteed unique identifier linking a previously submitted application request to its historical order and associated deals?
2. Historical query completeness
- When "HistorySelect(from, to)" returns "true" but produces zero matching orders and deals, what exactly can an application conclude?
- Does MT5 provide any documented completeness watermark, finality indicator or guarantee that all records associated with requests in that interval have become visible?
- Can historical records appear or change after an initially successful query?
3. Multiple orders and deals
- Can a single submitted trade request result in multiple historical orders or multiple deals?
- What is the documented relationship between an originating order and its associated deals?
- Are there cases where deal corrections, cancellations or other transaction updates require an application to revise its previous interpretation of execution history?
4. Partial execution and terminal outcomes
- What is the recommended way to distinguish a fully executed request from a partially executed request whose remaining volume was cancelled or rejected?
- Which historical order and deal properties should be considered authoritative when reconstructing the executed and remaining quantities?
5. Recovery after a lost response
From the documented MT5 interfaces, is there a supported and reliable procedure for reconstructing the outcome of a specific submitted request when the original "MqlTradeResult" was never received or persisted?
If no such guarantee exists, please identify the relevant platform limitations and the assumptions an application must not make.
I am particularly interested in documented platform behaviour rather than broker-specific trading conditions. I understand that individual brokers may impose additional limitations on historical data availability and retention.
Thank you for your technical guidance.
- Bulk Operations - Trade - MetaTrader 5 for Android
- Opening and Closing Positions - Trade - MetaTrader 5 for iPhone
- Request sending result: MqlTradeResult structure