Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddOn vs NinjaTrader Exit/Shutdown

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

    AddOn vs NinjaTrader Exit/Shutdown

    When Exiting (shutting down) NinjaTrader, how should one handle disposing of AddOn variables declared in AddOnBase that should, in normal usage, be Disposed, or at least set to null? For example, HttpClient or similar. Is there any need (or good reason) to do this when Exiting? If so, where is that done?

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    Thank you for your reply.

    Yes, is important to unsubscribe from event handlers and dispose of unused resources when they are no longer needed. The OnWindowDestroyed() method can be used to clean up any resources when closing out of NinjaTrader.

    I'm attaching this example AddOnShell that demonstrates cleaning up a click handler and removing the menu item for the window from the Control Center when the Control Center is closed.

    Please let us know if we may be of further assistance to you.


    Attached Files

    Comment


      #3
      Thanks, Kate.

      So, if I understand you correctly, all exit handling actions can/should be performed in OnWindowDestroyed() when that window is known to be the Control Center?

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello jeronymite,

        Thank you for your reply.

        That's correct, you'd want to handle that in OnWindowDestroyed.

        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Thanks, Kate.

          This is good to know. Nonetheless, OnWindowDestroyed is called when a NinjaScript object is compiled as, apparently, that causes all existing windows to be destroyed and recreated. Is there a way to determine unequivocally that NinjaTrader is shutting down and that's why the windows are destroyed?

          Thanks.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment


            #6
            Hello jeronymite,

            Thank you for your reply.

            If the ControlCenter window is updating OnWindowDestroyed() then likely NinjaTrader is shutting down, since closing that window isn't possible without exiting the platform.

            Please let us know if we may be of further assistance to you.

            Comment


              #7
              Thanks again, Kate.

              Actually, all windows are destroyed and recreated when an AddOn is compiled. This can easily be seen if one prints a diagnostic message in both OnWindowDestroyed and OnWindowCreated identifying the window being destroyed or created. The ControlCenter is always one of those windows. So, without further explicit and definitive information, it is not possible, from within OnWindowDestroyed alone, to know if NinjaTrader is shutting down or if it is a recompile.

              Grateful for your further investigation to determine how one might unequivocally know that NinjaTrader is shutting down as opposed to a recompile being done.

              Thanks.
              Multi-Dimensional Managed Trading
              jeronymite
              NinjaTrader Ecosystem Vendor - Mizpah Software

              Comment


                #8
                Hello jeronymite,

                Thank you for your reply.

                There would not be an alternate method to determine whether NinjaTrader is shutting down. We do have an existing feature request to add a property to OnWindowDestroyed() that tells if the addon window is being closed by the user or by NinjaTrader closing the workspace / shutting down. I have added a vote on your behalf to this request, which is being tracked using the number SFT-4752.

                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.

                Comment


                  #9
                  That's good, Kate. Thanks for the vote. It would also be good for that determination to be aware if a recompile is occurring.

                  Thanks.
                  Multi-Dimensional Managed Trading
                  jeronymite
                  NinjaTrader Ecosystem Vendor - Mizpah Software

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  558 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  324 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  101 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  545 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  547 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X