Functions

Functions exported by @reincharts/indicators.

import { adx, aroon, atr, ... } from "@reincharts/indicators";

adx

ADX only (see dmi).

function adx<T>(data: readonly T[], o?: DMIOptions<T>): Values

aroon

Aroon up / down over period + 1 bars (default period 14). First value at index period.

function aroon<T>(data: readonly T[], o?: LookbackOptions<T>): AroonResult

atr

Average true range (Wilder). First value at index period - 1.

function atr<T>(data: readonly T[], o?: ATROptions<T>): Values

bollinger

Bollinger Bands: basis MA ± multiplier × population standard deviation.

function bollinger<T>(data: readonly T[], o?: BollingerOptions<T>): Bands

cci

Commodity Channel Index: (src − SMA) / (0.015 × mean deviation). Default source hlc3.

function cci<T>(data: readonly T[], o?: CCIOptions<T>): Values

change

Bar-to-bar change, absolute and in percent. First value at index 1.

function change<T>(data: readonly T[], o?: SourceOptions<T>): ChangeResult

compare

Percent change of a series relative to its first defined value at or after baseIndex (e.g. compare(data, { source: (d) => d.AAPL })), used to compare symbols. Values before the base are undefined. Values are in percent (12.5 = +12.5%).

function compare<T>(data: readonly T[], o?: CompareOptions<T>): Values

defaultInputs

Default input values of a definition.

function defaultInputs<I>(def: IndicatorDefinition<I>): I

defineIndicator

Identity helper that types a custom indicator definition.

function defineIndicator<I>(def: IndicatorDefinition<I>): IndicatorDefinition<I>

dmi

Directional Movement Index (+DI, −DI) and ADX (Wilder smoothing).

function dmi<T>(data: readonly T[], o?: DMIOptions<T>): DMIResult

donchian

Donchian Channels: highest high, lowest low and their average over period bars.

function donchian<T>(data: readonly T[], o?: DonchianOptions<T>): Bands

elderImpulse

Elder impulse system: 1 (green) when both the EMA and the MACD histogram rise, −1 (red) when both fall, 0 (neutral / blue) otherwise; undefined until both are available.

function elderImpulse<T>(data: readonly T[], o?: ElderImpulseOptions<T>): Values

elderRay

Elder-ray bull and bear power ("Bull Bear Power" is their sum).

function elderRay<T>(data: readonly T[], o?: ElderRayOptions<T>): ElderRayResult

ema

Exponential moving average (alpha = 2 / (period + 1)), seeded with the SMA of the first period values.

function ema<T>(data: readonly T[], o?: MovingAverageOptions<T>): Values

envelope

Moving average envelope: basis × (1 ± percent / 100).

function envelope<T>(data: readonly T[], o?: EnvelopeOptions<T>): Bands

fastStochastic

Fast stochastic (%K unsmoothed).

function fastStochastic<T>(
    data: readonly T[],
    o?: Omit<StochasticOptions<T>, "kSmoothing">,
): StochasticResult

forceIndex

Raw force index: (src − src[1]) × volume. First value at index 1.

function forceIndex<T>(data: readonly T[], o?: SourceOptions<T> & OHLCVOptions<T>): Values

heikinAshi

Heikin Ashi bars: close = (O+H+L+C)/4, open = (prev open + prev close)/2 (first bar: (O+C)/2), high = max(H, open, close), low = min(L, open, close). Returns NEW bars, 1:1 with data.

function heikinAshi<T>(data: readonly T[], o?: OHLCVOptions<T>): HeikinAshiBar<T>[]

hma

Hull moving average: WMA(2·WMA(n/2) − WMA(n), √n). First value at period + floor(√period) - 2.

function hma<T>(data: readonly T[], o?: MovingAverageOptions<T>): Values

ichimoku

Ichimoku Kinko Hyo (defaults 9 / 26 / 52 / 26).

function ichimoku<T>(data: readonly T[], o?: IchimokuOptions<T>): IchimokuResult

indicatorName

Legend name: short name followed by number and source inputs, plus select inputs that differ from their default ("RSI 14 close", "BB 20 close 2", "MA 9 close ema").

function indicatorName<I>(def: IndicatorDefinition<I>, inputs?: Partial<I>): string

kagi

Kagi lines: the line extends while price keeps its direction and reverses after moving reversal against it.

function kagi<T>(data: readonly T[], o?: KagiOptions<T>): KagiLine[]

keltner

Keltner Channels: MA ± multiplier × ATR (defaults: EMA 20, ×2, ATR 10).

function keltner<T>(data: readonly T[], o?: KeltnerOptions<T>): Bands

lineBreak

Line break (three line break by default): a new line in the trend direction for every new close beyond the last line; a reversal line only when the close breaks the extreme of the last lines lines.

