Minimum headless chart surface needed to evaluate alerts. A host announces its writes with data:update; one update may append several bars, and the controller judges each of them in turn.

interface AlertChartHost {
    addPrimitive(primitive: IPrimitive, paneIndex?: number): void;
    alertState(): undefined | AlertsDocument;
    emit(event: string, payload: unknown): void;
    getDataContext(): undefined | Readonly<ChartDataContext>;
    indicators(): readonly (
        Pick<IndicatorApi, "values" | "id" | "paneIndex" | "series"> & Partial<
            Pick<IndicatorApi, "indicatorId">,
        >
    )[];
    on(event: string, callback: (payload: unknown) => void): () => void;
    primaryBars(): readonly Bar[];
    primaryPaneIndex(): number;
    primarySeries(): null | Pick<SeriesApi, "priceScale">;
    removePrimitive(primitive: IPrimitive): void;
    setAlertState(document: undefined | AlertsDocument): void;
    snapPrice(paneIndex: number, price: number): number;
    tickSchedule(): null | TickSchedule;
}

Methods

  • Parameters

    • event: string
    • payload: unknown

    Returns void

  • Flushes computed study values. Only required by indicator-source alerts.

    Returns readonly (
        Pick<IndicatorApi, "values" | "id" | "paneIndex" | "series"> & Partial<
            Pick<IndicatorApi, "indicatorId">,
        >
    )[]

  • Parameters

    • event: string
    • callback: (payload: unknown) => void

    Returns () => void

  • Slot of the price pane, where a price alert draws and where a drawing needs no input plot. It moves when a host puts the price pane below its studies. Optional; absent means slot 0.

    Returns number

  • Owning price scale for primary-price drag snapping, including a left axis.

    Returns null | Pick<SeriesApi, "priceScale">

  • A price rounded to the tick the pane's scale is written in.

    Optional, and unrounded is the fallback: a host that declares no tick has nothing to round to, and inventing one would move a price somebody chose.

    Parameters

    • paneIndex: number
    • price: number

    Returns number

  • The instrument's tick schedule, or null for a constant tick. A dragged price alert lands on the band its price falls in. Optional; absent keeps the source scale's one tick.

    Returns null | TickSchedule