Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on accessing volumetric bars

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

    Error on accessing volumetric bars

    Hi,

    I got the error "Index was outside the bounds of the array." when accessing the 6 range voluemtric bar dataseries.

    After debugging I found that the error is come from accessing the range bar with all zero data (datafeed error?).

    The function I use is barsType.Volumes[CurrentBar].TotalVolume

    Is there any ways in Ninjascript that I can skip the errors? As I need to use these functions for calculation, thanks.

    ​​

    #2
    Hello kelefei,

    Thanks for your post.

    This error indicates that you are accessing an invalid index somewhere in your script.

    To resolve the error message, you would need to debug your script by reducing code and adding prints to find the exact line of code causing the issue and the index that is being referenced in that line of code. Below is a link to a forum post that demonstrates how to use prints to understand behavior.

    https://ninjatrader.com/support/foru...121#post791121

    You could make sure that a certain number of bars have been processed in the data series you are accessing by adding a CurrentBar check to the script. Or, a CurrentBars check in a multi-instrument / multi-timeframe script.

    See this help guide page about making sure a certain number of bars have been processed in the data series you are accessing: https://ninjatrader.com/support/help...nough_bars.htm

    See this forum thread for more information about this error: https://ninjatrader.com/support/foru...92#post1050092

    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi,

      I have checked the error occurs not because my coding, that's becasue there some range bars that create only the 0x0, please see the attachment.

      I know that that may be the datafeed issue, but how can we skip that error if I am calling the functions like "barsType.Volumes[CurrentBar].TotalVolume"

      thanks.

      Comment


        #4
        Hello kelefei,

        Thanks for your note.

        I am not able to reproduce the error you are reporting on my end. A test indicator was created that prints out the Total Volume from the Volumetric Bars (barsType.Volumes[CurrentBar].TotalVolume) and the Time (Time[0]) that the print occurs.

        When enabling the indicator on an ES 03-23 6 Range Volumetric chart I am seeing the Total Volume and Time prints to the NinjaScript Output window without any errors occurring.

        See this demonstration video showing the steps I took to test this on my end: https://brandonh-ninjatrader.tinytak...NF8yMDY2ODQ3NA

        I am also attaching the indicator script used to test this so that you could follow the same steps seen in the demonstration video to test on your end. You could also compare the indicator script to your script to see where differences might be.

        Volumetric Bars help guide page and sample code: https://ninjatrader.com/support/help...tric_bars2.htm

        Are you able to reproduce the behavior you reported when using the steps in the demonstration video?

        If so, what are the exact steps and settings you are using to reproduce this on your end using the attached test script?

        Let me know if I may assist further.​
        Attached Files
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X