• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
        https://ninjatrader.com/support/help...fecycle_of.htm
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sledge, Today, 07:39 AM
        0 responses
        1 view
        0 likes
        Last Post sledge
        by sledge
         
        Started by Fness2020, Yesterday, 08:29 PM
        1 response
        28 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by Hurrikane, Yesterday, 09:18 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by stewarco, Today, 05:46 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jermaine  
        Started by andrewtrades, Yesterday, 08:24 PM
        2 responses
        15 views
        0 likes
        Last Post NinjaTrader_ChristopherD  
        Working...
        X