Interface: IContext
Charting Library.IContext
PineJS execution context.
Properties
symbol
• symbol: ISymbolInstrument
Symbol Instrument
Methods
is_main_symbol
▸ is_main_symbol(symbol
): boolean
Checks if symbol is the main symbol
Parameters
Name | Type | Description |
---|---|---|
symbol | ISymbolInstrument | symbol to check |
Returns
boolean
true
if symbol is the main symbol
new_ctx
▸ new_ctx(): IContext
Creates a new context
Returns
new_sym
▸ new_sym(tickerid
, period
, currencyCode?
, unitId?
, subsessionId?
): ISymbolInstrument
Load a new symbol for the custom indicator
Parameters
Name | Type | Description |
---|---|---|
tickerid | string | Symbol identifier |
period | string | period for the new symbol |
currencyCode? | string | Currency code |
unitId? | string | Unit ID |
subsessionId? | string | Subsession ID |
Returns
new_unlimited_var
▸ new_unlimited_var(value?
): IPineSeries
Creates an in-memory temporary storage with unlimited depth.
Parameters
Name | Type | Description |
---|---|---|
value? | number | variable's value |
Returns
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
Name | Type | Description |
---|---|---|
value? | number | variable's value |
Returns
select_sym
▸ select_sym(i
): void
Switch context to the other symbol received through IContext.new_sym
Parameters
Name | Type | Description |
---|---|---|
i | number | the index of the symbol (0 for the main series) |
Returns
void
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
Name | Type | Description |
---|---|---|
value | number | minimum number of bars to request |
Returns
void