I'm new to ninjascript but have done some stuff in MQL5 so I'm familiar with making some basic indicators.I'm trying to recreate an indicator that I've made before but can't seem to be able to convert it to Ninjascript.
I've looked at the documentation but can't understand why this isn't working. It doesn't seem to load all the data and only draws a portion of it. I've loaded three days of data but the indicator just draws for a few bars.(60 or so) on a 5 minute chart.
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @""; Name = "BnB"; Calculate = Calculate.OnEachTick; IsOverlay = false; DisplayInDataBox = true; DrawOnPricePanel = 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(new Stroke(Brushes.CadetBlue, 2), PlotStyle.Line, "Bulls"); AddPlot(new Stroke(Brushes.OrangeRed, 2), PlotStyle.Line, "Bears"); AddPlot(new Stroke(Brushes.White, 2), PlotStyle.Line, "Total"); } else if (State == State.Configure) { AddDataSeries(null,BarsPeriodType.Volume, 1, MarketDataType.Ask); AddDataSeries(null,BarsPeriodType.Volume, 1, MarketDataType.Bid); AddDataSeries(null,BarsPeriodType.Tick, 1); } else if (State == State.DataLoaded) { } } protected override void OnBarUpdate() { if (CurrentBars[0] < BarsRequiredToPlot || CurrentBars[1] < BarsRequiredToPlot || CurrentBars[2] < BarsRequiredToPlot) return; if (BarsInProgress == 0) { //Update(); /* I tried with this first int thisBar = BarsArray[1].GetBar(Times[0][0]); int prevBar = BarsArray[1].GetBar(Times[0][1]); for (int i = prevBar; i <= thisBar; i++) { if(Volumes[1].IsValidDataPointAt(i) && Volumes[2].IsValidDataPointAt(i)) { Bulls[0] += BarsArray[1].GetVolume(i); Bears[0] += BarsArray[2].GetVolume(i); Total[0] = Bulls[0] + Bears[0]; } } */ } // Then I tried to do this instead if (BarsInProgress == 1) { Bulls[0] += Volumes[1][0]; //if (CurrentBars[0] > 600 && CurrentBars[0] < 680) Print(Bulls[0]); } if (BarsInProgress == 2) { Bears[0] += Volumes[2][0]; } if(BarsInProgress == 3) { Total[0] = Volumes[1][0] + Volumes[2][0]; } }
Comment