Skip to content
EliteChart

appendHeikinAshiBar

Documentation


Documentation / @elitechart/core / appendHeikinAshiBar

code
function appendHeikinAshiBar(prev, raw): Bar;

Defined in: series/heikin-ashi.ts:44

Compute one Heikin-Ashi bar from the previous HA bar + the new raw OHLCV bar. Pure / deterministic — no module-level state.

Parameters

prev

Bar | undefined

— the previous HA bar, or undefined for the first bar in a series (uses the canonical bar-0 seed).

raw

Bar

— the raw OHLCV bar to transform.

Returns

Bar

the HA-projected bar with time + volume carried over.

Throws

when raw contains non-finite numbers — silent NaN propagation would poison every later HA bar via the recursion.

Example

code
import { appendHeikinAshiBar } from '@elitechart/core';
let prev: Bar | undefined;
const ha = bars.map((b) => (prev = appendHeikinAshiBar(prev, b)));