This is my code:
---------------------------
public class _my : Indicator
{
private Bollinger bollinger;
private double upperValue;
private double lowerValue;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "_my";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
//NumStdDev = 1.75;
//Period = 2;
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;
//Period = 2;
AddPlot(Brushes.Blue, "Upper BB");//2
AddPlot(Brushes.Blue, "Lower BB");//3
}
else if (State == State.DataLoaded)
{
bollinger = Bollinger(1.5, 2);
}
}
protected override void OnBarUpdate()
{
upperValue = bollinger.Upper[1];
lowerValue = bollinger.Lower[1];
Values[0][0] = upperValue;
Values[1][0] = lowerValue;
}
}
----------------------------------
note that if I change the Bollinger band value calls to current bar (as shown bellow), it works fine and shows the indicator without issue
upperValue = bollinger.Upper[0];
lowerValue = bollinger.Lower[0];
Does anyone have an idea what I'm doing wrong?
Comment