Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

On script remove event

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

    On script remove event

    Hello!

    How to catch OnStrategyRemove event? I use some object that need to be disposed after strategy removed from chart. I tried to use state Terminated but it call after settings window close. The same problem with using standard class destructor (~ClassName).

    How can I do this?

    #2
    Hello Dzammer,

    I'm not aware of any property or method that is triggered when a strategy instance (that may already be disabled) is removed from a chart (or the Strategies tab of the Control Center).

    I will forward a feature request on your behalf for the Development to consider creating a public method that is triggered when an instance of a strategy is removed (and not just disabled).

    However, I'm not quite understanding why OnStateChange when State is State.Terminated is not sufficient for this. This is where it would be recommend to clean up resources.
    Can you further describe why this would not work for your goals?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi, Chelsea.

      I recorded a small video where you can see a problem. http://take.ms/16fRd0

      When I add strategy to the chart and push "Ok" button I have this states:
      1. SetDefaults
      2. Terminated
      3. Terminated

      So the strategy is added and works but the last state is "Terminated"
      Attached Files

      Comment


        #4
        Hello Dzammer,

        This is expected as some instances created for the Strategies window are terminated.

        Below is a public link to the help guide on the lifecycle of a NinjaScript.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by kinfxhk, 07-13-2026, 10:18 AM
        0 responses
        59 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-13-2026, 09:50 AM
        0 responses
        41 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-13-2026, 07:21 AM
        0 responses
        47 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 07-11-2026, 02:11 AM
        0 responses
        38 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        157 views
        0 likes
        Last Post SalmaTrader  
        Working...
        X