Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Unable to load bars required

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

    Unable to load bars required

    Hi I am having trouble running my strategy live as it gives me the following error code

    Error on calling 'OnBarUpdate' method for strategy 'simpleMAcrossover/e079022e094f4dacb681d61c50c21380': 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.


    I have used the following method but it is still working.

    if (CurrentBar < 100)
    return;

    Could it be due to the fact that this is a multitimeframe strategy where I use:
    Daily, hourly and min data?

    Hope you can advise.

    #2
    Hello sgtrader888,
    In case of a multi series NinjaScript code you should check the bars for all bar series.

    Code:
    if (CurrentBars[0] < 20 || CurrentBars[1] < 20)
    { return; }
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thanks

      Thanks. It worked.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ETFVoyageur, 05-07-2024, 07:05 PM
      9 responses
      66 views
      0 likes
      Last Post ETFVoyageur  
      Started by TheTradingMantis, 01-19-2023, 02:05 AM
      42 responses
      912 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by _Zero_, 04-10-2020, 03:21 PM
      144 responses
      7,893 views
      6 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Richozzy38, Yesterday, 01:06 PM
      7 responses
      28 views
      0 likes
      Last Post Richozzy38  
      Started by swjake, Today, 12:04 PM
      5 responses
      16 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X