• 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

NT8b9 Exception handling (general)

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

    NT8b9 Exception handling (general)

    While developing new NinjaScripts (mostly Indicators) I have experienced quite a lot of stalling and crashing. Whenever this happens (and that usually forces me to kill NT process completely) and I start debugging in VS the problem is always with some unhandled exception, whether it is NullReference, ArgumentOutOfRange or whatever else.

    The stalling/crashing happens often enough to make me think development without Visual Studio for debugging is at the moment virtually impossible.

    Is this problem recognized and addressed by the development team or am I exceptional with my issues?

    #2
    I've only had 2 indicators custom, and over 200 strategies (mostly same code base)


    The only exceptions I get are in their code.

    Do you only have 1 work space open at a time? Close any that are not in use.

    Not using VS here.

    Comment


      #3
      Thanks sledge, yes I do happen to have 1+ workspace open at a time, I will try to make sure other ones are closed.

      In the meantime what would happen if eg.
      1. You try to edit a dictionary that you forgot to instantiate
      2. You try to get the value with out of range index, eg: mySeries[-1]

      In my case the chart simply stalls and to get what is the error/exception I need to debug with VS.

      Comment


        #4
        Originally posted by gregid View Post
        2. You try to get the value with out of range index, eg: mySeries[-1]

        .


        I have something in a strategy that is randomly happening on a contract startup. I replay from es03-14 post zenfire collapse.

        Sometimes it is fine, doesn't hapen. Then next replay run, a strategy disables because of the error. The chart is fine which had the indicator, and works.



        http://ninjatrader.com/support/forum...ad.php?t=83133

        Comment


          #5
          I just got another of the stall/crash type. This time I got an error message in the Log:
          "A hosted indicator tried to load additional data. All data must be first loaded by the hosting NinjaScript in its configure state"

          The error itself is quite clear - but the crash is not what I expect. This time just one workspace open.

          Comment


            #6
            It looks like NT staff was able to replicate it in B6... no tracking # provided so who knows what happened to it.

            http://ninjatrader.com/support/forum...dditional+data

            Comment


              #7
              Originally posted by gregid View Post
              I just got another of the stall/crash type. This time I got an error message in the Log:
              "A hosted indicator tried to load additional data. All data must be first loaded by the hosting NinjaScript in its configure state"

              The error itself is quite clear - but the crash is not what I expect. This time just one workspace open.
              What about using try/catch?
              In most cases, it can prevent a platform crash.
              ninZa
              NinjaTrader Ecosystem Vendor - Ninza

              Comment


                #8
                Originally posted by ninZa View Post
                What about using try/catch?
                In most cases, it can prevent a platform crash.
                I tend to use try/catch for anything non-standard... but since I have never had to do it for typical operations in NT it didn't cross my mind to use it more liberally so thanks for suggestion!

                Comment


                  #9
                  Since I put entire OnBarUpdate inside try/catch my NT doesn't crash any more on the simple exceptions. I do hope however these exceptions will be handled by core code and base classes in the final release as they were handled properly in NT7.

                  Comment


                    #10
                    Originally posted by sledge View Post
                    It looks like NT staff was able to replicate it in B6... no tracking # provided so who knows what happened to it.

                    http://ninjatrader.com/support/forum...dditional+data
                    As far as this is concerned, this is expected. Please see my post at the following link and let me know if you have any questions.

                    http://ninjatrader.com/support/forum...57&postcount=2
                    Patrick H.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Patrick - could you also address the main topic of this thread - which is lack of exception handling by NT8.

                      Comment


                        #12
                        Hello gregid,

                        Thank you for your patience.

                        What specific exceptions are missed by NinjaTrader and caught by Visual Studio in this scenario?
                        Patrick H.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_PatrickH View Post
                          Hello gregid,

                          Thank you for your patience.

                          What specific exceptions are missed by NinjaTrader and caught by Visual Studio in this scenario?
                          As mentioned in the first post the two most obvious are:
                          - NullReference (eg. editing an object with no instance created beforehand)
                          - ArgumentOutOfRange (eg. MySeries[-1])

                          But more generally I don't see any fallback exception handling, ie.: something that would protect from stalling/crash when the exact exception handling is not in place. For example in my current code I use the following:
                          Code:
                          protected override void OnBarUpdate()
                          {
                             try
                             {
                                 SafeOnBarUpdate();
                             }
                             catch (Exception ex)
                             {
                                 Print(ex);
                             }
                          }
                          private void SafeOnBarUpdate()
                          {
                             //all the OnBarUpdate logic here
                          }
                          
                          This simple fallback saves me a lot of trouble and as much as I can continue using it I raise it as potential issue in the final release. I would suggest this (fallback) could be done from the base class level.
                          Last edited by gregid; 03-08-2016, 01:59 PM.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Vps by stooby
                          Started by stooby, Today, 08:32 PM
                          0 responses
                          11 views
                          0 likes
                          Last Post stooby
                          by stooby
                           
                          Started by FaaastEddy, Today, 08:25 PM
                          0 responses
                          3 views
                          0 likes
                          Last Post FaaastEddy  
                          Started by YevhenShynkarenko, Yesterday, 01:22 AM
                          2 responses
                          39 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by testingsarasa, 05-20-2018, 02:50 PM
                          11 responses
                          737 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by martyn73, Today, 05:27 PM
                          2 responses
                          10 views
                          0 likes
                          Last Post martyn73  
                          Working...
                          X