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

Data Series question

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

    Data Series question

    I'm trying to understand Data Series Arrays (new to C# programming). I created the indicator using the Data Array tutorial, and it works fine. But, if I change the Open[0] to Open[1] I get nothing in the indicator panel and nothing in the output window (using a Print statement). Here is the line of code I change:

    This one works fine:

    myDataSeries.Set(Close[0] - Open[0]);

    This one doesn't:

    myDataSeries.Set(Close[0] - Open[1]);

    Why doesn't the second one work?

    Thanks

    #2
    Hello Ghoti,

    Likely you are running into the issue described in the post below:



    In your case you need to add a check at the top of the OnBarUpdate() method:
    Code:
     
    if (CurrentBar < 1)
       return;
    Last edited by NinjaTrader_RyanM1; 03-02-2010, 03:11 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan,

      I didn't mention, I did do some searching for the cause of this problem before I posted this question. I saw that post, it doesn't apply here. It is a daily chart with 365 days of history.

      Comment


        #4
        Hello Ghoti,

        If you are attempting to access Open[1] but you do not have the CurrentBar check, then that post applies here. Amount of history will not matter as the problem happens when NinjaTrader attempts to access objects that don't exist. When you're looking at the first bar in the series (from the left), Open[1] does not exist.

        Try adding that check and let us know your results.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I guess I need to read more carefully... That was it.

          Thanks again.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by mishhh, 05-25-2010, 08:54 AM
          19 responses
          6,189 views
          0 likes
          Last Post rene69851  
          Started by gwenael, Today, 09:29 AM
          0 responses
          1 view
          0 likes
          Last Post gwenael
          by gwenael
           
          Started by Karado58, 11-26-2012, 02:57 PM
          8 responses
          14,829 views
          0 likes
          Last Post Option Whisperer  
          Started by Option Whisperer, Today, 09:05 AM
          0 responses
          1 view
          0 likes
          Last Post Option Whisperer  
          Started by cre8able, Yesterday, 01:16 PM
          3 responses
          11 views
          0 likes
          Last Post cre8able  
          Working...
          X