Loading…

Backtest Versus Live Checker

A strategy that backtests beautifully and then underperforms live is usually not a broken strategy - it is a strategy that was quietly tested under conditions that do not match live trading. The gaps are well known individually: the Strategy Tester's default spread is often tighter and more constant than a real live spread; short backtests can start before an indicator has enough bars to warm up the same way it would live; and the tester's tick-generation model ("every tick" versus "open prices only") changes how intrabar logic behaves in ways that never show up from reading the code. This EA does not trade. Attached to the same symbol and timeframe you plan to run a strategy on, it reports the current spread against a configurable expectation for real live spread, flags when fewer bars are available than a chosen warm-up minimum, and shows the gap between local time and server time - meaningless while testing, since tester time is simulated, but a useful live sanity check if a feed has stalled. A tick-count heuristic approximates tester modelling quality: a low, flat tick count on each bar suggests "open prices only" modelling, while a steadily climbing count suggests "every tick" or real live ticks - explicitly labelled as a heuristic, not proof, since MQL4 exposes no direct way to read the tester's modelling-quality setting. When file logging is on, each closed bar is appended as one CSV row, tagged Testing, Testing-Visual or Live in both the row and the filename, so a tester run and a live or demo run on the identical symbol and period produce two files that can be opened side by side to see exactly where their numbers first start to disagree. Notes and limitations - This EA places no trades and manages no positions - it is a read-only diagnostic tool. - The tick-count heuristic is exactly that - a heuristic. MQL4 does not expose the Strategy Tester's modelling-quality setting directly, so this infers a rough signal from tick volume rather than reading it. - The local-time-versus-server-time comparison is meaningless while testing, because tester time is simulated rather than real. It is a live and demo sanity check only. - CSV files accumulate across runs by appending rather than overwriting; delete old files between comparisons if a clean pair is wanted.

Expert advisor · MT5 · v1.0 · Free

About Backtest Versus Live Checker

Backtest Versus Live Checker is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Min bars required, Expected live spread points and Log to file. MQL source code included.

Files in the download: BacktestLiveChecker.ex5, BacktestLiveChecker.mq5, BacktestLiveChecker.txt.

Settings

SettingDefaultWhat it does
Min bars required200Warn if fewer bars than this are available for indicators to warm up
Expected live spread points20.0A realistic live spread, in points, for comparison
Log to filetrueAppend one CSV row per closed bar to the sandbox Files folder
Show tick heuristictrueShow the per-bar tick-count heuristic for tester modelling quality

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria