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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      162 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      312 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      245 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      350 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      179 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X