Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Volumetric array out of bounds

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Volumetric array out of bounds

    For some reason, I started getting an array out of bounds. It looks like the last bar was 1716, but it is trying to look for 1717. This was previously working without any issue and then I started noticing this recently. My expectation is to get the current delta of the current volumetric bar.

    Code:
    NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = Bars.BarsSeries.BarsType as
                  NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
    
          if (barsType != null)
          {
            currentDelta = barsType.Volumes[CurrentBars[VOLUMETRIC_BAR]].BarDelta; // Errors here. VOLUMETRIC_BAR is 1, which is what I currently have in the State.Configure
          }​

    #2
    I found my issue. I updated my visual chart to a Range 15, but still had AddVolumetric in the State.Configure section to Range 10.

    Comment


      #3
      Hello tonystarks,

      It sounds like you need a proper current bars check.
      https://ninjatrader.com/support/help...urrentbars.htm
      https://ninjatrader.com/support/foru...13#post1048513

      Code:
      private NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType volumetricBars;
      private double currentDelta;
      Code:
      else if (State == State.Configure)
      {
          AddVolumetric(null, BarsPeriodType.Minute, 1, VolumetricDeltaType.BidAsk, 1);
      }
      else if (State == State.DataLoaded)
      {
          if (BarsArray.Count() > 0)
              volumetricBars = BarsArray[1].BarsSeries.BarsType as NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
      }​
      Code:
      if (BarsInProgress != 0)
      return;
      
      if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
      return;
      
      if (volumetricBars != null)
      {
          currentDelta = volumetricBars.Volumes[CurrentBars[1]].BarDelta;
          Print(string.Format("{0} | currentDelta: {1}", Times[1][0], currentDelta));
      }​​
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      134 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X