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

Make NT8 more resilient to buggy custom code

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

    Make NT8 more resilient to buggy custom code

    Hi,

    I have developed some add-ons, indicators and drawing tools recently for my private use. During development, I had several occurrences of the NT8 application crashing outright, after apparently not catching unexpected exceptions. This was due to buggy code on my side.

    While I can't remember or reproduce any of the exact circumstances that led to these application crashes, I wonder if we can work towards making NT8 more resilient against user programming errors. I believe NT8 should at least try not to crash as a result of an exception in custom code.

    I have attached a minimal indicator example that demonstrates the issue. The only line added by me is the construction of an invalid DateTime (line 29).

    Steps to reproduce (using NT 8.0.8.0):
    1. Add GurkCrash.cs to the Custom/Indicators folder
    2. compile
    3. right-click into a Chart window and
    4. select "Indicator..." from the context menu

    This is sufficient to display the attached error message and subsequently crash the NT8 application.

    Thoughts?

    Kind regards,
    Stefan.
    Attached Files

    #2
    Hello Stefan,

    The improper object initialization would cause a constructor error which is not possible to be caught with a try and catch as these can only be used in run time.

    You can prevent these errors by coding in the style where IsInstantiatedOnEachOptimizationIteration can be set to false, declaring the variable in the scope of the class but not initializing the object until State.DataLoaded.


    That said, I am happy to submit a feature request on your behalf for the NinjaTrader Development to try and find a way to prevent NinjaTrader from crashing when encountering this type of error.
    Once I have a tracking ID for this request I will forward this to you for future reference.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      after pondering your reply for a day I believe I understand what you're getting at. I understand the lifecycle of a NT object better now. Thank you.

      Still, speaking of a C# class generally, when I make the constuctor of that class throw an exception, the instance is never constructed and therefore not useable. When NT tries to create my sample indicator (GurkCrash), the variable supposed to hold the GurkCrash instance will be a null reference. Am I getting that right? If so, I believe NT8 should internally check for such a null reference and continue without the offending class, thereby avoiding a crash. Maybe my understanding fails at this point - would that be impossible to check against?

      Kind regards,
      Stefan.

      Comment


        #4
        Hi Stefan,

        I'll go ahead and send a report about the crash and create a feature request on your behalf to prevent crashes when experiencing constructor errors in NinjaScripts.

        Once I have a tracking ID for the request I will forward this to you for future reference.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Stefan,

          I've received a tracking ID for your request.

          Your request for scripting mistakes to not crash ninjatrader is being tracked with ID #SFT-2687.

          Please note it is up to the NinjaTrader Development to decide if and when a request will be implemented.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Christopher_R, Today, 12:29 AM
          0 responses
          9 views
          0 likes
          Last Post Christopher_R  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          166 responses
          2,235 views
          0 likes
          Last Post sidlercom80  
          Started by thread, Yesterday, 11:58 PM
          0 responses
          3 views
          0 likes
          Last Post thread
          by thread
           
          Started by jclose, Yesterday, 09:37 PM
          0 responses
          8 views
          0 likes
          Last Post jclose
          by jclose
           
          Started by WeyldFalcon, 08-07-2020, 06:13 AM
          10 responses
          1,415 views
          0 likes
          Last Post Traderontheroad  
          Working...
          X