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

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
    Kate W.NinjaTrader Customer Service

    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.
        Kate W.NinjaTrader Customer Service

        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.
            Kate W.NinjaTrader Customer Service

            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.
                Kate W.NinjaTrader Customer Service

                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 GLFX005, Today, 03:23 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post GLFX005
                  by GLFX005
                   
                  Started by XXtrader, Yesterday, 11:30 PM
                  2 responses
                  11 views
                  0 likes
                  Last Post XXtrader  
                  Started by Waxavi, Today, 02:10 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post Waxavi
                  by Waxavi
                   
                  Started by TradeForge, Today, 02:09 AM
                  0 responses
                  12 views
                  0 likes
                  Last Post TradeForge  
                  Started by Waxavi, Today, 02:00 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post Waxavi
                  by Waxavi
                   
                  Working...
                  X