Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Out of bounds in a Multtimeframe indicator

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

    Out of bounds in a Multtimeframe indicator

    Hi, I'm trying to write an indicator to calculate the cumulative delta.
    I already managed to make it work on a time Chart, like an 1 Minute Chart. The main part of my indicator is the following loop:
    // While index is smaller than the number of rows in the table
    if(index < count)
    {
    if (BarsInProgress == 0)
    {
    Values[0][0] = 0; Values[1][0] = Delta_values[index-1];
    }

    if(BarsInProgress == 1) index ++;
    }

    The problema is the using BarsInProgress == 0 seems to work only in the minute Charts. As a matter of fact, I am getting the opening of a bar, so to compensate, I subtract 1 when indexing Delta_values.

    Then I tried another solution: using
    if (Bars.BarsPeriod.Value == Bars.TickCount)
    in place of
    if (BarsInProgress == 0)

    This solution also didn't work for Renko and gave out of bounds results for minutes:
    "Indicator 'CumulativeDelta': Error on calling 'OnBarUpdate" method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range.
    Can anyone tell me why this new solution generate an out of bounds error? Is this solution a good one?

    Thank you,
    Claudio

    #2
    Hello Claudio,

    Thank you for your note.

    Have you included a current bar check? Checking to make sure you have enough bars before trying to access previous values?

    Please see the following example,


    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 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