Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 cre8able, Yesterday, 07:24 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by cocoescala, 10-12-2018, 11:02 PM
      6 responses
      939 views
      0 likes
      Last Post Jquiroz1975  
      Started by gbourque, Today, 06:39 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by benmarkal, Yesterday, 12:52 PM
      3 responses
      23 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X