Secondary Volumetric Bars series causing out of quota error

Hello all, I am trying to load a test indicator to try out a secondary volumetric bars series. However the indicator is always causing the chart to freeze on loading… and eventually I have to restart ninjatrader to get it working again. A regular volumetric bars chart does work and as a result of running this script I always get an out of quota error.

I have 16gb of RAM and 100+ GB of free space. In the past I have loaded 1 year of tick replay data into my chart and that eventually worked after 30 minutes.

Here is the code I am running:

namespace NinjaTrader.NinjaScript.Indicators
{
public class DrawTextBarDeltaFromVolumetric1Minute : Indicator
{
//private OrderFlowCumulativeDelta cumulativeDelta;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @“Enter the description for your new custom Indicator here.”;
Name = “DrawTextBarDeltaFromVolumetric1Minute”;
Calculate = Calculate.OnBarClose;
IsOverlay = true;
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 = false;
AddPlot(Brushes.Purple, “ema”);
}
else if (State == State.Configure)
{
AddVolumetric(Instrument.FullName, Data.BarsPeriodType.Tick, 100, VolumetricDeltaType.BidAsk, 1);
}
}

	protected override void OnBarUpdate()
	{
        if (Bars == null)
          return;
		
		NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = BarsArray[1].BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;

		if (barsType == null)
			return;
		Print(barsType.Volumes[CurrentBar].BarDelta.ToString());
		Values[0][0] = barsType.Volumes[CurrentBar].BarDelta;
		//Draw.Text(this, "BarDelta " + CurrentBar,  barsType.Volumes[CurrentBar].BarDelta.ToString(), 0, Low[0] - 5 * TickSize);
	}
}

}

“Out of quota” is a memory issue. Volumetric bars are a notorious memory hog. There’s a couple things you could try to limit the memory usage.

  1. When you add the volumetric series, use the same interval as the primary bars data
  2. Limit the amount of data you load to a smaller amount

Also, there is a bug in your code. In OnBarUpdate you do not check the BarsInProgress value. This means your values code is being called for every primary and secondary bar.

if(BarsInProgress == 0) {}// do primary data series stuff, like setting Values[0]
else if(BarsInProgress == 1) {}// do secondary volumetric bars stuff.

Also, be sure to use the CurrentBar from the series that owns the underlying object if reaching across boundaries.

if(BarsInProgress == 0) {Values[0][0] = barsType.Volumes[CurrentBars[1]].BarDelta;}

One other minor thing, I’m guessing this is a snippet of your full code so it may not even matter but the plot you add is called “ema” and you are setting it to the bar delta.

1 Like

Thank you for calling out the bug and the currentBar syntax that was a mistake on my part. As for the plot I just copy and paste a plot from the closest other indicator just to get a test going, I’ll change it later.

What I am surprised by is that the memory usage is that bad. I’ve loaded 1 year of tick replay data before which was fine so I thought volumetric bars would be fine too. Even setting days to load to 1 still causes the error.

In general, I am doing all this to be able to have historical access to trade delta and top of book updates which seems to be challenging in ninjatrader. If anyone has done something similar and knows a trick it would be much appreciated.

I asked Grok about your problem and it has a few interesting observations. Maybe these will help:

Why 1 day can still trigger “out of quota” on 16 GB

  • The AddVolumetric call is still using 100-tick bars (unless they changed it). One trading day of a liquid instrument (ES, NQ, etc.) in 100-tick bars = thousands of volumetric bars. Each volumetric bar stores the full footprint (bid/ask volume at every price level). That’s still a huge memory footprint even for one day. Primary volumetric charts work because they only load the exact bars you see; a mismatched secondary series does not.
  • Critical (and very common) bug that you didn’t catch yet: AddVolumetric(Instrument.FullName, …) in State.Configure is explicitly unsupported. NT8 requires all parameters to AddVolumetric() (and AddDataSeries()) to be hard-coded constants at compile time. Using runtime variables like Instrument.FullName causes the secondary series to load incorrectly/inefficiently. This frequently surfaces as loading failures or massive memory use (exactly the “out of quota” symptom). Official docs + support replies repeatedly warn about this.
  • The Print() statement is still in there. It fires on every bar of the secondary series during historical load → enormous log spam → extra memory/CPU pressure.

Also try these quick housekeeping steps:

  • Start a completely blank new workspace with only this one chart + indicator.
  • Delete the cache folders: Documents\NinjaTrader 8\db\cache and Documents\NinjaTrader 8\Cache (then restart NT).
  • Confirm your primary chart timeframe (is it 1-minute volumetric?).
2 Likes

Thanks for this. I will hardcode it and remove the statement. The primary series is a 1 minute time chart. I am trying to test a secondary volumetric series when the primary chart type is different. Will run more tests and get back to you.

Thanks again.