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

Autorun Addon

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

    Autorun Addon

    Hello,

    Is There a method to run an Addon automatically at Ninjatrader start ?

    Thanks !
    johnok
    NinjaTrader Ecosystem Vendor - Trade With Me

    #2
    Hi Johnok.

    I had an issue with debugging an addon just last week and made this very basic and simple addon to test the lifecycle of an addon you might find useful. It prints out its status as it transitions between states. The numerical value is the hashcode of the addon, so you can identify which ones are being instantiated and which are being destructed.

    To Answer your question, addons are automatically detected and started when Ninjatrader starts (or when recompile happens) and they exist as Singletons for the lifetime of the app process (or until a recompile happens: one starts and the old one is destroyed).

    NB: Addons are started before the output window appears so you'll need to do rebuilds to observe the output on my test addon. If you do continuous rebuilds you'll see a new addon starting up and the old one being deconstructed by the garbage collector.

    One thing I will warn you about is that the AddonBase class constructor calls the OnStateChange method of your Addon method BEFORE it calls the constructor of your addon. so make sure you don't use the constructor of your addon for instantiating instances of other classes you may require. I spent days trying to figure out why my addon wasn't working and it was because my I was using the constructor of my addon for instantiating things and they were being utilised via the base class before they my constructor had been called, so my instances had not yet been created. This resulted in a NullReference exception and a silent failure; took a couple of days to figure out what was going on.

    Hope this helps.

    Kevin.
    Attached Files

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by andrewtrades, Today, 04:57 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    5 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    436 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    7 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X