charton API / @chart-on/core / index / IndicatorManager
Class: IndicatorManager
Defined in: packages/core/src/indicators/manager.ts:158
Registered indicator definitions and the indicators on the chart. Saved indicators whose definition is not registered stay as pending placeholders and go live once it is.
Constructors
Constructor
new IndicatorManager(
host):IndicatorManager
Defined in: packages/core/src/indicators/manager.ts:180
Parameters
host
IndicatorHost
Returns
IndicatorManager
Properties
loading
loading:
boolean=false
Defined in: packages/core/src/indicators/manager.ts:165
Internal
True while load replaces the indicators, or a definition (un)registers and its placeholders switch state: the saved states don't change, so the chart does not report a state:change.
Accessors
access
Get Signature
get access():
AccessRule|null
Defined in: packages/core/src/indicators/manager.ts:286
The rule setAccess() set, or null when every indicator is allowed.
Returns
AccessRule | null
limit
Get Signature
get limit():
number|null
Defined in: packages/core/src/indicators/manager.ts:309
Most indicators the chart may hold, or null for no cap.
Returns
number | null
lookback
Get Signature
get lookback():
number
Defined in: packages/core/src/indicators/manager.ts:620
Most bars any live indicator needs before its first valid value.
Returns
number
Methods
add()
add<
I>(def,inputs?,options?):Indicator<I>
Defined in: packages/core/src/indicators/manager.ts:328
Add an indicator computed from the main series, by registered id or by definition (registered on first use). overlay indicators draw on the price pane; pane indicators get a new pane they own; either indicators follow options.placement. Throws on an unknown id, on unknown or invalid inputs, and when the access rule or the indicator limit refuses it (after indicator:refuse).
Type Parameters
I
I extends Record<string, InputValue>
Parameters
def
string | IndicatorDef<I>
inputs?
Partial<I> = {}
options?
IndicatorAddOptions = {}
Returns
Indicator<I>
applySet()
applySet(
set,options?):IndicatorSetResult
Defined in: packages/core/src/indicators/manager.ts:512
Add the indicators of a set made by serializeSet, replacing the saved ones unless replace is false. Each of the set's panes becomes one new pane, with its saved height. Entries that are unknown, malformed, refused or (when adding) already on the chart with the same inputs are skipped and returned, not thrown. Throws, changing nothing, when set is not a valid indicator set, and when adding its indicators fails (those added are removed again). Fires one state:change for the whole set.
Parameters
set
unknown
options?
Returns
copySet()
copySet(
indicator):IndicatorSet
Defined in: packages/core/src/indicators/manager.ts:487
Internal
indicator alone as a set, for the clipboard: on the price pane, or in a pane of its own.
Parameters
indicator
Returns
dataLoaded()
dataLoaded():
void
Defined in: packages/core/src/indicators/manager.ts:628
Internal
Main data loaded (a new symbol or interval, or older history): external data follows, fetching what the new bars need.
Returns
void
dataReset()
dataReset():
void
Defined in: packages/core/src/indicators/manager.ts:636
Internal
The data source corrected bars it had sent (data:loaded kind reset): external rows may be stale too, so fetch them again.
Returns
void
duplicate()
duplicate<
I>(indicator):Indicator<I>
Defined in: packages/core/src/indicators/manager.ts:372
Add a copy of indicator: the same inputs, visibility, intervals, plot styles, label switches and add options. An overlay's copy goes into the original's pane; a pane indicator's copy gets a new pane right below the original's. A pending indicator gets a pending copy. Throws when indicator is not on this chart, and when the access rule or the indicator limit refuses the copy (after indicator:refuse), whatever the original's restricted.
Type Parameters
I
I extends Record<string, InputValue>
Parameters
indicator
Indicator<I>
Returns
Indicator<I>
getAll()
getAll():
Indicator<Record<string,InputValue>>[]
Defined in: packages/core/src/indicators/manager.ts:425
Indicators in the order they were added, pending placeholders included.
Returns
Indicator<Record<string, InputValue>>[]
getById()
getById(
id):Indicator<Record<string,InputValue>> |undefined
Defined in: packages/core/src/indicators/manager.ts:430
The indicator with id (see Indicator.id), pending ones included.
Parameters
id
string
Returns
Indicator<Record<string, InputValue>> | undefined
getDefinitions()
getDefinitions():
IndicatorDef<Record<string,InputValue>>[]
Defined in: packages/core/src/indicators/manager.ts:259
Registered definitions in registration order, e.g. for an indicator picker.
Returns
IndicatorDef<Record<string, InputValue>>[]
intervalChanged()
intervalChanged():
void
Defined in: packages/core/src/indicators/manager.ts:396
Internal
The bar interval may have changed: show or hide indicators limited to some intervals.
Returns
void
isAllowed()
isAllowed(
type):boolean
Defined in: packages/core/src/indicators/manager.ts:291
Whether indicator id type passes the access rule, the limit aside.
Parameters
type
string
Returns
boolean
load()
load(
states):void
Defined in: packages/core/src/indicators/manager.ts:445
Replace every indicator with saved states. Throws, changing nothing, when the payload is not a list of indicator states. Unknown ids become pending placeholders; older versions go through the definition's migrate; inputs that still don't fit take their defaults and emit indicator:error.
Parameters
states
unknown
Returns
void
mergeEdits()
mergeEdits(
indicator):void
Defined in: packages/core/src/indicators/manager.ts:681
Internal
Record the edits of indicator as one undo step until called with another indicator or null, e.g. while its settings dialog is open. Edits that end where they began (a cancelled dialog) leave no step.
Parameters
indicator
Indicator<Record<string, InputValue>> | null
Returns
void
pasteSet()
pasteSet(
set):IndicatorSetResult
Defined in: packages/core/src/indicators/manager.ts:520
Internal
Add the indicators of a copied set (copySet) to the chart, also when it already shows them: a paste duplicates.
Parameters
set
unknown
Returns
refusal()
refusal(
type):IndicatorRefusal|null
Defined in: packages/core/src/indicators/manager.ts:314
Why add(type) would be refused now, or null when it would be accepted.
Parameters
type
string
Returns
IndicatorRefusal | null
register()
register<
I>(def):void
Defined in: packages/core/src/indicators/manager.ts:215
Make a definition available by id, and bring pending indicators of that id to life. Throws when the id is taken by a different definition; registering the same object again does nothing.
Type Parameters
I
I extends Record<string, InputValue>
Parameters
def
IndicatorDef<I>
Returns
void
relabel()
relabel(
previous):void
Defined in: packages/core/src/indicators/manager.ts:202
Internal
Retitle the live indicators' legend rows in the chart's language after it changed from previous. Only titles still as previous named them change, so a title the app set stays.
Parameters
previous
Returns
void
remove()
remove(
indicator):void
Defined in: packages/core/src/indicators/manager.ts:401
Remove an indicator with the drawings tied to it, and its pane when it owns one.
Parameters
indicator
Returns
void
runners()
runners():
IndicatorRunner[]
Defined in: packages/core/src/indicators/manager.ts:641
Internal
Runners of the live indicators.
Returns
IndicatorRunner[]
search()
search(
query):IndicatorDef<Record<string,InputValue>>[]
Defined in: packages/core/src/indicators/manager.ts:268
Registered definitions matching query, best first, ranked by matchRank (name, aliases, id, acronym, one typo, description, then category); ties keep registration order and an empty query returns them all. Access rules do not filter it.
Parameters
query
string
Returns
IndicatorDef<Record<string, InputValue>>[]
serialize()
serialize():
IndicatorState[]
Defined in: packages/core/src/indicators/manager.ts:435
States to save; indicators added with persist: false are left out.
Returns
serializeSet()
serializeSet(
options?):IndicatorSet
Defined in: packages/core/src/indicators/manager.ts:481
The saved indicators as a set to keep as a template: their states, the panes they share and those panes' heights relative to the price pane. appliesOn scopes the set to some intervals (see indicatorSetFits); throws when it is not a non-empty list of valid interval ranges.
Parameters
options?
appliesOn?
Returns
seriesRemoved()
seriesRemoved(
series):void
Defined in: packages/core/src/indicators/manager.ts:654
Internal
The chart removed an indicator's series itself (removeSeries, or with its pane): drop the indicator without touching the chart again.
Parameters
series
Returns
void
setAccess()
setAccess(
allow):void
Defined in: packages/core/src/indicators/manager.ts:279
Limit the indicators add() and duplicate() accept: allow is the same rule as the chart's access.allow option, asked with { kind: 'indicator', id }; null allows every indicator. Indicators already on the chart stay, and saved layouts (load()) are not restricted. The option sets this too.
Parameters
allow
AccessRule | null
Returns
void
setLimit()
setLimit(
limit):void
Defined in: packages/core/src/indicators/manager.ts:300
Cap how many indicators the chart holds, pending ones included: add() and duplicate() refuse more. null removes the cap. Indicators already past a lowered cap stay. Throws unless null or a non-negative integer.
Parameters
limit
number | null
Returns
void
syncBars()
syncBars(
bars,change,count?):void
Defined in: packages/core/src/indicators/manager.ts:646
Internal
The main bars changed by change: hand them to the live indicators' runners.
Parameters
bars
readonly Bar[]
change
"reset" | "append" | "prepend" | "tick"
count?
number = 0
Returns
void
unregister()
unregister(
id):void
Defined in: packages/core/src/indicators/manager.ts:246
Forget a definition. Its indicators stay on the chart as pending placeholders.
Parameters
id
string
Returns
void