Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars ago > 20

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

    Bars ago > 20

    Is there a limit on the bars I can look back on an indicator in a strategy.
    Trying to look up to 28 bars back on the Ichimoku Indicator but it exit the strategy with every lookback greater than 20. The searched (15min) bar visible in the chart. There are about 50 days loaded.


    Code:
    private double SenkouA;

    SenkouA = TSIchimoku(9, 26, 52).SenkouSpanA[28];


    Error:
    **NT** Error on calling 'OnBarUpdate' method for strategy 'SportStrategyMom/ebcc5a42e7ce42ada08ce5633b379197': 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.

    #2
    Hello P-Sionic,

    Thank you for writing in.

    You'll want to make sure that you have enough bars first before attempting to access the value 28 bars ago.

    The reason why is because your script is going to evaluate exactly what you have coded. Do remember that the script evaluates every single historical bar.

    On the first bar, what's going to happen when the script tries to evaluate 28 bars ago? That bar doesn't exist, hence the error.

    More information about checking that you have enough bars in the series you are trying to access can be found here: http://ninjatrader.com/support/forum...ead.php?t=3170

    By default, strategies have a min bars required set to 20. This means that your strategy's logic is not going to evaluate until the 21st bar is evaluated. This is why you do not run into any errors when checking something less than or equal to 20 bars ago.

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the prompt response. Helped a lot!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bortz, 11-06-2023, 08:04 AM
      47 responses
      1,605 views
      0 likes
      Last Post aligator  
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      8 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      4 views
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      13 views
      0 likes
      Last Post Javierw.ok  
      Working...
      X