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 GussJ, 03-04-2020, 03:11 PM
          15 responses
          3,268 views
          0 likes
          Last Post xiinteractive  
          Started by Tim-c, Today, 02:10 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Taddypole, Today, 02:47 PM
          0 responses
          2 views
          0 likes
          Last Post Taddypole  
          Started by chbruno, 04-24-2024, 04:10 PM
          4 responses
          50 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by TraderG23, 12-08-2023, 07:56 AM
          10 responses
          401 views
          1 like
          Last Post beobast
          by beobast
           
          Working...
          X