I'm trying to add an indicator to a strategy chart that uses the second data series (BarsArray[1]) as an input, and then trying to add an indicator that uses THAT indicator as an input. Here is an example:
// Variables
private string myInstrument = @"SPY";
protected override void Initialize()
{
CalculateOnBarClose = true;
Add(myInstrument,BarsPeriod.Id, BarsPeriod.Value);//Adds another bar series to the strategy... BarsArray[1]
//This Complies, but throws an error 'BarsArray property can not be accessed from within 'Initialize' method
Add(SMA(BarsArray[1], 14));//Adds an SMA plot to the chart from BarsArray[1] instrument
//This is not OK
//Add(SMA((myInstrument,BarsPeriod.Id, BarsPeriod.Value), 14));
//This is not OK
//Add (SMA(myInstrument, 14));
//Indicator on Indicator. This compiles, but throws the error
//Add (EMA((SMA(BarsArray[1], 14)), 14));
}
protected override void OnBarUpdate()
{
//Do something
}

Comment