• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Bars.IsFirstBarOfSession NullReferenceException

  • Filter
  • Time
  • Show
Clear All
new posts

    Bars.IsFirstBarOfSession NullReferenceException

    I got a NullReferenceException while calling Bars.IsFirstBarOfSession.

    Take note that the Bars property/object was NOT NULL. I had the Visual Studio debugger
    attached at the time that it happened and was able to confirm this. I was able to query the Bars object in the immediate window of the debugger.

    Fyi, The value of the CurrentBars property was something over 200 bars ( didn't get a chance to capture more details before the Rithimic connection timed out due do being blocked in the debugger and my call stack disappeared )

    I had loaded a new workspace and TickReplay backfill was in progress.

    Somewhere in the logic of the IsFirstBarOfSession there is a null reference being accessed.

    Log file entry:

    2016-11-10 11:48:30:563|3|4|Indicator 'AtsVolumeLadderVector': Error on calling 'OnBarUpdate' method on bar 224: Object reference not set to an instance of an object.

    Hello Brillo,

    What version of the Beta are you using?
    (You can find this in Help -> About...)

    I have created a very simple script that simply prints if Bars is null or if Bars.IsFirstBarOfSession is null.

    I am not able to reproduce this behavior with tick replay enabled or disabled.

    Are you able to reproduce this behavior using the attached script?

    If so, please attached the output this script prints to the Output Window with your next post.
    Attached Files
    Chelsea B.NinjaTrader Customer Service


      Hi Chelsea,
      I'm running NT8 RC2.
      The exception is difficult to reproduce on a regular basis. As are a lot of the issues that remain in system, it's probably due to a race condition. The reason I had the debugger attached to NT8 in the first place was because I was trying to reproduce a different exception that had just happened prior.
      I point out the property IsFirstBarOfSession as a code area that should be reviewed on theoretical basis and any object references used in the implementation should be candidates for checking for null prior to use ( and possibly logging )


        Hello Brillo,

        To report an issue to our development, I will need to reproduce this behavior on my end.

        Currently, I am not able to reproduce behavior that I can report to our development.

        Please let me know the steps I need to take with the example I have posted so that I may reproduce the behavior and enter a report on your behalf.
        Chelsea B.NinjaTrader Customer Service


          I can't give you a use case but it's happening on a pretty regular basis in my setup.
          It's got multi-threaded issues and that's a whole class of debugging that use cases will not be found.
          It simply requires code review.
          It happened again though and this time I was able to get a screen capture. I was loading a workspace w/out a connection.
          See attached.

          Fyi about the screen shot attached.... the "Autos" debugging tab is showing members of the Bars object. The list of members is long and I scrolled it so that you could see the null exception happening when the debugger itself is trying to query the IsFirstBarOfSession. That line has the small red X and the line has a message explaining that it threw the null reference. Note that the rest of members are valid indicating that the Bars object itself is okay.
          Attached Files
          Last edited by Brillo; 11-10-2016, 06:16 PM.


            I have more info on this ( please see prior post as well as this post will push it down before it's reviewed ).
            I've been reporting NT8 crashes over the last couple of weeks and I just received another but this time I had the Visual Studio debugger attached at the time and got a look at the callstack.
            It's the same call stack as the one in this thread but instead of the result being a null reference exception, it's a CLR Execution Exception which results in the Windows Process hosting the CLR ( and in turn NT8 ) to crash.
            See screen shot.
            Clearly something is getting corrupted in the memory of the CLR. Sometimes it's manifesting itself as null references and sometimes it's just a crash like this one.

            UPDATE. I just got another one. Attaching screenshot. Different callstack. I'm leaving it on screen in case you want to remote in and see.
            Attached Files
            Last edited by Brillo; 11-11-2016, 07:57 AM.


              If no one is interested in connecting to my computer today to see this then I'm going to restart NT8 because I want to continue development. I'll wait until 2pm EST.


                Hello Brillo,

                Thank you for your response.

                Can you send us a note to platformsupport[at]ninjatrader[dot]com and reference this thread with 'ATTN: Patrick H' in the subject line?
                We can then schedule a time to look into this on your PC.
                Patrick H.NinjaTrader Customer Service


                Latest Posts


                Topics Statistics Last Post
                Started by EnveousColnago, Today, 07:24 AM
                1 response
                Last Post NinjaTrader_ShawnB  
                Started by tornadoatc, Today, 10:31 AM
                0 responses
                Last Post tornadoatc  
                Started by EnveousColnago, Yesterday, 05:43 PM
                4 responses
                Last Post marcus2300  
                Started by Vypre, 11-23-2018, 07:51 AM
                2 responses
                1 like
                Last Post fx.practic  
                Started by AMATX, Yesterday, 09:29 AM
                7 responses
                Last Post AMATX
                by AMATX