Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars ago

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

    Bars ago

    Hi, new to Ninja Trader and trying to bring some indicators in.

    I am having problem with:

    double xx = EMA(Close,10)[1];

    Nothing appears on the chart unless I change the 1 to a 0. This seems to be a common theme on the forum.

    I have read this:


    The log is reflecting the 'Error on calling the 'OnBarUpdate' method for indicator 'xx' on bar 0: Index was out of range...'

    This doesn't make sense. I logged onto my Ameritrade account for historical and the chart is reflecting 3 days worth of 10 minute bars == 117 bars? I should only need 11 bars? What gives?

    Pulling my hair out on this one. Been at it all day. Silly me.

    EDIT:

    Yikes... I figured it out. For the sake of posterity, bars are left to right, 0 to whatever. I needed to set the condition to check for bars equal to or greater than period plus whatever. Heh.
    Last edited by Day Trading Fool; 02-05-2010, 04:09 PM.

    #2
    Hello,

    Yes, that's exactly what's happening here. No "prior bar" exists for the first bar in the series so you have to tell the code explicitly to return. Thanks for sharing the solution to your problem.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Hello,

      Yes, that's exactly what's happening here. No "prior bar" exists for the first bar in the series so you have to tell the code explicitly to return. Thanks for sharing the solution to your problem.

      Try this:

      if (CurrentBar > 0)
      {
      your code here
      }

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X