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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    80 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X