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 helpwanted, Today, 03:06 AM
    1 response
    12 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    9 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    5 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    242 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    387 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X