Skip to content
All library documents

Building Higher-Timeframe Candles from Lower-Timeframe Data

Article TradingView scripts

Summary

This Pine library provides structures and functions for representing higher-timeframe candles alongside the lower-timeframe bars that formed them. Its candle objects hold OHLC values, bar indices and times, references to the lower-timeframe bars that supplied the open, high, low, and close, and a link to the previous candle. A helper returns higher-timeframe OHLC and timing fields for use in a security request.

The library can draw the reconstructed candle body and wicks on a chart and optionally attach a text description of its values and constituent bars. The included sample shows how to request higher-timeframe data and pass it into the builder. This is a data and visualization utility rather than a trading strategy: it defines no entries, exits, or tests. Users should account for how requested timeframe data is aligned and confirmed, since the sample uses lookahead settings that can expose information before a higher-timeframe candle is complete.

Key ideas

  • Candle objects combine higher-timeframe OHLC data with selected lower-timeframe bars and timing information.
  • The library tracks which lower-timeframe bars contain the higher-timeframe candle's open, high, low, and close.
  • A helper packages higher-timeframe OHLC values and bar metadata for use in a security request.
  • Drawing methods render candle bodies and wicks and can include a textual summary.
  • The example's lookahead configuration requires care when using the data for non-repainting analysis.

Tags

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