As I'm a beginner with regards to Ninjatrader and programming so I can't fully exclude it's a user error but I think users are not supposed to get unhandled exceptions.
Stripped pretty much everything out of the indicator but error remains as long as I maintain the while loop.
the code:
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Bull Divergence";
Name = "MyBullDivErr2";
Calculate = Calculate.OnBarClose;
IsOverlay = false;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
MinPeriod = 5;
MaxPeriod = 30;
AddPlot(Brushes.Orange, "BullDiv");
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
int i = MinPeriod;
BullDiv[0] = 0;
while (i < MaxPeriod && BullDiv[0] <= 0);
{
if (Low[0] > Low[i] )
{
BullDiv[0] = i;
}
i++;
}
}

An inadvertent endless loop is your error, and needs to be handled by you after you see the effect.
Maybe not in the manner that you would like, but still informed nonetheless.
Comment