• 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


Object reference not set to an instance of an object

  • Filter
  • Time
  • Show
Clear All
new posts

    Object reference not set to an instance of an object

    Edit on 3/29/2017: I corrected the screenshot referenced on step 5.

    The log file is reporting an error when I try to reload ninjascripts using F5. I am running two independent strategies at the same time. Both strategies use AddChartIndicator to display stochastic and MACD indicators. When reloading the scripts, on occasion, the log reports the following error for the stochastic indicator:

    Indicator 'Stochastic': Error on calling 'SetState' method: Object reference not set to an instance of an object.

    The log also reports a similar error for the MACD indicator.

    I created a simplified script to demonstrate the error (actually leveraging a test script from a previous post - see attached). The error is sporadic and may occur on the third reload attempt or it may occur on the 50th. The number of attempts required is inconsistent.

    I am running: version 64-bit of the Ninjatrader platform.

    To reproduce the problem, I performed the following steps. I have also attached the screenshots associated with most of the steps.
    1. I opened a 300 tick window for the 6E 06-17 with a specific end date (see Data Series window screenshot).
    2. I added the 'DetectDrawingObject' script twice to simulate the two independent scripts I am normally running. I kept the default input values for the first and changed the stochastic values for the second (see "Strategy Window-prior to error" screenshot).
    3. After enabling both strategies, I checked the Indicator window which correctly showed the indicators added by the strategy (refer to the "Indicator Window - prior to the error" screenshot).
    4. On the third attempt at reloading the indicator, the log reported the errors described above (refer to the screenshot of the log).
    5. After the error, the Indicator window displays two new entries for the Stochastic and MACD indicators in addition to the ones previously added. The two new indicators do not appear to be associated with the 300-tick bar (refer to "Indicator Window - after error" screenshot)
    6. I next removed the two strategies from the strategy window.
    7. The chart window still retained two panes for the MACD and Stochastic indicators, but the panes were blank(refer to "Chart Window - after removing strategies" screenshot).
    8. Returning to the Indicator window, the two new indicators that were added after the error still remained but the original Stochastic and MACD indicators were automatically removed. Attempting to manually remove the remaining indicators resulted in an error stating the indicators were added by a strategy.(refer to "Indicator Window - error attempting to remove the indicator" screenshot).

    I'm not sure what is causing the issue, but any help would be appreciated.
    Attached Files
    Last edited by dp2002; 03-29-2017, 09:50 AM.

    I had the same, but haven't been able to reproduce this reliably either.

    I know this isn't very helpful, but it happened somehow related to adding, editing, starting, stopping, removing multiple strategies from Strategies tab or charts.


      Thank you for your report. I am testing this on my end and will return when I have more information.
      Jessica P.NinjaTrader Customer Service


        Following your steps, as well as testing with a large number of copies of your strategy with both many and no drawing objects, I was unable to see the same thing you were seeing in a pre-release copy of NinjaTrader. Please let us know if this continues into the next release so we may investigate further.
        Jessica P.NinjaTrader Customer Service


          Thanks Jessica,

          I am running which I believe is the latest release. Is this still considered a pre-release?


            No is the most recent release of NinjaTrader. I was able to use a more recent version than this to test on.
            Jessica P.NinjaTrader Customer Service


            Latest Posts


            Topics Statistics Last Post
            Started by tonynt, Today, 01:42 AM
            0 responses
            Last Post tonynt
            by tonynt
            Started by NT-Roland, Yesterday, 04:36 PM
            0 responses
            Last Post NT-Roland  
            Started by Newtrader101, Yesterday, 03:40 PM
            2 responses
            Last Post Newtrader101  
            Started by Branpo, Yesterday, 02:58 PM
            2 responses
            Last Post Branpo
            by Branpo
            Started by sdauteuil, Yesterday, 02:09 PM
            1 response
            Last Post NinjaTrader_Jesse