Skip to main content

Interface: IContext

Charting Library.IContext

PineJS execution context.

Properties​

symbol​

Symbol Instrument

Methods​

is_main_symbol​

is_main_symbol(symbol): boolean

Checks if symbol is the main symbol

Parameters​

NameTypeDescription
symbolISymbolInstrumentsymbol to check

Returns​

boolean — true if symbol is the main symbol


new_ctx​

new_ctx(): IContext

Creates a new context

Returns​

IContext


new_sym​

new_sym(tickerid, period, currencyCode?, unitId?, subsessionId?): ISymbolInstrument

Load a new symbol for the custom indicator

Parameters​

NameTypeDescription
tickeridstringSymbol identifier
periodstringperiod for the new symbol
currencyCode?stringCurrency code
unitId?stringUnit ID
subsessionId?stringSubsession ID

Returns​

ISymbolInstrument


new_unlimited_var​

new_unlimited_var(value?): IPineSeries

Creates an in-memory temporary storage with unlimited depth.

Parameters​

NameTypeDescription
value?numbervariable's value

Returns​

IPineSeries


new_var​

new_var(value?): IPineSeries

Creates an in-memory temporary storage with depth defined by the first call new_var(value).get(n)

Parameters​

NameTypeDescription
value?numbervariable's value

Returns​

IPineSeries


select_sym​

select_sym(i): void

Switch context to the other symbol received through IContext.new_sym

Parameters​

NameTypeDescription
inumberthe index of the symbol (0 for the main series)

setMinimumAdditionalDepth​

setMinimumAdditionalDepth(value): void

Allows you to specify how many data points beyond the visible range the library should request. You should use this method only in exceptional cases.

By default, the library request data for the visible range and some additional data points required for calculations. For example, if you calculate 10-period Moving Average with the PineJSStd.sma function, the library will request at least 10 extra bars of historical data.

However, the library cannot determine the number of extra bars when your indicator depends on another indicator (chained calculations). In this exceptional case, you can specify this number using the setMinimumAdditionalDepth method. Consider the Custom Moving Average example, where a series is calculated and then used as an input for the second calculation.

Parameters​

NameTypeDescription
valuenumberminimum number of bars to request