I added a ^VIX data series in my code, please see below:
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Tick, 1);
AddDataSeries("^VIX", BarsPeriodType.Day, 1);
}
When I try to access the ^VIX data series in State.DataLoaded, please see below
else if (State == State.DataLoaded)
{
Print("=========================================== ===========");
Print("^VIX 10 days moving average" + EMA(BarsArray[2], 10)[0]);
Print("=========================================== ===========");
}
I got the following error message:
Strategy 'AGG6BarDailyMonthlyVIX': Error on calling the 'OnStateChange' method: Object reference not set to an instance of an object.
However, if I access the same data series in OnBarUpdate(), it worked fine. Please advise how can t I access it when data has been loaded in State.DataLoaded? Thanks
else if (BarsInProgress == 2)
{
Print("=========================================== ===========");
Print("^VIX 10 days EMA " + EMA(BarsArray[2], 10)[0]);
Print("=========================================== ===========");
}
Billy
Comment