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 futtrader, 04-21-2024, 01:50 AM
      4 responses
      41 views
      0 likes
      Last Post futtrader  
      Started by Option Whisperer, Today, 09:55 AM
      1 response
      11 views
      0 likes
      Last Post bltdavid  
      Started by port119, Today, 02:43 PM
      0 responses
      1 view
      0 likes
      Last Post port119
      by port119
       
      Started by Philippe56140, Today, 02:35 PM
      0 responses
      3 views
      0 likes
      Last Post Philippe56140  
      Started by 00nevest, Today, 02:27 PM
      0 responses
      2 views
      0 likes
      Last Post 00nevest  
      Working...
      X