Announcement

Collapse
No announcement yet.

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 NullPointStrategies, Yesterday, 05:17 AM
              0 responses
              58 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              133 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              73 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              45 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              50 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X