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

How to create new strategy instances programmatically?

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

    How to create new strategy instances programmatically?

    I want to run a multi-instrument strategy on a lot of instruments (with a new bar every several minutes) and from this strategy identify a few of those instruments to be monitored in more detail and potentially traded. Those few chosen instruments would be traded in an additional single-instrument strategy that would access tick data for each chosen instrument. The instruments chosen for more intense monitoring would change dynamically as the multi-instrument strategy runs in order to limit bandwidth usage.

    One way to do this would be for the multi-instrument strategy to add a new single-instrument strategy to the Strategies tab of the Control Center for each of the chosen instruments. Then, when it was no longer necessary to monitor an instrument, that instrument's strategy could be removed or disabled by the main multi-instrument strategy. Is it possible to do this within the code of a strategy? How?

    Is it true that if a strategy is "Disabled" on the Strategies tab, the request to the data provider for a data stream for that instrument is cancelled?

    An alternative approach could be to add a single-instrument strategy for every instument in my instrument list to the Control Center manually and then have the multi-instrument strategy enable/disable only the instances of the single-instrument strategy that are chosen/unchosen. Is there a way to access a list of all the strategies that are running in NT and change the property that "enables" the strategy from within the multi-instrument strategy?

    Yet another possibility would be to add a second (tick level) data series for each instrument to my multi-instrument strategy and disable all but the chosen data series to keep the bandwidth requirements manageable. Is it possible to disable/enable a data series from within OnBarUpdate()? I am assuming it is not possible to add or remove a data series from within OnBarUpdate(). Is that true?

    Any suggestions for the best way to approach this problem will be greatly appreciated.

    #2
    Hello,

    Thanks for the forum post.

    Good idea's, however Unfortunately unsupported. I'm not saying that it cant be done however we have simply not built any NinjaScript functions to do what you describe.You may want to check out this thread for unsupported tips and tricks and possibly post there, http://www.ninjatrader.com/support/f...supported+tips


    Your answers below:

    One way to do this would be for the multi-instrument strategy to add a new single-instrument strategy to the Strategies tab of the Control Center for each of the chosen instruments. Then, when it was no longer necessary to monitor an instrument, that instrument's strategy could be removed or disabled by the main multi-instrument strategy. Is it possible to do this within the code of a strategy? How?

    Brett: Unfortunately Unsupported.

    Is it true that if a strategy is "Disabled" on the Strategies tab, the request to the data provider for a data stream for that instrument is cancelled?

    Brett: This is true, Data connection is closed when you Disable the strategy.

    An alternative approach could be to add a single-instrument strategy for every instument in my instrument list to the Control Center manually and then have the multi-instrument strategy enable/disable only the instances of the single-instrument strategy that are chosen/unchosen. Is there a way to access a list of all the strategies that are running in NT and change the property that "enables" the strategy from within the multi-instrument strategy?

    Brett: Again Unsupported, As there are no NinjaScript function that allows you to enable a strategy.

    Yet another possibility would be to add a second (tick level) data series for each instrument to my multi-instrument strategy and disable all but the chosen data series to keep the bandwidth requirements manageable. Is it possible to disable/enable a data series from within OnBarUpdate()? I am assuming it is not possible to add or remove a data series from within OnBarUpdate(). Is that true?

    Brett: This is true, you must have all data series loaded before the strategy starts. You cannot change this dynamically.


    Let me know if I can be of further assistance.

    Comment


      #3
      Another Approach

      Brett:

      Thanks for the quick response.

      Please add a function to Add(Strategy, ...) to the Strategies tab of Control Center from within a strategy to the wish list.

      In the mean time, is there any fundamental reason that it would not work to do:

      Strategy MySingleInstr = new Strategy(Instr, {other arguments});

      within my multi-instrument strategy, let it run for a while, and then call:

      MySingleInstr.OnTerminate();

      when I want to shut that instrument down?

      I am new to C#, but it seems there is no delete operator in it. If I subsequently execute again

      Strategy MySingleInstr = new Strategy();

      will that immediately send the first instance to garbage collection and terminate the request for data from the data provider? Or, can you directly call the destructor of the Strategy object?

      Any suggestions you can provide will be greatly appreciated.

      Comment


        #4
        Hello,

        Sure absolutly on the below I will send into development as a suggestion and get you a tracking number from development. Thanks for that.

        Also, as far as the rest of your tread this may or may not work. Since its not supported I really can't comment on it sorry.

        Let me know if I can be of further assistance.

        Comment


          #5
          Do we know if this functionality has been added or if there is still a request ticket open for it?

          Comment


            #6
            Hello magnataruren,

            This functionality is not yet implemented and we are still tracking demand before making moves to implement that functionality. The internal ticket ID is SFT-392 and I have added a vote on your behalf.

            Feature Request Disclaimer

            We receive many requests and cannot reasonably implement all requested features or changes. Interest is tracked internally and if enough interest is tracked, it would be weighed against how feasible it would be to make those changes to consider implementing.

            When new features are implemented, they will be listed in the Release Notes page of the Help Guide. The ID number will be different than the internal feature request tracking ID, but the description of the feature will let you know if that feature has been implemented.

            Release Notes -
            https://ninjatrader.com/support/help...ease_notes.htm

            We look forward to assisting.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            17 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            5 views
            0 likes
            Last Post Creamers  
            Started by Segwin, 05-07-2018, 02:15 PM
            12 responses
            1,786 views
            0 likes
            Last Post Leafcutter  
            Started by poplagelu, Today, 05:00 AM
            0 responses
            3 views
            0 likes
            Last Post poplagelu  
            Started by fx.practic, 10-15-2013, 12:53 AM
            5 responses
            5,408 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Working...
            X