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 ScottW, Today, 06:09 PM
          0 responses
          2 views
          0 likes
          Last Post ScottW
          by ScottW
           
          Started by Board game geek, 10-29-2023, 12:00 PM
          14 responses
          244 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Waxavi, 04-19-2024, 02:10 AM
          4 responses
          56 views
          0 likes
          Last Post sonia0101  
          Started by cmtjoancolmenero, Today, 03:58 PM
          0 responses
          9 views
          0 likes
          Last Post cmtjoancolmenero  
          Started by Segwin, 05-07-2018, 02:15 PM
          11 responses
          1,779 views
          0 likes
          Last Post aligator  
          Working...
          X