Skip to main content

LibraryPineStudy<TPineStudyResult>

Interface

Type parameters

Name
TPineStudyResult

Indexable

[key: string]: any

Methods

init

Optional

The method is designed to get additional information for an indicator and allows you to initialize variables needed for your data calculations. For example, you can reset a counter with this method. The library calls init when the indicator should be calculated from scratch. For more information, refer to the Constructor article.

Example:

this.init = function(context, inputCallback) {
var symbol = '#EQUITY';
var period = PineJS.Std.period(this._context);
context.new_sym(symbol, period);
};

Signature

init(ctx: IContext, inputs: Function) => void

Parameters

NameTypeDescription
ctxIContextAn object containing symbol info along with some useful methods to load/store symbol
inputs<T>(index: number) => TThe inputs callback is an array of input values, placed in order of inputs in Metainfo.

Returns

void


main

Called every time the library wants to calculate the study. Also it's called for every bar of every symbol. Thus, if you request several additional symbols inside your indicator it will increase the count of runs.

Signature

main(ctx: IContext, inputs: Function) => TPineStudyResult

Parameters

NameTypeDescription
ctxIContextAn object containing symbol info along with some useful methods to load/store symbol
inputs<T>(index: number) => TThe inputs callback is an array of input values, placed in order of inputs in Metainfo.

Returns

TPineStudyResult