function lineBreak<T>(data: readonly T[], o?: LineBreakOptions<T>): LineBreakBar[]

macd

Moving Average Convergence Divergence.

function macd<T>(data: readonly T[], o?: MACDOptions<T>): MACDResult

mfi

Money Flow Index (volume weighted RSI) on hlc3 by default. Money flow starts at the second bar, so the first value is at index period.

function mfi<T>(data: readonly T[], o?: MFIOptions<T>): Values

momentum

Momentum: src − src[n].

function momentum<T>(data: readonly T[], o?: ChangeOverOptions<T>): Values

movingAverage

Any moving average by type ("sma" | "ema" | "wma" | "rma" | "hma" | "tma").

function movingAverage<T>(data: readonly T[], o?: AnyMovingAverageOptions<T>): Values

obv

On-balance volume: cumulative volume signed by the direction of the source. Starts at 0.

function obv<T>(data: readonly T[], o?: SourceOptions<T> & OHLCVOptions<T>): Values

pointAndFigure

Point & figure columns. Returns NEW bars (one per column) to use as chart data.

function pointAndFigure<T>(data: readonly T[], o?: PointAndFigureOptions<T>): PointAndFigureColumn[]

renko

Traditional renko: a new brick each time the price moves one box beyond the last brick's top (up) or bottom (down) — reversals therefore need two boxes from the last close. Returns NEW bars.

function renko<T>(data: readonly T[], o?: RenkoOptions<T>): RenkoBrick[]

resolveInputs

Defaults merged with partial inputs (undefined values fall back to defaults).

function resolveInputs<I>(def: IndicatorDefinition<I>, inputs?: Partial<I>): I

rma

Wilder's moving average (RMA / SMMA, alpha = 1 / period) as used by RSI and ATR.

function rma<T>(data: readonly T[], o?: MovingAverageOptions<T>): Values

roc

Rate of change in percent: 100·(src − src[n]) / src[n].

function roc<T>(data: readonly T[], o?: ChangeOverOptions<T>): Values

rsi

Relative Strength Index (Wilder smoothing). First value at index period.

function rsi<T>(data: readonly T[], o?: RSIOptions<T>): Values

sar

Parabolic SAR (Wilder), with the standard start / increment / max parameters. First value at index 1.

function sar<T>(data: readonly T[], o?: SAROptions<T>): Values

slowStochastic

Slow stochastic (%K smoothed by 3).

function slowStochastic<T>(
    data: readonly T[],
    o?: Omit<StochasticOptions<T>, "kSmoothing">,
): StochasticResult

sma

Simple moving average. First value at index period - 1.

function sma<T>(data: readonly T[], o?: MovingAverageOptions<T>): Values

smoothedForceIndex

Elder's force index smoothed by a moving average ("Elder Force Index").

function smoothedForceIndex<T>(
    data: readonly T[],
    o?: SmoothedForceIndexOptions<T>,
): { force: Values; smoothed: Values; }

stddev

Rolling population standard deviation.

function stddev<T>(data: readonly T[], o?: StdDevOptions<T>): Values

stochastic

Full stochastic oscillator: %K = 100·(C − LL)/(HH − LL) smoothed by kSmoothing, %D = SMA(%K). A flat window (HH = LL) gives 50.

function stochastic<T>(data: readonly T[], o?: StochasticOptions<T>): StochasticResult

supertrend

Supertrend: hl2 ± factor × ATR with trailing bands.

function supertrend<T>(data: readonly T[], o?: SupertrendOptions<T>): SupertrendResult

tma

Triangular moving average (double smoothed SMA, weights 1, 2, ..., 2, 1). First value at period - 1.

function tma<T>(data: readonly T[], o?: MovingAverageOptions<T>): Values

trueRange

True range per bar: max(H − L, |H − prevC|, |L − prevC|). The first bar is H − L.

function trueRange<T>(data: readonly T[], o?: OHLCVOptions<T>): Values

volume

Volume, its moving average and the bar direction used to color volume bars.

function volume<T>(data: readonly T[], o?: VolumeOptions<T>): VolumeResult

vwap

Anchored volume weighted average price with standard deviation bands. Default source hlc3.

function vwap<T>(data: readonly T[], o?: VWAPOptions<T>): VWAPResult

vwma

Volume weighted moving average: Σ(price·volume) / Σ(volume) over period bars (default 20).

function vwma<T>(data: readonly T[], o?: VWMAOptions<T>): Values

williamsR

Williams %R in [−100, 0]: 100·(C − HH)/(HH − LL). A flat window gives −50.

function williamsR<T>(data: readonly T[], o?: LookbackOptions<T>): Values

wma

Linearly weighted moving average (weights 1..period, newest heaviest).

function wma<T>(data: readonly T[], o?: MovingAverageOptions<T>): Values

On this page