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 jclose, Today, 09:37 PM
          0 responses
          5 views
          0 likes
          Last Post jclose
          by jclose
           
          Started by WeyldFalcon, 08-07-2020, 06:13 AM
          10 responses
          1,413 views
          0 likes
          Last Post Traderontheroad  
          Started by firefoxforum12, Today, 08:53 PM
          0 responses
          11 views
          0 likes
          Last Post firefoxforum12  
          Started by stafe, Today, 08:34 PM
          0 responses
          11 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by sastrades, 01-31-2024, 10:19 PM
          11 responses
          169 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X