Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Indicators

History Gaps: find missing bars before you backtest - indicator for MetaTrader 5

Bayram Erhan Partal
Bayram Erhan Partal
  • MQL5 / MQL4 Developer at  MQL5 Freelance
  • Türkiye
  • 449
MQL5 / MQL4 developer: Expert Advisors, indicators, scripts and utilities
for MetaTrader 5 and MetaTrader 4.
I deliver code that matches your specification, and I show the proof.
With every job you get
- Source code (.mq5/.mq4) and the compiled file, inputs named as in your spec
Views:
40
Rating:
(1)
Published:
HistoryGaps.mq5 (12.69 KB) view
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

A backtest is only as good as the bars under it. MetaTrader 5 does not warn you when the history has holes: the chart simply draws the next bar, and an Expert Advisor tested over the gap never sees the move that happened inside it. The usual check, counting bars or looking for time jumps, flags every weekend and every daily break, so the real holes are lost in the noise.

This indicator reads the symbol's trading sessions from the symbol specification and expects a bar only when the market was open. Every missing bar is then sorted into one of three kinds, so you can tell a data problem from a holiday.


XAUUSD M15 since November 2023: one real hole of 2 bars, 42 short sessions around holidays, 4 days without bars

The three kinds

  • Hole: bars are missing while the session was open on both sides. This is the one that can change a backtest. Marked with a red line.
  • Short session: the market opened late or closed early, as on Thanksgiving, Christmas Eve or US bank holidays. On such a day, thin-trading gaps count here too. Usually not a data problem.
  • Day with no bars: a trading day by the session table, but not a single bar (Good Friday, 25 December, 1 January on many feeds).

What the panel shows

  • The first date checked. If it is later than you asked for, the terminal holds fewer bars: raise "Max bars in chart" in the terminal settings.
  • Coverage: the share of session bars present, with short sessions and empty days left out
  • Number of holes, bars missing in them, and the largest one with its time
  • Number of short sessions and of days with no bars
  • Whether the history reaches the current server time, or how many bars it stops short

Hover a line on the chart to see the kind, the start and end time, and the number of bars.

Input parameters

  • Days to check: counted back from the last bar.
  • Mark gaps on the chart: draw a vertical line after each hole.
  • Also mark short sessions and empty days: dotted grey lines for those as well.
  • Write a CSV report: every gap with kind, start, end and bars, saved to MQL5\Files\HistoryGaps_<symbol>_<timeframe>.csv.
  • Colours, font size: for dark and light charts.

Notes

It checks the timeframe of the chart it is on, from M1 to D1. Each new day it checks again. The session table is the broker's: if it lists hours the market never trades, those show up as holes, which is worth knowing too. A short session is a guess from where the gap sits; the CSV lets you check any of them. The indicator draws objects only and has no buffers.

Prop Firm Equity Guard daily loss and max drawdown protector Prop Firm Equity Guard daily loss and max drawdown protector

Prop Firm Equity Guard protects prop-firm challenges and funded accounts. It monitors live equity against your daily loss and max drawdown limits, then closes all positions, deletes pending orders and locks trading before the firm's limit is hit. A safety buffer makes it act early, and anything opened while locked is closed instantly. It supports static and trailing drawdown, an optional profit target lock and alerts, saves its state through restarts, and shows an on-chart dashboard with room left and a reset countdown. It works alongside manual trading and other EAs.

Trade History in R Trade History in R

Shows the closed trades of the account in R (net profit divided by the money at risk at entry): expectancy, win rate, drawdown in R, losing streak, per-symbol summary and CSV export.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.