Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with an instance of indicator

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

    Problem with an instance of indicator

    Hi,

    I am developing a strategy in strategy builder but a I have the following error:

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

    The indicator is displayed in the chart perfectly, only have problems when I create a simple strategy using it.

    I attached the code and the indicator.

    Thanks,
    Attached Files

    #2
    Hello jairotunior,

    Thanks for opening the thread. And welcome to the forums!

    The error is reporting a runtime error for that indicator in the OnStateChange() method. I recommend reaching out to the developer of this indicator and let them know you are hitting this issue when adding the indicator to a strategy.

    If you would like to debug and fix the issue yourself, I recommend adding prints after each line in OnStateChange() under State.SetDefaults and State.Configure so you can see which line of code throws the runtime error.

    At a glance, I can say it would not be advised to check for ChartBars.ToIndex or ChartBars.FromIndex in State.DataLoaded or in State.Configure since these objects will not be available until rendering has started on a chart. I would instead recommend to get this value after rendering has started and check for it as early as State.Historical.

    I've included a link on debugging - https://ninjatrader.com/support/foru...ead.php?t=3418

    You may also hire a NinjaScript Consultant who would be happy to review this code and apply any needed fixes. If that is the case, please let me know and I can have a member of our business development team reach out with additional information.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    52 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X