Interface IndicatorAttachContext

What an indicator's attach lifecycle can reach.

interface IndicatorAttachContext {
    signal?: AbortSignal;
    store: IndicatorStore;
    addPrimitive(p: IPrimitive): void;
    bars(): readonly Bar[];
    dataContext(): undefined | Readonly<ChartDataContext>;
    emit(event: string, payload: unknown): void;
    interval(): undefined | string;
    now(): number;
    paneIndex(): number;
    removePrimitive(p: IPrimitive): void;
    requestRecompute(): void;
    setDataRetry(retry: null | () => void): void;
    setDataStatus(status: IndicatorDataStatus): void;
    settings(): Readonly<IndicatorSettings>;
    subscribeDataChanges(
        listener: (change: IndicatorDataChange) => void,
    ): () => void;
    symbol(): undefined | string;
    timezone(): string;
}

Properties

signal?: AbortSignal

Instance lifetime. Aborted on removal, preserved across style changes.

Scratch this instance owns; the same object calc receives.

Methods

  • Emit on the chart's own event bus, the one chart.on(name, cb) listens to.

    The declarative alerts slot covers a condition read off the bars; this is the imperative half, for an indicator whose signal arrives from outside the calculation entirely (a subscription its attach opened).

    Parameters

    • event: string
    • payload: unknown

    Returns void

  • The instrument the chart is showing, when the host knows it.

    Hosts can supply this through IndicatorHost or Chart's explicit data context. Without a configured identity it stays undefined. External studies read dataContext to include the exchange as well.

    Returns undefined | string