Building Higher-Timeframe Seconds Bars from Lower-Timeframe Data
Summary
This script demonstrates a workaround for constructing higher-timeframe bars measured in seconds when the platform’s standard multi-timeframe function does not support those intervals. It groups chart data into configurable second-based intervals and stores open, high, low, close, and volume values in rolling arrays. The example uses the aggregated closes to calculate and plot an average, while also displaying the current aggregated values.
The method starts a new interval when the selected second boundary is reached. Within an interval, it updates the high and low, carries forward the latest close, and accumulates volume. The arrays retain recent bars so other calculations can use them. The code is an implementation example rather than a tested trading strategy: results depend on chart timeframe and data behavior, and the author cautions that the selected interval should exceed the chart interval. It provides no performance evidence or guidance on signals or risk.
Key ideas
- The script approximates seconds-based higher-timeframe bars by collecting data in arrays.
- Each interval begins when the current second value reaches the configured boundary.
- Highs, lows, closes, and volume are updated as the interval develops, while the open is set at its start.
- Rolling arrays allow calculations such as an average across recent aggregated closes.
- The example describes an indicator-building technique, not a validated trading strategy.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.