Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with Close[1], High[1], Vol[1]

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

    Problem with Close[1], High[1], Vol[1]

    Hi,

    I am programming a personal indicator and I need to get the High, Low and Volume for the previous bar. When I try to get those values like the Manual shows, e.g.:

    // Low price of 10 bars ago
    double barLowPrice = Low[10];

    I get nothing, and the same for High, Vol on past bars. However, I can use those functionalities to get the values for the actual bar.

    I have followed the NT7 guide but I can't get what I need. Can anyone help me?

    Thanks.

    #2
    Hi h2oid,

    Using Low[0] will return the Low 10 bars ago.

    If this is called on CurrentBar 0, this will break your script and you will get an error in the Log tab of the Control Center.

    Are you seeing any error messages in the Log tab of the Control Center?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi!

      I have changed the test script to only see the lowest value of the previous bar. I've written:

      double value = Low[1];

      and I receive the error as you said:

      I see in the log "Error on calling 'OnBarUpdate' method for indicator 'aaaTesting' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."

      Then, I do not understand why in the Ninja Trader help guide it is written this:

      Examples
      // Current bar low price
      double barLowPrice = Low[0];

      // Low price of 10 bars ago
      double barLowPrice = Low[10];

      // Current bar value of a 20 period exponential moving average of low prices
      double value = EMA(Low, 20)[0];

      I found it at: http://www.ninjatrader.com/support/h...rice_data2.htm

      How should I get lowest and highest values of the previous bar?

      Thanks!

      Comment


        #4
        h2oid,

        You can use the [10] index bars ago for your look back, however we have to remember that the data has be loaded first before checking something is not there. This is known has an Index out of range error

        You would want to use a CurrentBar check in the OnBarUpdate to ensure that enough data has loaded before running calculations.

        See the sample below for more information -
        http://www.ninjatrader.com/support/f...ead.php?t=3170
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X