Indicators
applyIndicators, EmaIndicator, IndicatorConfig, IndicatorResult and 2 more: generated from the source of active-charts.
Exported by @workspace/. Generated from the package source; part of the index of every export.
Functions, hooks and constants#
Applies indicators to chart data, adding computed values as new keys on each datum. Returns the enriched data (new array, original data untouched) plus metadata for rendering the indicator series as lines.
Generated keys: __, __, __ and __. When an indicator's source differs from default, _ is appended (for example __), so indicators of the same kind and period on different source keys do not overwrite each other.
A period that is not a whole number of at least 1 yields null for every point.
(data: ChartDatum[], indicators: IndicatorConfig[], t: ChartTranslateFn, defaultSourceKey?: string) => { enrichedData: ChartDatum[]; indicatorSeries: IndicatorResult[]; }Types#
interface EmaIndicator {
type: 'ema';
period: number;
sourceKey?: string;
stroke?: string;
name?: string;
}type IndicatorConfig = SmaIndicator | EmaIndicator | MacdIndicator;interface IndicatorResult {
key: string;
name: string;
stroke: string;
lineDash?: number[];
}interface MacdIndicator {
type: 'macd';
fastPeriod?: number;
slowPeriod?: number;
signalPeriod?: number;
sourceKey?: string;
macdStroke?: string;
signalStroke?: string;
name?: string;
}interface SmaIndicator {
type: 'sma';
period: number;
sourceKey?: string;
stroke?: string;
name?: string;
}