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

Delete Strategy from Strategies Tab

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

    Delete Strategy from Strategies Tab

    Hi there, I built a service to auto-load and start strategies in NT8 and would like to know if there was a way for me to have it DELETE itself from the strategies tab. As of right now I'm using a timer to auto-terminate if a trade isn't made within 15 minutes(if it doesn't happen within 15, it ain't happening according to my strategy. The issue is that even though the strategy is disabling it's still holding on to a little bit of ram. Unfortunately towards the end of the trading day it actually leaks so badly that NT locks up. Is there a way to stop that leak, or remove the strategy from the list entirely?

    #2
    Hi RaddiFX, thanks for posting.

    Removing strategies automatically is not supported. There is code running in the strategy that is taking up the memeory. The script would need to be reduced to test for a memory leak.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chris.

      How about any unsupported ways, haha. I can deal with the repercussions and I can also deal with programming it myself, I'd just need to know where the active strategies would be stored, or what's being called when I remove them from the list.

      Comment


        #4
        Hi RaddiFX,

        I do not know of any way to remove a strategy from the configured list programmatically.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          So I did a fair amount of digging and testing.

          Long story short, I was able to find the method for removing a strategy from the strategies grid. My question now is how do I tell it which strategy I need to remove. I've gotten as far as adding a new strategy, but that's with me providing all of the NEW information. I now need to find information about strategies that are already enabled and on the grid.

          Just as an example, here is a shortened version of how to add a strategy:

          try{
          NinjaTrader.Gui.NinjaScript.StrategiesGrid sg=new NinjaTrader.Gui.NinjaScript.StrategiesGrid();

          System.Reflection.MethodInfo dynMethod = sg.GetType().GetMethod("StrategyAdd",
          System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
          if (dynMethod!=null)
          dynMethod.Invoke(sg, new object[] { s });

          dynMethod = sg.GetType().GetMethod("StrategyEnable",
          System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
          dynMethod.Invoke(sg, new object[] { s, null, null });

          }

          s being the strategy and you having set all of its parameters earlier.

          Attached is a quick addon I wrote to explore the available methods and how to call them.
          Attached Files

          Comment


            #6
            Hi RaddiFX, I apologize but I won't be able to help with the unsupported code. Other members of the forum will need to assist if they are able.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              If anyone is looking to do this in the future... don't, lol... I figured it out and it doesn't do what I wanted. However, you can run the
              Code:
              CloseStrategy("Exterminate");
              command to close out the strategy and it will do a full cleanup.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by rajendrasubedi2023, Today, 09:50 AM
              3 responses
              15 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by lorem, Today, 09:18 AM
              2 responses
              11 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by geddyisodin, Today, 05:20 AM
              4 responses
              29 views
              0 likes
              Last Post geddyisodin  
              Started by geotrades1, Today, 10:02 AM
              2 responses
              10 views
              0 likes
              Last Post geotrades1  
              Started by ender_wiggum, Today, 09:50 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X