Skip to content

charton API


charton API / @chart-on/core / index / Indicator

Class: Indicator<I> ​

Defined in: packages/core/src/indicators/indicator.ts:74

Handle returned by chart.indicators.add. While its definition is not registered (e.g. restored from saved state before the app registered it), the indicator is pending: it keeps its saved state and draws nothing.

Type Parameters ​

I ​

I extends Record<string, InputValue> = Record<string, InputValue>

Constructors ​

Constructor ​

new Indicator<I>(state, options, owner): Indicator<I>

Defined in: packages/core/src/indicators/indicator.ts:92

Parameters ​

state ​

IndicatorState

Saved state, used while pending.

options ​

Options the indicator was added with.

legend? ​

boolean

persist? ​

boolean

placement? ​

"overlay" | "pane"

priceScale? ​

string

renderer? ​

"canvas" | "gpu"

owner ​

IndicatorOwner

Returns ​

Indicator<I>

Properties ​

live ​

live: LiveIndicator | null = null

Defined in: packages/core/src/indicators/indicator.ts:76

Internal

Set while the definition is registered.


options ​

readonly options: object

Defined in: packages/core/src/indicators/indicator.ts:96

Internal

Options the indicator was added with.

legend? ​

optional legend?: boolean

persist? ​

optional persist?: boolean

placement? ​

optional placement?: "overlay" | "pane"

priceScale? ​

optional priceScale?: string

renderer? ​

optional renderer?: "canvas" | "gpu"


removed ​

removed: boolean = false

Defined in: packages/core/src/indicators/indicator.ts:78

Internal

Set once the indicator is no longer on the chart.


state ​

state: IndicatorState

Defined in: packages/core/src/indicators/indicator.ts:94

Internal

Saved state, used while pending.

Accessors ​

def ​

Get Signature ​

get def(): IndicatorDef<I> | null

Defined in: packages/core/src/indicators/indicator.ts:122

The definition, or null while pending.

Returns ​

IndicatorDef<I> | null


edits ​

Get Signature ​

get edits(): IndicatorEdits

Defined in: packages/core/src/indicators/indicator.ts:344

Internal

The part of the state undo steps of edits keep.

Returns ​

IndicatorEdits


hiddenByInterval ​

Get Signature ​

get hiddenByInterval(): boolean

Defined in: packages/core/src/indicators/indicator.ts:254

True while visibleOn excludes the chart's current interval, so nothing is drawn.

Returns ​

boolean


id ​

Get Signature ​

get id(): string

Defined in: packages/core/src/indicators/indicator.ts:107

The indicator's id, unique on its chart, e.g. 'ind-3': drawings tie to it through Drawing.indicator. Saved with the indicator and kept by load; copies and indicators added from a set get a new one.

Returns ​

string


inputs ​

Get Signature ​

get inputs(): Readonly<I>

Defined in: packages/core/src/indicators/indicator.ts:144

Returns ​

Readonly<I>


labelOptions ​

Get Signature ​

get labelOptions(): Readonly<IndicatorLabelOptions>

Defined in: packages/core/src/indicators/indicator.ts:331

Price-axis label switches: lastValueLabel (default true) and axisTitle (default false).

Returns ​

Readonly<IndicatorLabelOptions>


legendFolded ​

Get Signature ​

get legendFolded(): boolean

Defined in: packages/core/src/indicators/indicator.ts:241

Internal

Whether the legend row shows only the title (see chart.setLegendFolded); saved with the indicator.

Returns ​

boolean


lookback ​

Get Signature ​

get lookback(): number

Defined in: packages/core/src/indicators/indicator.ts:185

