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

Detect if addon is already started

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

    Detect if addon is already started

    Hello,

    Is there a way to detect if my addon is already started ? I would like to force user to have only one addon started.

    Thanks for the help !

    Sebastien
    johnok
    NinjaTrader Ecosystem Vendor - Trade With Me

    #2
    Hello johnok,

    Thank you for your inquiry.

    All authorized addons will be automatically started when the platform loads - what is the use case here? You can only have one instance of the same add-on compiled and running simultaneously, so I'm unsure what you mean. Are you trying to force the use of only your add-on?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your answer.

      In my case, i've an addon who can help user to manager there positions. But if the user start multiple instance of this addon, managed positions could be impacted by all instance in same time and it's not good.

      To avoid this impact, i'm searching if my addon can check at start with lockfile ? Mutex ? or maybe a Ninjascript attribute if this addon is already started once and cancel the start.

      Thanks
      johnok
      NinjaTrader Ecosystem Vendor - Trade With Me

      Comment


        #4
        Hello johnok,

        Thank you for your reply.

        If there are multiple installed addons with the same class names, only the first one alphabetically will be loaded. The other instances of the add-on would be ignored. There can only be one instance of the same addon running at once.

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

        Comment


          #5
          Oh, that's was my mistake, the problem seems to be about event cleaning and not multiple addon instance.

          The event OnExecutionUpdate is called multiple times after re-compilation of my addon. I have an Addon with xaml code and i'm using "Closing" method to unbind this event but the event seem to be duplicated and not cleaned because my addon is not stopped.

          I'm now searching how to check if event are already binded or unbind properly.

          johnok
          NinjaTrader Ecosystem Vendor - Trade With Me

          Comment


            #6
            And when i try to use Cleanup method, i get the error message: "No method has been found for the substitution" (in french).

            I don't know where to place this method who could maybe do the job.
            johnok
            NinjaTrader Ecosystem Vendor - Trade With Me

            Comment


              #7
              Hello johnok,

              Thank you for your reply.

              In an add-on, you would want to unsubscribe from any event handlers and dispose of any resources that need it in OnWindowDestroyed(). From our help guide:

              Code:
              // Will be called as a new NTWindow is destroyed. It will be called in the thread of that window
              protected override void OnWindowDestroyed(Window window)
              {
                if (addOnFrameworkMenuItem != null && window is ControlCenter)
                {
                    if (existingMenuItemInControlCenter != null && existingMenuItemInControlCenter.Items.Contains(addOnFrameworkMenuItem))
                        existingMenuItemInControlCenter.Items.Remove(addOnFrameworkMenuItem);
              
                    addOnFrameworkMenuItem.Click -= OnMenuItemClick;
                    addOnFrameworkMenuItem = null;
                }
              }
              I would suggest reviewing this section of the help guide on creating an addon:



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

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bmartz, 03-12-2024, 06:12 AM
              4 responses
              31 views
              0 likes
              Last Post bmartz
              by bmartz
               
              Started by Aviram Y, Today, 05:29 AM
              4 responses
              12 views
              0 likes
              Last Post Aviram Y  
              Started by algospoke, 04-17-2024, 06:40 PM
              3 responses
              28 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by gentlebenthebear, Today, 01:30 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by cls71, Today, 04:45 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X