Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CurrentBar Limit?!

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

    CurrentBar Limit?!

    Hi,
    i am currently working on an indicator for seasonality.
    I imported external data with 80,000 Bars.

    But now i the following problem:
    when i try to access bars greater than appx. 6000 and i have if(CurrentBar <6000) i obviously get an error.

    But now if i set (CurrentBar < 7000) or greater i dont even get an error message and the indicator wont calculate although i have enough data loaded the CurrentBar is great enough.

    What can i do about this? Or is there a maximum Bar back that youre able to index?

    Thanks for your help
    Felix

    #2
    Hello FelixMMM,

    Thank you for your post.

    Do you have MaximumBarsLookback set to infinite or 256? Setting MaximumBarsLookback to infinite allows full access of the series instead of only the last 256 values of the Series.

    Here is a help guide link about MaximumBarsLookback - https://ninjatrader.com/support/help...rslookback.htm

    Are you trying to avoid an index out of range error?

    A CurrentBar check could be used at the beginning of OnBarUpdate to ensure there are enough bars processed before making a barsAgo reference on a series. CurrentBar represents the current bar in a Bars object that the OnBarUpdate() method in an indicator or strategy is currently processing. For example, if a chart has 100 bars of data, the very first bar of the chart (left most bar) will be number 0 (zero) and each subsequent bar from left to right is incremented by 1. A CurrentBar check would like something like this.

    protected override void OnBarUpdate()
    {
    // Evaluates to make sure we have at least 20 or more bars
    if (CurrentBar < 20)
    return;

    // Indicator logic calculation code...
    }

    Here is a help guide link about CurrentBar - https://ninjatrader.com/support/help...nough_bars.htm

    Is the script hitting an error on a line of code that references a Series object with a barsAgo reference? Or, is your script hitting an error for another object such as an array?

    To understand why a condition in your code has not become true, you could add a print above the condition to print out and evaluate the values used in the condition.

    Thanks in advance, I look forward to your reply.
    <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
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X