Code Review
Track MQL5 trade events before guessing why the EA entered or exited.
An accepted order request is not the same as a filled trade. OnTradeTransaction helps you capture the account event stream, then reconcile orders, deals, positions, and history so the EA can explain fills, closes, SL/TP changes, and duplicate entries.
Search intent
The developer needs to debug the trade lifecycle in an MT5 EA and understand what happened after an order send.
Cluster
Code Review
Tool path
mql5 code review
Reader
mq5 developer
Optional follow-up for MQL5 OnTradeTransaction deal tracking
Open the free desk first. Opt in only if this guide matches your compiler blocker for MQL5 OnTradeTransaction deal tracking.
Lead activation handoff
No email wait is required. After saving the opt-in, continue into the free desk with the same blocker so the visitor-to-lead-to-workflow path is measurable.
Continue in free deskChoose the workflow you want, then opt in only if you want Workfusionapp updates.
Separate order, deal, and position events
OnTradeTransaction receives transaction types from the terminal. Treat request accepted, order update, deal add, and position change as different events instead of one generic trade result.
Filter events by symbol and Magic Number
The transaction stream can include manual trades, other EAs, and account maintenance events. Filter the event context before changing your EA state.
Reconcile live events with history
After the event, use HistorySelect and HistoryDealGet* calls to read closed PnL, exit reason, commission, swap, and entry direction. Keep a processed ID set so the same deal is not counted twice.
Use the tool
Paste your handler, order-send block, and history loop into Workfusion Debugger or Code Review to build a clean event log before the next Strategy Tester or demo retest.
Related guides
Continue the EA build path.
Compiler Fixes
Fix MQL5 history and deal functions
Fix MT5 EA errors around HistoryDeals.mqh, HistoryDealGetTicket, deal properties, magic numbers, and closed-trade PnL.
Code Review
Expert Advisor state machine design
Design EA state around waiting, signal, risk-approved, order-sent, position-open, and cooldown phases.
Code Review
MQL5 logging and diagnostics for EAs
Add useful MQL5 logs that explain EA decisions without flooding the MetaTrader journal.