In charts, I set stock A as the primary and then Add() stock B in the indicator. In charts, this works fine as the indicator is plotted as expected. I also get my Print() messages in Output.
In the strategy, I again Add() stock B. However, in the Strategy Analyzer when stock A is selected as the target of the backtest, I get this error:
Error on calling 'OnBarUpdate' method for indicator 'PairsIndicator' on bar 0: Object reference not set to an instance of an object.
After the failed backtest, on the chart of stock A in strategy analyzer, trying to plot the Indicator doesn't work at all - the panel is created but nothing is plotted. This puzzles me as to why the Indicator would work in regular charting and not in backtesting. The MinBarsRequired setting is 0 in both cases.
Any ideas to why this is the case problem would be much appreciated.
I googled that declaring data series and in variables which are not initiated may cause this problem. This isn't the case here.
Thanks in advance!
---
Update: Also getting this error sometimes:
Error on calling 'OnBarUpdate' method for indicator 'PairsIndicator' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
I've looked through the code and still can't find anything. Surely if this was the problem, it would cause the same thing in regular charting?
Comment