• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.
    http://ninjatrader.com/support/helpG...niteration.htm

    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 Johnny Santiago, Today, 04:50 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_ChrisSch  
          Started by rickyblah12, Yesterday, 08:17 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by jamarc, Today, 02:30 AM
          0 responses
          4 views
          0 likes
          Last Post jamarc
          by jamarc
           
          Started by mrlucky1x, Yesterday, 08:07 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by uday12, Yesterday, 07:21 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Jim  
          Working...
          X