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 cmoran13, 04-16-2026, 01:02 PM
        0 responses
        37 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        23 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        98 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        152 views
        2 likes
        Last Post CaptainJack  
        Working...
        X