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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X