Skip to main content

aggregate_candles

Function aggregate_candles 

Source
pub fn aggregate_candles(candles: &[Candle], multiplier: u32) -> Vec<Candle>
Expand description

Aggregate lower-timeframe candles into higher-timeframe candles.

multiplier indicates how many base candles form one HTF candle. For example, with 1H candles and multiplier = 4, you get 4H candles.

Aggregation rules per group:

  • open: first candle’s open
  • close: last candle’s close
  • high: max high across the group
  • low: min low across the group
  • volume: sum of all volumes
  • time: first candle’s time (period start)

Incomplete trailing groups (fewer than multiplier candles) are dropped.