I'm currently developing an indicator and when I load the indicator it only runs up to bar 4 but then I get this error: "Error on calling 'OnBarUpdate' method on bar 4: Object reference not set to an instance of an object." By the way, it's calculating OnEachTick. Below is the code I'm writing:
public class Prueba : Indicator
{
private Series<List<double>> listPrices;
}
else if (State == State.Configure)
{
ClearOutputWindow();
AddVolumetric(null, BarsArray[0].BarsPeriod.BarsPeriodType, BarsArray[0].BarsPeriod.Value, VolumetricDeltaType.BidAsk, 1);
}
else if (State == State.DataLoaded)
{
listPrices = new Series<List<double>> (this, MaximumBarsLookBack.Infinite);
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 1)
{
if (Bars == null)
return;
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = BarsArray[1].BarsType as
NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
if (barsType == null)
return;
double prices = Close[0];
if(IsFirstTickOfBar)
{
// create the list once per bar
listPrices[0] = new List<double>();
}
listPrices[0].Add(prices);
foreach(double price in listPrices[0])
{
Print("Current Bar: " + CurrentBar + " " + price);
}
The same thing happens to me if I use a dictionary instead of a list.
Could you please help me with this problem?

Comment