Loading…

Bar Data Quality Report

Every backtest, every statistic, every custom indicator assumes the bars underneath it are honest. Broker feeds are not always honest. A bad tick history, a feed gap stitched over wrong, or a symbol whose data has never really been checked can carry impossible bars - a high below the open and close, a candle with volume but zero range, a timestamp that repeats or runs backwards - and every one of those quietly poisons whatever gets built on top without ever raising an error. This script does not fix any of that. It tells you it is there. Six categories are checked in a single forward pass over the loaded window: OHLC violations (high below max(open,close), or low above min(open,close)), a zero-range bar that still carries volume, a volume-free bar that still moved, a timestamp equal to or earlier than the one before it, and a spike - a bar whose range is many times the average of the 20 bars immediately before it. The spike check is where a careless version of this script gets dishonest. Comparing every bar's range against the whole history's average makes volatile periods swamp quiet ones and the threshold means nothing. This one compares each bar only against the 20 bars that came immediately before it, so the baseline moves with the market instead of being a single number for the whole file. The first 20 bars in the loaded window have no such baseline and are deliberately never flagged as spikes, no matter how large their range looks, because flagging them would mean comparing against a baseline built from history that has not actually loaded yet. Every flagged bar can optionally be written to a CSV alongside the categorised console summary, so a suspect stretch of history can be handed to someone else, or fed into a spreadsheet, without re-running the scan. Notes and limitations - This scans only the bars already loaded into the terminal's memory for that symbol and timeframe. It does not force history to download - scroll the chart back first if the window you want is not loaded yet. - A CLEAN verdict means these six specific checks found nothing. It is not a certificate that the data is otherwise correct - a feed can be internally consistent and still be wrong relative to some other source. - The spike threshold is a multiplier, not an absolute price distance, so it behaves consistently across instruments with very different typical ranges without needing per-symbol tuning. - Real volume, where a broker provides it separately from tick volume, is not examined - only tick volume, which is what both platforms expose uniformly. - The example cap only limits what is printed and, if a CSV is written, what is buffered for the console; every flagged bar is still written to the CSV and counted in the totals regardless of the cap.

Script · MT4 · v1.0 · Free

About Bar Data Quality Report

Bar Data Quality Report is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 6 settings, such as Symbol, Timeframe and Spike multiplier. MQL source code included.

Files in the download: BarQualityReport.ex4, BarQualityReport.mq4, BarQualityReport.txt.

Settings

SettingDefaultWhat it does
SymbolSymbol to scan (blank = this chart's symbol)
TimeframePERIOD_CURRENTTimeframe to scan
Spike multiplier10.0Spike threshold: range vs the prior 20-bar average
Examples per category5Example lines printed per category
Save csvfalseAlso write every flagged bar to a CSV file
DelimiterDelimiterCommaCSV column separator

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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: Volume · Alerts · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria