Discussing the article: "Trust Your Backtest Data First: Building a Reproducible Historical Data Audit in Python for MetaTrader 5"

 

Check out the new article: Trust Your Backtest Data First: Building a Reproducible Historical Data Audit in Python for MetaTrader 5.

A reproducible, read-only Python audit for MetaTrader 5 that verifies history quality before any backtest. It exports M5 data from multiple terminals, detects gaps and synthetic bars by timestamp spacing, and reports coverage per year. The same deterministic strategy then runs on three broker feeds over a common window to quantify result drift and decompose it into spread, data/price, and trade effects.

Every backtest result inherits the quality of its input data, yet few people check that data before computing statistics. Traders routinely see MetaTrader 5's built‑in “History Quality” drop from 99% to 30% without knowing why. Others discover too late that their feed had silent gaps in the exact period they tested. The forums are full of the same question — "how do I verify my history is complete across several pairs?" — and the usual answer is "write a script yourself."

This article is that script. It builds a reproducible, read‑only data audit that you run once before trusting any backtest. Then it shows why the audit matters by running the same trivial strategy on data from three brokers and measuring the result drift. The brokers are anonymized throughout (Broker A, B, C) — the point is not who is "best," but that "the same backtest" is an illusion the moment the data underneath it changes.

Everything here is reproducible. Full Python source is attached; it imports only read-only functions (API calls) from the MetaTrader 5 package and never touches an order function.


Author: Jan Kahlert