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 Waxavi, Today, 02:10 AM
          0 responses
          4 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by TradeForge, Today, 02:09 AM
          0 responses
          10 views
          0 likes
          Last Post TradeForge  
          Started by Waxavi, Today, 02:00 AM
          0 responses
          2 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by elirion, Today, 01:36 AM
          0 responses
          4 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by gentlebenthebear, Today, 01:30 AM
          0 responses
          4 views
          0 likes
          Last Post gentlebenthebear  
          Working...
          X