Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Failed to call 'Add' method

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

    Failed to call 'Add' method

    Hi,

    I'm writing a new strategy that I run on 5 minute.
    I want to use also daily data in the strategy, so I added "Add(PeriodType.Day, 1);" in the "Initialize" method.

    The problem is that I get the below errors:

    Default Failed to call 'Add' method: Cbi.Bars.Add: volume value (-210) must be greater than 0


    Error on calling 'OnBarUpdate' method for strategy 'BelowAbpveBB/0ffaa1429baa4d94a154b5c13ef435db': 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 shayhz,

    Thank you for your post.

    You will need to make sure you have enough bars in your chart before accessing them. For information on making sure you have enough bars on your chart before accessing them please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3170

    Please let me know if I may be of further assistance.

    Comment


      #3
      I've added the check using "CurrentBar", but I still get the below error.
      I think it's related to my use of the daily data, while the strategy is running on 5 min data.
      example of my use is: Closes[1][1]

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

      Any thoughts ?

      Comment


        #4
        Hello shayhz,

        Thank you for your response.

        Please try the following:
        Code:
        if(CurrentBar < BarsRequired)
        return;

        Comment


          #5
          Originally posted by shayhz View Post
          I've added the check using "CurrentBar", but I still get the below error.
          I think it's related to my use of the daily data, while the strategy is running on 5 min data.
          example of my use is: Closes[1][1]

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

          Any thoughts ?
          You need to check all bar series, not just CurrentBar.

          ref: http://www.ninjatrader.com/support/h...nstruments.htm

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          27 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          117 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          69 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          226 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          417 views
          0 likes
          Last Post CaptainJack  
          Working...
          X