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

Reading Data off Data Box

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

    Reading Data off Data Box

    Hi,

    I have a third party indicator and want to include it in a strategy. However, when I do this I get an error
    "Error on calling 'OnStateChange' method: Object reference not set to an instance of an object"

    Is there a way around this, or is it possible to read the values used by the indicator from a Data Box, or directly off the chart?

    Thanks

    Ian

    #2
    Hello IanC28,

    There wouldn't be a supported way to get the values without calling the indicator.

    Is that the only error? Is this error with the strategy or with the indicator?

    Is the indicator having an error?

    The error is stating some variable you are using is null. If you are saving the indicator to a variable, that might be the null the variable.

    Have you reported the error to the author or vendor that supplied you with the script, or inquired if it is designed to be called by a host strategy?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      I resolved this issue by adding the indicator to the chart using AddChartIndicator().

      Thanks for your assistance.

      Ian

      Comment


        #4
        Hi Chelsea,

        I tried optimizing the strategy and got the same error. There must be something in the indicator that is messing up. Any ideas?

        Thanks

        Ian

        Comment


          #5
          Hello IanC28,

          Is that the only error? Is this error with the strategy or with the indicator?

          Is the indicator having an error?

          The error is stating some variable you are using is null. If you are saving the indicator to a variable, that might be the null the variable.

          Have you reported the error to the author or vendor that supplied you with the script, or inquired if it is designed to be called by a host strategy?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Hi Chelsea,

            Yes this is the only error. It is first reported as the indicator, and it is repeated as a strategy error.

            Indicator '': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
            Strategy 'TOPUltimateBreakoutProV2': Error on calling 'OnBarUpdate' method on bar 240: Object reference not set to an instance of an object.

            The indicator does not report an error if it is on a chart. It is being included in a strategy that is the issue.

            I just print the value of the indicator in a simplified strategy.

            I have reported the error to the vendor.

            Thanks,

            Ian

            Comment


              #7
              Hello Ian,

              Typically if an indicator variable that was assigned a null object from a null indicator return, this is the because the indicator itself had an error (like an indexing or null object error).

              If you comment out the line to the indicator call and all used of the variable, does the error stop?
              (This would identify the indicator call as the source of the null value)
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by geddyisodin, 04-25-2024, 05:20 AM
              8 responses
              61 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by jxs_xrj, 01-12-2020, 09:49 AM
              4 responses
              3,288 views
              1 like
              Last Post jgualdronc  
              Started by Option Whisperer, Today, 09:55 AM
              0 responses
              5 views
              0 likes
              Last Post Option Whisperer  
              Started by halgo_boulder, 04-20-2024, 08:44 AM
              2 responses
              22 views
              0 likes
              Last Post halgo_boulder  
              Started by mishhh, 05-25-2010, 08:54 AM
              19 responses
              6,189 views
              0 likes
              Last Post rene69851  
              Working...
              X