Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

getting an error accessing EMA(8)[1]

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

    getting an error accessing EMA(8)[1]

    Hi all,

    This line of code:

    double next = EMA(8)[1];

    is throwing this error:

    Error on calling 'OnBarUpdate' method for indicator 'ema8slope' on bar 0: 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.

    If I call "Print(EMA(8).Count);" it shows a value of 50.

    What's going on?

    thanks.

    john

    #2
    Hello,

    You're likely running into an issue explained in the following forum post from our Tips section:
    http://www.ninjatrader.com/support/f...ead.php?t=3170

    Please try adding the following snippet to the beginning of your code in OnBarUpdate()


    if (CurrentBar < 1)
    return;

    You need to ensure you have enough bars on the chart to calculate correctly.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Thank you, that was it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Unsuitable, Today, 07:26 PM
      0 responses
      1 view
      0 likes
      Last Post Unsuitable  
      Started by jvanelli, Today, 06:36 PM
      1 response
      7 views
      0 likes
      Last Post jeronymite  
      Started by twitch251, Today, 05:14 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Started by robforee2, Today, 05:07 PM
      0 responses
      4 views
      0 likes
      Last Post robforee2  
      Started by blar58, Today, 03:16 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Melissa  
      Working...
      X