Here's my code:
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "CummulativeDelta"; Calculate = Calculate.OnEachTick; BarsRequiredToPlot = 1; 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; //AddPlot(Brushes.Blue, "CumulativeDelta"); AddPlot(Brushes.RoyalBlue, "CumulativeDelta"); AddLine(new Stroke(Brushes.Gray, DashStyleHelper.Dot ,1), 0, "ZeroLine"); } else if (State == State.Configure) { } } protected override void OnBarUpdate() { if (Bars == null || CurrentBar == 0) return; if (Bars.IsLastBarOfSession) { cumulativeDelta = 0.0; previousDelta = 0.0; } // indicator logic Value[0] = indicator result; } }
Comment