Building Custom Candles from Smaller Bars and Exchange Data
Summary
The article describes how to combine smaller interval candlesticks into a larger interval. The synthesized bar takes its opening price and timestamp from the first source bar, its close from the last, its high and low from the maximum and minimum across the group, and its volume from the sum. A worked example aggregates hourly BTC/USDT bars into a four-hour bar.
It also shows how to extract a field such as each bar’s high into an array for a moving average, and outlines fetching a larger history directly from an exchange API when a platform’s standard retrieval returns too few bars. The method requires a target interval that is an integral multiple of the source interval and whose boundaries form complete cycles within the relevant time frame. The sample implementation depends on timestamp and timezone alignment, and the article’s code has apparent inconsistencies, so users should validate aggregation boundaries and output against their data source before relying on it.
Key ideas
- A larger candlestick can be built from smaller bars using first open, last close, maximum high, minimum low, and summed volume.
- The synthesized candle’s timestamp is taken from the first source bar in its group.
- The target interval must be an integral multiple of the source interval and align to complete cycles.
- A selected candle field can be extracted into a separate series for indicator calculations.
- Direct exchange history requests can supply more bars than a platform’s default retrieval, but timestamps and aggregation logic need validation.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.