ISeries

View as Markdown

Definition

ISeries is an interface that is implemented by all NinjaScript classes that manage historical data as an ISeries\<double\> (Open, High, Low, Close, etc), used for indicator input, and other object data. Please see the help guide article on Working with Price Series for a basic overview on how to access this information.

Types of ISeries

Series<t>Represents a generic custom data structure for custom development
PriceSeriesHistorical price data structured as an ISeries\<double\> interface (Close[0], High[0], Low[0], etc)
TimeSeriesHistorical time stamps structured as an ISeries<datetime> interface (Time[0])
VolumeSeriesHistorical volume data structured as an ISeries\<double\> interface (Volume[0])

Methods and Properties

PropertyDescription
GetValueAt()Returns the underlying input value at a specified bar index value.
IsValidDataPoint()Indicates if the specified input is set at a barsAgo value relative to the current bar.
IsValidDataPointAt()Indicates if the specified input is set at a specified bar index value.
CountReturn the number total number of values in the ISeries array

Tips: (see examples below)

  1. By specifying a parameter of type ISeries\<double\>, you can then pass in an array of closing prices, an indicator, or a user defined data series.
  2. When working with ISeries\<double\> objects in your code you may come across situations where you are not sure if the value being accessed is a valid value or just a “placeholder” value. To check if you are using valid values for your logic calculations that have been explicitly set, please use .IsValidDataPoint(int barsAgo) to check.

Examples

Using ISeries as a method parameter

1private double DoubleTheValue(ISeries`<double>` priceData)
2{
3 return priceData[0] * 2;
4}
5
6protected override void OnBarUpdate()
7{
8 Print(DoubleTheValue(Close));
9 Print(DoubleTheValue(SMA(20)));
10}

Checking ISeries value before accessing

1protected override void OnBarUpdate()
2{
3 if (Input.IsValidDataPoint(0))
4 Plot0[0] = Input[0];
5}