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>): Valuesaroon
Aroon up / down over period + 1 bars (default period 14). First value at index period.
function aroon<T>(data: readonly T[], o?: LookbackOptions<T>): AroonResultatr
Average true range (Wilder). First value at index period - 1.
function atr<T>(data: readonly T[], o?: ATROptions<T>): Valuesbollinger
Bollinger Bands: basis MA ± multiplier × population standard deviation.
function bollinger<T>(data: readonly T[], o?: BollingerOptions<T>): Bandscci
Commodity Channel Index: (src − SMA) / (0.015 × mean deviation). Default source hlc3.
function cci<T>(data: readonly T[], o?: CCIOptions<T>): Valueschange
Bar-to-bar change, absolute and in percent. First value at index 1.
function change<T>(data: readonly T[], o?: SourceOptions<T>): ChangeResultcompare
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>): ValuesdefaultInputs
Default input values of a definition.
function defaultInputs<I>(def: IndicatorDefinition<I>): IdefineIndicator
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>): DMIResultdonchian
Donchian Channels: highest high, lowest low and their average over period bars.
function donchian<T>(data: readonly T[], o?: DonchianOptions<T>): BandselderImpulse
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>): ValueselderRay
Elder-ray bull and bear power ("Bull Bear Power" is their sum).
function elderRay<T>(data: readonly T[], o?: ElderRayOptions<T>): ElderRayResultema
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>): Valuesenvelope
Moving average envelope: basis × (1 ± percent / 100).
function envelope<T>(data: readonly T[], o?: EnvelopeOptions<T>): BandsfastStochastic
Fast stochastic (%K unsmoothed).
function fastStochastic<T>(
data: readonly T[],
o?: Omit<StochasticOptions<T>, "kSmoothing">,
): StochasticResultforceIndex
Raw force index: (src − src[1]) × volume. First value at index 1.
function forceIndex<T>(data: readonly T[], o?: SourceOptions<T> & OHLCVOptions<T>): ValuesheikinAshi
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>): Valuesichimoku
Ichimoku Kinko Hyo (defaults 9 / 26 / 52 / 26).
function ichimoku<T>(data: readonly T[], o?: IchimokuOptions<T>): IchimokuResultindicatorName
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>): stringkagi
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>): BandslineBreak
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>): MACDResultmfi
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>): Valuesmomentum
Momentum: src − src[n].
function momentum<T>(data: readonly T[], o?: ChangeOverOptions<T>): ValuesmovingAverage
Any moving average by type ("sma" | "ema" | "wma" | "rma" | "hma" | "tma").
function movingAverage<T>(data: readonly T[], o?: AnyMovingAverageOptions<T>): Valuesobv
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>): ValuespointAndFigure
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>): Irma
Wilder's moving average (RMA / SMMA, alpha = 1 / period) as used by RSI and ATR.
function rma<T>(data: readonly T[], o?: MovingAverageOptions<T>): Valuesroc
Rate of change in percent: 100·(src − src[n]) / src[n].
function roc<T>(data: readonly T[], o?: ChangeOverOptions<T>): Valuesrsi
Relative Strength Index (Wilder smoothing). First value at index period.
function rsi<T>(data: readonly T[], o?: RSIOptions<T>): Valuessar
Parabolic SAR (Wilder), with the standard start / increment / max parameters. First value at index 1.
function sar<T>(data: readonly T[], o?: SAROptions<T>): ValuesslowStochastic
Slow stochastic (%K smoothed by 3).
function slowStochastic<T>(
data: readonly T[],
o?: Omit<StochasticOptions<T>, "kSmoothing">,
): StochasticResultsma
Simple moving average. First value at index period - 1.
function sma<T>(data: readonly T[], o?: MovingAverageOptions<T>): ValuessmoothedForceIndex
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>): Valuesstochastic
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>): StochasticResultsupertrend
Supertrend: hl2 ± factor × ATR with trailing bands.
function supertrend<T>(data: readonly T[], o?: SupertrendOptions<T>): SupertrendResulttma
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>): ValuestrueRange
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>): Valuesvolume
Volume, its moving average and the bar direction used to color volume bars.
function volume<T>(data: readonly T[], o?: VolumeOptions<T>): VolumeResultvwap
Anchored volume weighted average price with standard deviation bands. Default source hlc3.
function vwap<T>(data: readonly T[], o?: VWAPOptions<T>): VWAPResultvwma
Volume weighted moving average: Σ(price·volume) / Σ(volume) over period bars (default 20).
function vwma<T>(data: readonly T[], o?: VWMAOptions<T>): ValueswilliamsR
Williams %R in [−100, 0]: 100·(C − HH)/(HH − LL). A flat window gives −50.
function williamsR<T>(data: readonly T[], o?: LookbackOptions<T>): Valueswma
Linearly weighted moving average (weights 1..period, newest heaviest).
function wma<T>(data: readonly T[], o?: MovingAverageOptions<T>): Values