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

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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Max238, Today, 01:28 AM
    5 responses
    40 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by giulyko00, Yesterday, 12:03 PM
    3 responses
    12 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by habeebft, Today, 07:27 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_ChristopherS  
    Started by AveryFlynn, Today, 04:57 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by r68cervera, Today, 05:29 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X