Valid Input Data for Indicator Methods

View as Markdown

System indicator methods require valid input data to function property. Indicator methods can accept the following forms of input data:

Default Input

The default input (Inputs[BarsInProgress) of the custom indicator, Market Analyzer row or strategy is used if input is not specified.

1// Printing the current value of the 10 period SMA of closing prices
2// using the default input.
3double value = SMA(10)[0];
4Print("The current SMA value is " + value.ToString());

Price Series

Open, High, Low, Close and Volume can all be used as input for an indicator method.

1// Passing in the a price series of High prices and printing out the current value of the
2// 14 period simple moving average
3double value = SMA(High, 14)[0];
4Print("The current SMA value is " + value.ToString());

Indicator

Indicators can be used as input for other indicators.

1// Printing the current value of the 20 period simple moving average of a 14 period RSI
2// using a data series of closing prices
3double value = SMA(RSI(Close, 14, 3), 20)[0];
4Print("The current SMA value is " + value.ToString());

Series<double>

Series<double> can be used as input for indicators.

1// Instantiating a new Series<double> object and passing it in as input to calculate
2// a simple moving average
3Series<double> myDataSeries = new Series<double>(this);
4double value = SMA(myDataSeries, 20)[0];

Bars Object

A Bars object (which holds a series that contains OHLC data) can be used as input for indicators.

1// Passing in the second Bars object held in a multi-instrument and timeframe strategy
2// The default value used for the SMA calculation is the close price
3double value = SMA(BarsArray[1], 20)[0];
4Print("The current SMA value is " + value.ToString());;

Tip: The input series of an indicator cannot be the hosting indicator itself, as this will cause recursive loops.

1// Using the hosting indicator in this way will cause errors with recursive loops
2double value = SMA(this, 20)[0];|