Skip to content
All library documents

Auditing MetaTrader 5 Historical Data Before Backtesting

Article MQL5 articles

Summary

The article presents a reproducible workflow for checking MetaTrader 5 M5 history before backtesting. A Python exporter connects to broker terminals one at a time, checks terminal identity, resolves broker-specific symbol names, and caches the retrieved bars. The audit compares timestamps with an expected five-minute grid, classifies missing intervals, and reports history coverage and gaps by instrument and year so a clean aggregate percentage cannot conceal a defective period.

A comparison across three broker feeds shows substantial differences in history depth and pair coverage. The article also warns that backward paging can return synthetic bars: for an M5 request, daily timestamp spacing exposes these records more reliably than flat OHLC values, which may also occur in genuine quiet bars. A simple time-of-day breakout is then used to compare results across feeds and isolate data-driven differences. The article describes checks for lookahead and reconciliation, but its findings concern specific terminals, brokers, symbols, and cached data; audit rules must account for each feed’s session schedule and history limits.

Key ideas

  • Build an expected timestamp grid and report missing bars by instrument and year.
  • Verify terminal identity and export broker histories sequentially before caching them.
  • Daily spacing in an M5 series can reveal synthetic history that OHLC flatness alone misses.
  • Comparing one unchanged strategy across feeds helps expose how data differences affect backtest results.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.