Interface IndicatorDescriptor

interface IndicatorDescriptor {
    category?: string;
    id: string;
    inputs: readonly IndicatorInput[];
    name: string;
    placement: "onchart" | "pane";
    plots: readonly IndicatorPlot[];
    attach(ctx: IndicatorAttachContext): void | () => void;
    calc(
        bars: readonly Bar[],
        settings: Readonly<IndicatorSettings>,
        store: IndicatorStore,
    ): IndicatorValues;
    calcTail(
        bars: readonly Bar[],
        settings: Readonly<IndicatorSettings>,
        fromIndex: number,
        previous: IndicatorValues,
        store: IndicatorStore,
    ): null | IndicatorValues;
    levels(settings: Readonly<IndicatorSettings>): readonly IndicatorLevel[];
    range(
        settings: Readonly<IndicatorSettings>,
    ): null | { max: number; min: number };
}

Properties

category?: string

Grouping for a picker UI ('Trend', 'Momentum', 'Volume', 'Volatility').

id: string

Registry key, e.g. 'macd'.

inputs: readonly IndicatorInput[]
name: string

Display name, e.g. 'MACD'.

placement: "onchart" | "pane"

'onchart' overlays the price pane; 'pane' gets its own pane.

plots: readonly IndicatorPlot[]

Methods

  • Optional per-instance lifecycle, for indicators whose data is not derived from the chart's bars (open interest, CVD, an external feed). Called once when the instance is created; return a teardown function.

    Fetch into ctx.store, then call ctx.requestRecompute()calc runs again and reads what you stored.

    Parameters

    Returns void | () => void

  • Optional incremental path, called instead of calc when only the tail changed (a live tick). Return values for indices [fromIndex, bars.length) — the runtime splices them onto the previous result — or null to fall back to a full calc.

    Without it every tick costs a full recompute. That is a few hundred microseconds for one indicator over 50k bars, but it is O(n) per tick per indicator, so implement this for anything meant to run in a busy live pane.

    Parameters

    Returns null | IndicatorValues

  • Optional fixed price range for the indicator's own pane (RSI 0..100). Applied only when the indicator creates its pane — two indicators sharing a pane would otherwise fight over it.

    Parameters

    Returns null | { max: number; min: number }