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 ETFVoyageur, Today, 07:05 PM
      0 responses
      4 views
      0 likes
      Last Post ETFVoyageur  
      Started by Orion815, 05-02-2024, 08:39 AM
      2 responses
      17 views
      0 likes
      Last Post Orion815  
      Started by suroot, 02-25-2017, 04:43 AM
      11 responses
      2,549 views
      0 likes
      Last Post Zilvercat  
      Started by Rogers101, 05-05-2024, 11:30 AM
      16 responses
      50 views
      0 likes
      Last Post Rogers101  
      Started by ninza33, Today, 12:31 PM
      2 responses
      12 views
      0 likes
      Last Post ninza33
      by ninza33
       
      Working...
      X