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 NullPointStrategies, Today, 05:17 AM
    0 responses
    41 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    64 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X