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

Ninjascript way to identify if in OnTermination event

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

    Ninjascript way to identify if in OnTermination event

    Hi,

    I'm overloading OnTermination with some code to clean up and log stuff in my indicator and I have hit a problem.

    When I am running my indicator and I re-load the ninjascript from the right-click menu, the OnTermination event triggers at some point as a consequence. I do some stuff with the multiple bars and the CurrentBar number etc.

    I just found that re-loading the historical data calls the OnTermination event but at a different point, a point at which something in the BarsArray had been cleaned up by Ninja already and it caused my OnTermination code to break.

    Can you tell me what one single variable or state can I check in my OnTermination event to determine whether Ninja is stopping the indicator script?

    e.g. is there something useful like Indicator.ScriptTerminatingNow

    #2
    OnTermination itself would be what would be called when the indicator is stopping. This would happen after manually disabling the indicator, reloading the NinjaScript or after reloading historical data. I'm not aware of a way to check for this outside of the event itself.

    If this is causing problems for you, you may want to consider creating your own Dispose methods and calling them in your own custom event trigger method:

    In this article, learn to implement the Dispose method, which releases unmanaged resources used by your code in .NET.


    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,404 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    95 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    8 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    159 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    8 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X