Broker Statement Reconciliation
A downloaded broker statement and the terminal's own history are supposed to tell the same story, and usually they do, right up until a row goes missing from an export, a merge tool doubles up a ticket, or a copy trading setup introduces a trade the statement never picked up. Finding that by eye across a few hundred rows is not realistic, so this script does it as a straight row-by-row match. The statement is read from a CSV in the sandbox with the header ticket, symbol, type, volume, profit. Every row is matched to terminal history by ticket number, the only field guaranteed unique on both sides, and then symbol, type, volume and profit are checked individually so a mismatch line says exactly which field disagreed rather than just flagging the ticket. The profit comparison uses a tolerance rather than an exact match. A spreadsheet export and the platform's own double-precision arithmetic round differently often enough that an exact compare would flag nearly every row as a mismatch and bury the reconciliation that actually matters under noise. Raise InpProfitTolerance if your broker's statement rounds to whole units. A ticket that appears twice inside the statement file itself is reported separately from a mismatch - it is a defect in the export, not a disagreement with the terminal, and the two causes need different follow-up. Notes and limitations - Market trades only, matched against terminal closed-trade history (MQL4: MODE_HISTORY orders; MQL5: HistorySelect deals grouped by position, see MQL4 VERSUS MQL5 DIFFERENCES). Pending orders and balance operations are not part of either side of the comparison. - The statement's own date range is not filtered by this script - only the terminal side respects InpFromDate and InpToDate. Trim the statement file itself if it covers a wider period than you want compared. - A statement using a different ticket/position numbering scheme than the terminal (some multi-account or copy-trading exports do this) cannot be matched by this script; it depends on the statement's ticket column using the same number the terminal itself would report (order ticket on MQL4, position id on MQL5). - Profit in the statement should already reflect swap and commission for the comparison to be meaningful, since terminal net is profit plus swap plus commission.
Script · MT5 · v1.0 · Free
About Broker Statement Reconciliation
Broker Statement Reconciliation is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Statement file name, Delimiter and From date. MQL source code included.
Files in the download: BrokerStatementReconciliation.ex5, BrokerStatementReconciliation.mq5, BrokerStatementReconciliation.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Statement file name | broker_statement.csv | Statement file, from MQL5\Files |
| Delimiter | DelimiterComma | Statement column separator |
| From date | 0 | From close time (1970.01.01 = no lower bound) |
| To date | 0 | To close time (1970.01.01 = up to now) |
| Profit tolerance | 0.01 | Profit difference still counted as a match |
| Volume tolerance | 0.001 | Lot difference still counted as a match |
| Write report file | true | Write a discrepancy report CSV |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Trade Copier · Alerts · MT5 Script · MQL5 Source Code