Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Mizzouman1, Today, 07:35 AM
    4 responses
    18 views
    0 likes
    Last Post Mizzouman1  
    Started by philmg, Today, 01:17 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by cre8able, Today, 01:01 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by manitshah915, Today, 12:59 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by ursavent, Today, 12:54 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X