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 NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      86 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      151 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      79 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      52 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      59 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X