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

Feature Request: Trace/Log to include entire exception data

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

    Feature Request: Trace/Log to include entire exception data

    When an exception is thrown inside the OnBarUpdate method, NT8 logs just the exception message.
    Please make it log and trace the entire exception data obtained via exception.ToString()
    Thanks

    #2
    I agree. I think NinjaTrader could probably do a better job capturing and reporting exceptions,
    although I'm still more familiar with NT7 than NT8 ... I was hoping NT8 was better than NT7.

    FWIW, long ago, like everyone else, I used to do this,

    Code:
    protected override void OnStartUp()
    {
    ...my code here...
    }
    
    protected override void OnBarUpdate()
    {
    ...my code here...
    }
    Now, for every indicator and strategy, I wrap every NinjaTrader Framework method
    in a simple try-catch, precisely to compensate for the issues you raise here.

    Code:
    protected override void OnStartUp()
    {
        try {
            OnStartUp_Handler()
        }
        catch (Exception ex) {
            HandleException(ex);
            throw;
        }
    }
    
    protected override void OnBarUpdate()
    {
        try {
            OnBarUpdate_Handler()
        }
        catch (Exception ex) {
            HandleException(ex);
            throw;
        }
    }
    My real code now goes here,

    Code:
    private void OnStartUp_Handler()
    {
    ...my code here...
    }
    
    private void OnBarUpdate_Handler()
    {
    ...my code here...
    }
    So now, I always get full details of the exception, including a stack trace,
    because I wrote my HandleException() method to do exactly that. And I
    can write this information to my own debug log, Ninja's output window, or
    the builtin Log facility ... or any combination thereof ... very convenient.

    [The only real annoyance that is left is this: if your properties do anything
    complicated to cause an exception, then this specific technique can't catch
    that -- you'll need to create try/catch traps specific to those properties.]

    Despite the (very small) additional coding, this technique has been an extremely
    worthwhile addition to my toolkit. I'm sure I'll be continuing to use this technique
    in all my NT8 programming.

    Comment


      #3
      Hello bboyle1234 and bltdavid,

      Thank you for your suggestion.

      I've added a feature request to improve the error logging. This request is being tracked under the number SFT-4653.

      As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

      Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

      Please let us know if we may be of further assistance to you.
      Kate W.NinjaTrader Customer Service

      Comment


        #4
        We usually just print to the Output window with something like this....


        Code:
        try
        {
            // ... Logic here
        }
        catch (Exception ex)
        {
            Print(string.Format("Method name EXCEPTION [{0} / {1}]: Msg: {2}{3}   Trace: {4}", _productName, _version, ex.Message, Environment.NewLine, ex.StackTrace));
        }
        This seems to work pretty well for our needs.
        We've also considered using our own logging mechanism in this scenario.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by arvidvanstaey, Today, 02:19 PM
        3 responses
        9 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by jordanq2, Today, 03:10 PM
        2 responses
        8 views
        0 likes
        Last Post jordanq2  
        Started by traderqz, Today, 12:06 AM
        10 responses
        18 views
        0 likes
        Last Post traderqz  
        Started by algospoke, 04-17-2024, 06:40 PM
        5 responses
        47 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by mmckinnm, Today, 01:34 PM
        3 responses
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X