Skip to content
All library documents

Filling Missing Time Bars in MetaTrader Charts

Article MQL5 articles

Summary

This article describes creating continuous time charts in MetaTrader 4 by inserting bars for intervals with no price changes. Its process has two stages: build a history file that fills gaps using the preceding close as the inserted bar's open, high, low, and close, then keep that history updated as new quotes arrive. A setting controls whether weekend periods remain empty or are filled as well. The article extends the method from a one-symbol script to an expert advisor that updates the offline chart on ticks, and then to handling multiple symbols and chart periods.

The document demonstrates the approach through MQL4 code and describes comparing the resulting offline charts with the original data. It is a chart-data and terminal implementation technique, not a trading signal or performance study. Inserted bars represent absent quotes rather than observed market transactions, so downstream indicators and analyses may behave differently on the continuous time series; weekend handling and the terminal's history-file behavior also constrain its use.

Key ideas

  • A continuous time chart can be made by inserting flat bars where no quote arrived during an interval.
  • History generation and live updating are separate tasks in the proposed workflow.
  • The preceding close supplies all prices for an inserted bar, while its volume is zero.
  • A weekend option determines whether some missing intervals are filled or skipped.
  • The method changes the time series presented to indicators and should not be mistaken for actual trades.

Tags

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