Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dataseries Add() is not loading the Bars Array

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

    Dataseries Add() is not loading the Bars Array

    Hi,

    In my Initialize() I have

    Add(PeriodType.Minute, 5);

    But the BarsArray is not being loaded.

    I've been trying to identify for some time exceptions that I have been getting whilst trying to access this array that occur intermittently, but I now have a situation where the error is occurring consistently.

    I put a condition in my indicator now to test for BarsArray[1].Count>0 before attempting to access the array and I have discovered that BarsArray[1].Count=0, even after executing the above Add().

    In this particular situation my instrument is FDAX and I am running my indicator during market closed time, but I am certain that there are other conditions which also cause this problem.

    Why would the array not be loaded? Is there something I can do to force the load?

    Thanks,
    will.

    #2
    Hello Will,

    Thank you for your post.

    The Array should be loaded, where in your code are you checking the count?

    Comment


      #3
      Hi Patrick,

      I have a timer event that is executed for the first time at 1 second after the Initialize(). In the timer event is where I check the count.

      Will.

      Comment


        #4
        Hello dontpanic,

        Thank you for your response.

        Where is the timer called? If not in the OnBarUpdate() method and in the Initialize() method the bars have not loaded yet.

        Comment


          #5
          The timer is intialised and started in OnStartup(), which occurs after Initialize(). However, OBU() has not been called for BarsArray[1] before the first timer event (I put a debug Print() in there).

          In fact it appears that OBU() is not being called at all for BarsArray[1]. As I said, in this case I am accessing a market that has no incoming data at this time, during market close, however it was my understanding that OBU() was called for every bar of historical data during startup, so I assumed that this was the case for the additional series...?

          If change my instrument to GC then OBU() is called, I guess GC has incoming data right now.

          But in this case for GC it appears as tho OBU() IS being called for BarsArray[1] for each bar of the historical array, as I would expect.

          Now... something interesting has happened. After I loaded GC, I put my instrument back to FDAX, and now OBU() has been called for every historical bar. I saved my workspace and restarted NT, and again, OBU() is being called as I would expect.

          There is still no incoming data for FDAX, so I don't know if this is related to the cause or not, but something has changed... whatever the conditions are that cause BarsArray[1] to be loaded or not loaded have changed. The question is, I think, what are those conditions?

          Will.

          Comment


            #6
            Hello Will,

            Thank you for your response.

            Do you have an example I can test to investigate this matter further?

            Comment


              #7
              Hi Patrick, I can send you my indicator via email if thats ok?

              A similar thing is happening to yesterday. I was working on this indicator this morning and it was working fine. At some point it started getting the array errors. I suspect that shortly it will start working again, I think there is a time factor involved, something to do with the way data is received from the exchange?

              Will.

              Comment


                #8
                Hi, now I suspect its not related to time, but related to loading or reloading of data. A couple of times when I have "reload all ninjascript" it gets the error. When I swap instruments to GC, then swap back again, there is no error.

                W.

                Comment


                  #9
                  Hello dontpanic,

                  Yes, please send to support[at]ninjatrader[dot]com with 'ATTN: Patrick - 1096579' in the subject line.

                  Comment


                    #10
                    Hi, Patrick, Cal,


                    Yes I can do a remote session if you are around.

                    I now have another indicator that has a similar problem, this time its with the Times[0] dataseries and it happens consistently. I have it running in Visual Studio debug mode so hopefully that will give us some more info.

                    Regards,
                    Will.

                    Comment


                      #11
                      Hi,

                      I'm available for a remote session for the next 24 hours. I'm in Australia EST timezone, so if you would like to make a time I can be available.

                      Thanks,
                      Will.

                      Comment


                        #12
                        Hello Will,

                        Thank you for your response.

                        I will follow up with you via e-mail.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        579 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        334 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        101 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        554 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        551 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X