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

object reference not set to an instance of an object

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

    object reference not set to an instance of an object

    Hello,

    I need some help. I am using a strategy with "ES 12-19" as a primary instrument with which I want to place a trade on the MES 12-19 contract. I've added the following code to my strategy.
    Code:
                if (State == State.Configure)
                {
                    AddDataSeries("MES 12-19");
                }
    When I backtest my strategy, I get the following error.

    object reference not set to an instance of an object
    Please advise to what, I'm doing wrong.

    Thanks,
    eleven

    #2
    Hello eleven,

    Thanks for your post.

    The error is advising that something you are accessing has not been created at the time you are accessing it. There is no specific thing I can advise as to the source of the error.

    To determine what the source of the error is you will need to debug your strategy. This is typically done with print statements added to your code to send a print output to the New>Ninjascript Output window. As you do not know where the error is, you would add a print statement every few lines of code and then observe the output window when you apply the strategy. The last print statement value shown in the output window would indicate the error occurs after that print statement, you can then add further print statements to zero in on the offending code.

    Here is a link to our tips on debugging: https://ninjatrader.com/support/help...script_cod.htm

    If you are not familiar with creating multi series coding, we highly recommend a review of https://ninjatrader.com/support/help...nstruments.htm

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul, I figured out the issue I was having with object reference not set to an instance of an object, but I have another question.

      I'd like to use ES historical data to place orders on MES. MES is a new instrument so the data only goes back a few months. Is there a way to set up a strategy using ES as the primary instrument, but place trades on MES using the full historical data of ES.

      Bottom line is that my strategy places different trades on ES and MES. I believe it due to the lack of historical MES data as I require over 100 bars with my strategy.

      Thanks,
      eleven

      Comment


        #4
        Hello eleven,

        Thanks for your post.

        It is possible to create a strategy that places orders on more than one instrument or using calculatons on one instrument and entering on another instrument.. I recommend a thorough review of this specific section of the help guide that reveals all of the consideratiuons required for such a strategy: https://ninjatrader.com/support/help...nstruments.htm

        Please note that you would not be able to place orders on MES prior to its first day of trading.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_PaulH View Post
          Hello eleven,

          Thanks for your post.

          The error is advising that something you are accessing has not been created at the time you are accessing it. There is no specific thing I can advise as to the source of the error.

          To determine what the source of the error is you will need to debug your strategy. This is typically done with print statements added to your code to send a print output to the New>Ninjascript Output window. As you do not know where the error is, you would add a print statement every few lines of code and then observe the output window when you apply the strategy. The last print statement value shown in the output window would indicate the error occurs after that print statement, you can then add further print statements to zero in on the offending code.

          Here is a link to our tips on debugging: https://ninjatrader.com/support/help...script_cod.htm

          If you are not familiar with creating multi series coding, we highly recommend a review of https://ninjatrader.com/support/help...nstruments.htm
          What you posted here about adding a print statement EVERY FEW LINES is great. First time I have seen that in 3 years with NinjaTrader. Believe me I have been instructed to add Print Statements over 40 times

          This should be stated more often from support

          Comment


            #6
            I keep getting this error when I NT asks me if I want to roll over futures contracts and I say yes by checking the boxes next to the instruments I want to update. Every single time I get this error and then a popup that says "NT has stopped working" . So it crashes everytime. This has been going on for months.

            Comment


              #7
              Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


              Watch this video

              Comment


                #8
                Hello hothomas,

                Thanks for your post.

                In your NinjaTrader, please go to Help>Email support.

                In the email support window, add your e-mail address, and in the large section describe the issue there. This will automatically send in your log and trace files which will allow the platform support team to review and advise.

                Note: do not post log and trace files here due to the sensitive nature of these files.
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by proptrade13, Today, 11:06 AM
                0 responses
                0 views
                0 likes
                Last Post proptrade13  
                Started by kulwinder73, Today, 10:31 AM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by RookieTrader, Today, 09:37 AM
                3 responses
                15 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by terofs, Yesterday, 04:18 PM
                1 response
                24 views
                0 likes
                Last Post terofs
                by terofs
                 
                Started by CommonWhale, Today, 09:55 AM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Erick  
                Working...
                X