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