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

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 jclose, Today, 09:37 PM
        0 responses
        4 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,413 views
        0 likes
        Last Post Traderontheroad  
        Started by firefoxforum12, Today, 08:53 PM
        0 responses
        10 views
        0 likes
        Last Post firefoxforum12  
        Started by stafe, Today, 08:34 PM
        0 responses
        10 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by sastrades, 01-31-2024, 10:19 PM
        11 responses
        169 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X