IPineSeries
Interface
Methods
adopt
Map some values from one time scale to another.
Example
// A pine series with values [5, 5]
const sourceTimes = ctx.new_var();
// A pine series with values [4, 5]
const destinationTimes = ctx.new_var();
// A pine series with values [1, 2]
const values = ctx.new_var();
// Creates a pine series with values [2, 2]
const adopted1 = values.adopt(sourceTimes, destinationTimes, 0);
// Creates a pine series with values [NaN, 2]
const adopted2 = values.adopt(sourceTimes, destinationTimes, 1);
Example
Psuedocode of the adopt algorithm:
adopt(sourceSeries, destinationSeries, mode) =
destinationValue = most recent value in destinationSeries
sourceIndex = index of destinationValue in sourceSeries
if mode equals 1 then
previousDestinationValue = second most recent value in destinationSeries
previousSourceIndex = index of previousDestinationValue in sourceSeries
if sourceIndex equals previousSourceIndex
return NaN
return value at sourceIndex
Signature
adopt(source: IPineSeries, destination: IPineSeries, mode: 0 | 1) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Source times. |
destination | IPineSeries | Destination times. |
mode | 0 | 1 | Adopt mode. 0 for continuous, 1 for precise. In continuous mode (0 ) every source time will be mapped to a destination time if one exists. Multiple source times may be mapped to the same destination time. In precise mode (1 ) every source time will be mapped to a destination time AT MOST ONCE if one exists. Some source times may not be mapped. |
Returns
number
get
Get the value at a specific index.
Note: The indices of a pine series is opposite.
Example:
- s.get(1) returns second last,
- s.get(2) - third last
- and so on
Signature
get(n?: number) => number
Parameters
Name | Type |
---|---|
n? | number |
Returns
number
indexOf
Get the index for the bar at the specified timestamp
Signature
indexOf(time: number) => number
Parameters
Name | Type | Description |
---|---|---|
time | number | timestamp |
Returns
number
set
Set the value for the pine series at the current index interation.
Signature
set(value: number) => void
Parameters
Name | Type | Description |
---|---|---|
value | number | value to be set |
Returns
void