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

Catching termination of strategy...

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

    Catching termination of strategy...

    Hi,

    Is there anything I can do, to execute some clean-up code when my strategy is *terminated*? Some kind of global finalize?

    The problem is I'm using the .NET FileSystemWatcher class, so I can monitor changes to one of my configuration file. If I modify a file, my strategy real-time reloads some parameters, etc.

    When I terminate the strategy, I'd like to stop monitoring the configuration file. So far, haven't seen a way of doing that.

    #2
    Hi heech, I think the method you're looking for is Dispose().
    AustinNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Austin View Post
      Hi heech, I think the method you're looking for is Dispose().
      That's it! Thank you sir.

      Comment


        #4
        Hi Heech, Austin,

        Recalling my memory I would say that Dispose() is only called when you remove the strategy.

        If my memory is correct: Once a strategy gets flat after a trade the strategy has realized P/L and (true?) start/stop cell becomes stopped.

        But to call Dispose() one must manually remove the strategy.


        So maybe you should monitor the change of the cells start/stop or realized P/L of the strategies' row in the grid?
        You can do this, you must get access to the SourceGrid2
        strategyGridDisplay1
        (possible, but undocumented) and then you can add a IBehaviorModel to the cell in question. (look through sourcegrid2.dll) . OnValueChanged(..) is a good place to put your stop filesystemwatcher code.

        best regards
        Andreas

        Comment


          #5
          Originally posted by zweistein View Post
          Hi Heech, Austin,

          Recalling my memory I would say that Dispose() is only called when you remove the strategy.
          You are exactly right. I've just tested this. For my purposes for now, I will just be sure to "remove strategy".

          I'd love to hear more about these undocumented features though, if you've built up a collection of similar things we can automate! Any clever ways to programmatically disconnect/reconnect, or start a new strategy, for example?

          Comment


            #6
            with NT7 coming soon I think one should concentrate on other parts in the strategy logic. Undocumented features will definetely change.


            For example I have added a parameters dialog ( pops up when clicking the strategy's parameter cell) where I can change the strategy parameters after the strategy has already started.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Zeezee, Today, 12:45 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Started by tomasak, Today, 12:54 PM
            0 responses
            1 view
            0 likes
            Last Post tomasak
            by tomasak
             
            Started by swjake, Today, 12:04 PM
            2 responses
            9 views
            0 likes
            Last Post swjake
            by swjake
             
            Started by Richozzy38, Yesterday, 01:06 PM
            5 responses
            24 views
            0 likes
            Last Post Richozzy38  
            Started by tradingnasdaqprueba, 05-07-2024, 03:42 AM
            13 responses
            52 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X