Bars needed before the first valid value (the definition's lookback); 0 while pending.

Returns ​

number


message ​

Get Signature ​

get message(): string | null

Defined in: packages/core/src/indicators/indicator.ts:382

Text shown in the indicator's pane, or null: the reason from supports, a fetch error, or the message given to setError.

Returns ​

string | null


pane ​

Get Signature ​

get pane(): Pane | null

Defined in: packages/core/src/indicators/indicator.ts:140

The pane the plots are in, or null while pending.

Returns ​

Pane | null


pending ​

Get Signature ​

get pending(): boolean

Defined in: packages/core/src/indicators/indicator.ts:117

True while the definition is not registered: nothing is drawn. False once removed.

Returns ​

boolean


placement ​

Get Signature ​

get placement(): "overlay" | "pane" | null

Defined in: packages/core/src/indicators/indicator.ts:135

Where the indicator draws: on the price pane ('overlay') or in a pane of its own ('pane'). Null while pending, since the definition decides.

Returns ​

"overlay" | "pane" | null


plotStyles ​

Get Signature ​

get plotStyles(): Readonly<Record<string, Readonly<PlotStyle>>>

Defined in: packages/core/src/indicators/indicator.ts:283

Plot styles set over the definition's, by plot id: only the members that differ from it. Empty when every plot draws as declared.

Returns ​

Readonly<Record<string, Readonly<PlotStyle>>>


priceScale ​

Get Signature ​

get priceScale(): string

Defined in: packages/core/src/indicators/indicator.ts:158

Price scale id the plots draw on: the one given to add, else the definition's priceScale, else 'right'.

Returns ​

string


series ​

Get Signature ​

get series(): IndicatorSeries | null

Defined in: packages/core/src/indicators/indicator.ts:127

The series drawing the plots, or null while pending.

Returns ​

IndicatorSeries | null


status ​

Get Signature ​

get status(): IndicatorStatus

Defined in: packages/core/src/indicators/indicator.ts:374

Load state of the indicator's external data (fetch / subscribe): idle, loading, loaded, empty or error. Indicators without external data stay idle unless the app calls setError.

Returns ​

IndicatorStatus


type ​

Get Signature ​

get type(): string

Defined in: packages/core/src/indicators/indicator.ts:112

Definition id.

Returns ​

string


values ​

Get Signature ​

get values(): Readonly<Record<string, Float64Array>>

Defined in: packages/core/src/indicators/indicator.ts:180

Latest output arrays (one value per bar, NaN = none), keyed by plot id. Empty while pending.

Returns ​

Readonly<Record<string, Float64Array>>


visible ​

Get Signature ​

get visible(): boolean

Defined in: packages/core/src/indicators/indicator.ts:149

Whether the user shows the indicator; it may still be hidden on this interval (see hiddenByInterval).

Returns ​

boolean


visibleOn ​

Get Signature ​

get visibleOn(): readonly IntervalRange[] | null

Defined in: packages/core/src/indicators/indicator.ts:221

Intervals the indicator shows on, or null for every interval.

Returns ​

readonly IntervalRange[] | null

Methods ​

adoptPlotStyles() ​

adoptPlotStyles(def): Readonly<Record<string, PlotStyle>>

Defined in: packages/core/src/indicators/indicator.ts:325

Internal

Going live with def: keep the plot styles that fit it, and return them for the series.

Parameters ​

def ​

IndicatorDef

Returns ​

Readonly<Record<string, PlotStyle>>


applyInputs() ​

applyInputs(inputs): void

Defined in: packages/core/src/indicators/indicator.ts:194

Merge new input values and recompute. Throws on unknown or invalid inputs. While pending, only values no input type accepts throw; the rest are kept and checked once the definition is registered.

Parameters ​

inputs ​

Partial<I>

Returns ​

void


applyLabelOptions() ​

applyLabelOptions(options): void

Defined in: packages/core/src/indicators/indicator.ts:336

Turn the indicator's last-value labels, or the title tag beside them, on or off. Kept while pending.

Parameters ​

options ​

Partial<IndicatorLabelOptions>

Returns ​

void


clearError() ​

clearError(): void

Defined in: packages/core/src/indicators/indicator.ts:393

Clear an error set with setError; the status goes back to what the data feed reports.

Returns ​

void


getPlotStyle() ​

getPlotStyle(id): PlotStyle | null

Defined in: packages/core/src/indicators/indicator.ts:292

The style plot id draws with: line width and style (line plots only) and visibility, the definition's with plotStyles over it. Null for an unknown plot, and while pending.

Parameters ​

id ​

string

Returns ​

PlotStyle | null


refetch() ​

refetch(): void

Defined in: packages/core/src/indicators/indicator.ts:400

Drop the fetched rows (or other intervals' bars) and load them again; does nothing without fetch, subscribe or intervals.

Returns ​

void


refreshStatus() ​

refreshStatus(): void

Defined in: packages/core/src/indicators/indicator.ts:411

Internal

Push the current status to the series and tell listeners when it changed.

Returns ​

void


remove() ​

remove(): void

Defined in: packages/core/src/indicators/indicator.ts:420

Remove the indicator, and its pane when it owns one.

Returns ​

void


restoreEdits() ​

restoreEdits(edits): void

Defined in: packages/core/src/indicators/indicator.ts:351

Internal

Put back edits taken earlier.

Parameters ​

edits ​

IndicatorEdits

Returns ​

void


serialize() ​

serialize(): IndicatorState

Defined in: packages/core/src/indicators/indicator.ts:425

Current state; a pending indicator returns its saved state unchanged.

Returns ​

IndicatorState


setError() ​

setError(message): void

Defined in: packages/core/src/indicators/indicator.ts:387

Show an error from the app (e.g. its own data feed failed): status error and message in the pane.

Parameters ​

message ​

string

Returns ​

void


setFeedStatus() ​

setFeedStatus(status, message): void

Defined in: packages/core/src/indicators/indicator.ts:405

Internal

The external data feed's state changed.

Parameters ​

status ​

IndicatorStatus

message ​

string | null

Returns ​

void


setLegendFolded() ​

setLegendFolded(folded): void

Defined in: packages/core/src/indicators/indicator.ts:246

Internal

Fold or unfold the legend row; chart.setLegendFolded calls this for an indicator's series.

Parameters ​

folded ​

boolean

Returns ​

void


setPlotStyle() ​

setPlotStyle(id, style): void

Defined in: packages/core/src/indicators/indicator.ts:306

Set plot id's line width, line style or visibility over the definition's; members left out keep their current value, and a value equal to the definition's stops overriding it. null puts the plot back as declared. Throws on an unknown plot, an invalid value, or a line width or style for a histogram. While pending the plot is not known yet: the style is kept and checked once the definition is registered. Saved with the indicator; input changes keep it.

Parameters ​

id ​

string

style ​

PlotStyle | null

Returns ​

void


setPriceScale() ​

setPriceScale(id): void

Defined in: packages/core/src/indicators/indicator.ts:168

Draw the plots on price scale id of their pane: 'right' (the pane's main scale), 'left' (shows a left axis while the indicator is visible) or any other id (a scale of its own, with no axis). Throws on an empty id. Kept while pending and saved with the indicator.

Parameters ​

id ​

string

Returns ​

void


setVisible() ​

setVisible(visible): void

Defined in: packages/core/src/indicators/indicator.ts:212

Parameters ​

visible ​

boolean

Returns ​

void


setVisibleOn() ​

setVisibleOn(ranges): void

Defined in: packages/core/src/indicators/indicator.ts:232

Show the indicator only on bar intervals inside ranges (null or []: every interval). Elsewhere it stays on the chart and in the legend, but draws nothing. Throws on an invalid interval or a range whose from is longer than its to. Kept while pending and saved with the indicator.

Parameters ​

ranges ​

readonly IntervalRange[] | null

Returns ​

void


syncInterval() ​

syncInterval(): void

Defined in: packages/core/src/indicators/indicator.ts:264

Internal

Hide or show the series for the chart's current interval.

Returns ​

void