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

Error on NT8 Startup: Unhandled exception: Object reference not set o an object

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

    Error on NT8 Startup: Unhandled exception: Object reference not set o an object

    Hello,
    I am getting error (see topic) when starting NT8

    Click image for larger version

Name:	exception.png
Views:	688
Size:	21.1 KB
ID:	1038336

    In log i find

    2018-11-03 15:51:14:876|3|4|Strategy '131269595': unable to deserialize user data: There was an error reflecting type 'NinjaTrader.NinjaScript.Strategies.Golem'.
    2018-11-03 15:51:14:952|0|4|Unhandled exception: Object reference not set to an instance of an object.

    I have object Golem - which is ninja strategy and
    Gadget - which si form looking like this:



    I moved all code about gadget from golem.cs to class Gadget and error started to show.
    I tried to do in golem.cs

    [XmlIgnore()]
    public Golemator.Golem.Gadget gadget = null;

    and in gadget.cs
    [XmlIgnore()]
    private NinjaTrader.NinjaScript.Strategies.Golem golemObj;

    but nothing helps. does anyone know, what happens with my code - what runs on startup? Because I can compile all classes and if I add strategy to chart no error or exception occurs.
    Have no idea how to track error. I use Visual Studio but do not know how to debug NT while starting up.

    Thanks Paul
    Attached Files

    #2
    Hello kujista,

    Thank you for your note.

    These errors almost always have to do with public variables that are not serialized and should be, or public variables that are being passed through the XML parser when they shouldn't be.

    Are you able to identify the lines of code throwing the issue by commenting out public variables (and associated code) and testing your script again?

    You may try adding [XmlIgnore()] above,

    public Golemator.Golem.Core.Enum_Golem_AcceptedPatterns AOSTrades
    public Golemator.Golem.Core.Enum_Golem_Mode AOSMode

    See,


    When you save an indicator to a chart either via a workspace file, or in a chart template, it saves all of the public properties from the indicator via an XML file.

    There are complex objects like Brushes, ChartObjects, or even .NET types like TimeSpan which cannot be serialized like a simple type of string or int, etc. These are just a few examples and you need to take precautions if you're using these publicly.

    When you add XmlIgnore you're telling the XML Serializer to skip that property and not save it into the workspace or template file.

    More information on this .NET concept can be found here:
    https://docs.microsoft.com/en-us/dot...ramework-4.7.2
    https://docs.microsoft.com/en-us/dot...ramework-4.7.2

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      I started backtesting a strategy and after it's been running for a day or so, I begin to get the following error message: Unhandled exception: Object reference not set to an instance of an object. Then, NT freezes. Please help. What do I need to do to stop receiving this error message so I can continue to backtest?

      Comment


        #4
        Hello Ttrade12,

        Thank you for your post.

        The cause of the error is likely not the same as in the post above, as that occurred when starting NinjaTrader 8, and your issue doesn't occur until a backtest is in progress. This means it's likely you're trying to access a variable to which nothing has been assigned.

        The first thing I would recommend is to add prints to the strategy to help determine where within the code it gets to before the error is seen, so we can understand where within the code the error is occurring. One thing I like to do is put prints between chunks of the code to narrow down the section of code causing the error, then once I've figured out the general area of code it's erroring in, adding prints to print all variable values being used in that segment of code. If you then see one print occur but the next one does not and the error is seen, you pretty much know which variable is causing the issue. From there, you can work back and see where you may not have a value getting assigned.

        This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.

        https://ninjatrader.com/support/foru...ns-not-working

        If you have Visual Studio, you can also use that for debugging:



        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Thank you NinjaTrader_Kate for your response. When I run the strategy on my home computer (Windows 10 Home Version 21H1) I get the error messages. But, when I run the the same strategy on my VPN computer (when I look at the system info it says Windows Server 2012 R2 Standard), I don't get the error messages at all. So, that makes me think it isn't the strategy, but it may have something to do with Windows 10 Home? Is that possible?

          Comment


            #6
            Ttrade12 Have you turned on Debug Mode in the NinjaScript Editor (and recompiled)? That should provide additional information if the error is coming from your Strategy code, but will not add any extra information if it is NT8 code. It adds a small performance overhead ... but it may help identify where the issue lies. At the very least, it should help determine if it's your code or NT8 code.
            Multi-Dimensional Managed Trading
            jeronymite
            NinjaTrader Ecosystem Vendor - Mizpah Software

            Comment


              #7
              Hello Ttrade12,

              Thank you for your reply.

              Unlikely that it would be a problem with the operating system version but could be an installation issue on the home PC or a general issue with the computer itself. I would suggest uninstalling and reinstalling the platform.

              Please follow the steps listed below to completely uninstall and reinstall NinjaTrader so we can make sure that no files from the old version's back end may be causing conflicts.
              • If possible, copy your license key from the Control Center > Help > License Key.
              • Close all running applications.
              • Navigate to your Documents folder > Right click on the 'NinjaTrader 8' folder > Rename > rename the folder to 'NinjaTrader 8 OLD'. DO NOT delete this folder.
              • Uninstall NinjaTrader within Windows Control Panel.
              • Navigate to C:\ > Program File (x86) > Delete the 'NinjaTrader 8' folder if it exists
              • Reboot your PC.
              • Once these steps are completed, download and install NT8 from the link below.
              • Once reinstalled, you will now have 2 NinjaTrader folders in your Documents, the old one and the new one. Open two file explorer windows and open the new one in one and the old one in another.
              • Drag the following items from the old folder to the new one (folders should automatically merge)
                • Config.xml and UI.xml
                • Workspaces folder (if it asks to overwrite the _Workspaces.xml file, say yes)
                • Templates folder (if it asks to overwrite anything, say no)
                • db folder (you can overwrite any files in here)
                • bin folder (do not overwrite ANY duplicate files).
              • Once complete, restart NinjaTrader. You may get a few initial errors. Open a NinjaScript Editor and run a compile, then, if no additional errors are received, restart NinjaTrader and try again to run the strategy.
              Thanks in advance; I look forward to assisting you further.
              Kate W.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by frankthearm, Today, 09:08 AM
              7 responses
              29 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by NRITV, Today, 01:15 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by maybeimnotrader, Yesterday, 05:46 PM
              5 responses
              25 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by quantismo, Yesterday, 05:13 PM
              2 responses
              17 views
              0 likes
              Last Post quantismo  
              Started by adeelshahzad, Today, 03:54 AM
              5 responses
              33 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X