Historical Decision Audit
A backtest answers "was this rule profitable". This tool answers a different, often more useful question for a trader running an EA live: "did the trades this account actually took match the rule it claims to run". The two drift apart more often than expected - a manual override during a busy session, a second EA on the same symbol fighting this one, a parameter that got changed and never changed back, or a rule that was refactored and quietly stopped matching its own documented behaviour. A backtest cannot catch any of these, because a backtest never looks at what the account actually did. This EA replays the embedded rule (a fast/slow moving-average crossover, the same shape used elsewhere in this catalogue as a template rule to swap out) across the last InpBarsToAudit closed bars on the chart symbol, using the identical bar-alignment convention a live EA would use tick-by-tick, so the replay is not silently more generous than what the rule would actually have signalled in real time. It then reads this account's own order history (and any still-open positions) on the same symbol over the same window, and cross-matches each rule signal against an actual trade whose direction agrees and whose open time falls within InpMatchWindowBars bars - a tolerance window, not an exact-tick requirement, since a live EA rarely fires in the identical millisecond as a pure historical replay even when its logic is unchanged. Every rule signal with no matching trade in that window is reported MISSED - the rule wanted to trade and, as far as this account's history shows, nothing happened. Every account trade with no matching signal is reported UNEXPLAINED - something traded that the embedded rule, as currently coded, would not have signalled. Neither category alone proves a problem, but a growing UNEXPLAINED list is exactly the kind of drift this tool exists to surface before it becomes an expensive surprise. Notes and limitations - Report-only: this EA never calls OrderSend under any input combination. - The embedded rule is intentionally simple so this stays a short, auditable template; swapping in the actual rule you want to audit means editing ReplayRuleSignals() to match your live EA's real logic exactly, which is a prerequisite for the audit to mean anything. - Matching is a tolerance window on time plus exact direction agreement, not an exact-tick requirement or a match on trade size or price - this catches "did the rule and the account roughly agree", not a strict reconciliation of every trade detail. - MISSED and UNEXPLAINED counts are informational, not a verdict - a MISSED signal during a period the EA was deliberately paused, or an UNEXPLAINED trade that was a known manual intervention, are both expected and not evidence of a bug. This tool surfaces the list; interpreting it is the trader's job. - The audit runs once in OnInit, not continuously.
Expert advisor · MT4 · v1.0 · Free
About Historical Decision Audit
Historical Decision Audit is a script for MetaTrader 4 based on Moving Average. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Bars to audit, Fast ma period and Slow ma period. MQL source code included.
Files in the download: HistoricalDecisionAudit.ex4, HistoricalDecisionAudit.mq4, HistoricalDecisionAudit.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Bars to audit | 500 | How many recent closed bars to replay the rule against |
| Fast ma period | 10 | Embedded rule: fast MA period |
| Slow ma period | 30 | Embedded rule: slow MA period |
| Ma method | MODE_EMA | MA method for the embedded rule |
| Match window bars | 2 | Bars of tolerance when matching a signal to an actual trade's open time |
| Magic filter | 0 | 0 = match any of this account's trades on this symbol; else only this magic |
| Output file name | HistoricalDecisionAudit_report.csv | Written under MQL4\Files\ |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Buy/Sell Arrows · Trading Sessions · Alerts · Moving Average · MT4 Expert Advisor · MQL4 Source Code