Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Debug Mode adds line number to exception information

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

    Debug Mode adds line number to exception information

    Documentation Suggestion:

    The NinjaTrader documentation below does not mention the enormous time savings that compiling with Debug Mode can yield during testing, even when Visual Studio is not available.

    o Debugging your NinjaScript Code http://www.ninjatrader-support2.com/vb/showthread.php?t=3418
    o Indicator: Using Try-Catch Blocks http://www.ninjatrader-support2.com/vb/showthread.php?t=9825
    o Help for Debug

    Below is the output from indicator SampleTryCatch above with Debug Mode disabled:

    1/9/2009 12:11:00 AM System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    at System.Collections.ArrayList.get_Item(Int32 index)
    at NinjaTrader.Indicator.DataSeriesHelper.get_Item(In t32 barsAgo)
    at NinjaTrader.Indicator.SampleTryCatch.OnBarUpdate()

    After compiling with Debug Mode enabled the output shows the cs file and line number where the exception occurred:

    1/9/2009 12:11:00 AM System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
    at System.Collections.ArrayList.get_Item(Int32 index)
    at NinjaTrader.Indicator.DataSeriesHelper.get_Item(In t32 barsAgo)
    at NinjaTrader.Indicator.SampleTryCatch.OnBarUpdate() in c:\Documents and Settings\JW\My Documents\NinjaTrader 6.5\bin\Custom\Indicator\SampleTryCatch.cs:line 57

    I suggest that this benefit of testing with Debug Mode enabled be added to NinjaTrader documentation.

    #2
    Thanks for pointing this out.

    Comment


      #3
      Another suggestion: The following message is displayed when a compile is run with Debug Mode enabled:

      Enabling "Debug Mode" should only be used by advanced programmers that intend to debug their NinjaScript code in Visual Studio. Compiling NinjaScript objects with this mode enabled will results in a run time performance penalty.

      PLEASE MAKE SURE YOU DISABLE THIS MODE ONCE YOU ARE COMPLETE WITH YOUR DEBUG AND RECOMPILE YOUR NINJASCRIPT OBJECTS.

      The sentence that I have marked in red is not true and should be removed from the warning.

      Comment


        #4
        Thanks for your feedback. However, we consider debugging NinjaScript as feature for advanced users only.

        Comment


          #5
          Originally posted by NinjaTrader_Dierk View Post
          Thanks for your feedback. However, we consider debugging NinjaScript as feature for advanced users only.

          When I first enabled Debug Mode, I read the warning:

          "Enabling "Debug Mode" should only be used by advanced programmers that intend to debug their NinjaScript code in Visual Studio. . . ."

          and interpreted it as:

          if (Advanced_Programmer & Have_Visual_Studio)
          Debug_Mode_will_help_find_errors = true

          else
          Debug_Mode_will_help_find_errors = false

          Since I did not have Visual Studio, I disabled Debug Mode and did not try it again until recently. Recently, I was having a problem finding the cause of an intermittent exception using the recommendations from "Debugging your NinjaScript Code" http://www.ninjatrader-support2.com/vb/showthread.php?t=3418 . After several days I downloaded the trial version of Visual Studio. While following the instructions for using it with NT I enabled Debug Mode. Before I even had a chance to start Visual Studio, my catch clause displayed the line number of the statement causing the exception. I inserted the needed "if (Bars.GetSessionBar(i) != null)" statement and the problem was fixed. My first reaction was joy that I had found the problem, but it turned to disgust when I realized the hundreds of hours that I had wasted debugging NT code without Debug Mode enabled.

          I said in my earlier post that the "Enabling "Debug Mode" should only be used by advanced programmers that intend to debug their NinjaScript code in Visual Studio. . . ." statement is not true. I firmly believe that:

          if (Advanced_Programmer & Do_Not_Have_Visual_Studio)
          Debug_Mode_will_help_find_errors = true

          if (Not_Advanced_Programmer & Do_Not_Have_Visual_Studio)
          Debug_Mode_will_help_find_errors = true

          if (Not_Advanced_Programmer & Have_Visual_Studio)
          Debug_Mode_will_help_find_errors = true

          Which means that:
          Debug_Mode_will_help_everyone_find_errors = true
          Last edited by Jim W.; 01-28-2009, 10:29 AM.

          Comment


            #6
            Thanks for adding the details, we fully understand that advanced users benefit from using the debug mode.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              I believe his point is that Visual Studio is not required for using Debug Mode.

              Comment


                #8
                Ya... I agree mgbloomfield...
                I think this 'bandwidth problem' starts to become a real issue...

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jclose, Today, 09:37 PM
                0 responses
                5 views
                0 likes
                Last Post jclose
                by jclose
                 
                Started by WeyldFalcon, 08-07-2020, 06:13 AM
                10 responses
                1,414 views
                0 likes
                Last Post Traderontheroad  
                Started by firefoxforum12, Today, 08:53 PM
                0 responses
                11 views
                0 likes
                Last Post firefoxforum12  
                Started by stafe, Today, 08:34 PM
                0 responses
                11 views
                0 likes
                Last Post stafe
                by stafe
                 
                Started by sastrades, 01-31-2024, 10:19 PM
                11 responses
                169 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X