Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnTermination

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

    OnTermination

    Hi

    I try to catch the event of disabling my strategy (similar to OnTermination at NT7). To my understanding the equivalent is the OnStateChange event when State == State.Terminated.
    However this event is fired even if my strategy was not even enabled in the first place, which causes errors on my strategy to be printed to the output window.
    How can I catch the event when the strategy is disabled only?

    Thanks

    #2
    Hello kiss987,

    A script that is not enabled may still have been configured and may still need to clean up resources.

    Have a bool that is set to false in State.SetDefaults. In OnStateChange() when State is State.DataLoaded set the bool to true. In OnStateChange() when State is State.Terminated if the bool is true the script was enabled and you can set the bool back to false.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    47 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Working...
    X