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

Calling a Strategy from another one

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

    Calling a Strategy from another one

    Hello,

    I'm quite new to NT- and C# - coding (but not programming at all).

    I have a strategy running for a couple of Forex-Pairs. The strategy is compiled and has around 50 inout parameters. Every time I wanna activate this one, I have to check all the parameters which is annoying.

    That's why I wanna create a strategy that simply calls this strategy with all the needed parameters so that I only have to put them into my strategy once. Imagin this like the follows:

    if(Instrument.FullName == "EURUSD")
    {
    Strategy(ABC).Call(param1,param2....param50)
    }
    else if (Instrument.FullName == "EURJPY")
    {
    Strategy(ABC).Call(param1x,param2x....param50x)
    }

    Is that possible? I guess I have to kind of "include" the Strategy ABC into my code. And/Or have to create an intance of X times the Strategy (for each Instrument).....
    Are there any examples available? I searched the forum but couldn't find any useful snippets.

    Bye
    Steakley

    #2
    Originally posted by steakley View Post
    Hello,

    I'm quite new to NT- and C# - coding (but not programming at all).

    I have a strategy running for a couple of Forex-Pairs. The strategy is compiled and has around 50 inout parameters. Every time I wanna activate this one, I have to check all the parameters which is annoying.

    That's why I wanna create a strategy that simply calls this strategy with all the needed parameters so that I only have to put them into my strategy once. Imagin this like the follows:

    if(Instrument.FullName == "EURUSD")
    {
    Strategy(ABC).Call(param1,param2....param50)
    }
    else if (Instrument.FullName == "EURJPY")
    {
    Strategy(ABC).Call(param1x,param2x....param50x)
    }

    Is that possible? I guess I have to kind of "include" the Strategy ABC into my code. And/Or have to create an intance of X times the Strategy (for each Instrument).....
    Are there any examples available? I searched the forum but couldn't find any useful snippets.

    Bye
    Steakley
    You cannot call a Strategy from a another Strategy. If you want to do what you have listed, do it in the Initialize() or OnStartUp() methods, by setting the parameter defaults using an if() or switch() statement.

    Comment


      #3
      Hello steakley,

      Thank you for your post and welcome to the NinjaTrader Support Forum!

      Koganam's post here is correct, you cannot call a strategy from another strategy.

      You could simply right click in the parameters section when setting up your strategy and select 'SetAsDefault for 'yourstrategyName'" after setting the parameters to make them the default parameters.

      For information on working with strategies please visit the following link: http://www.ninjatrader.com/support/h...strategies.htm

      Please let me know if I may be of further assistance.

      Comment


        #4
        Hello,

        Thank you both for your answers!

        The strategy is a compiled one. So I can't add anything into the initialize-Section of that strategy. That's why I was interested in calling it from another one.

        I do know about the other suggestion (set as default). But the problem here is that each pair has it's own values which differ from the other pairs. It would be just great to have some kind of possibility to store the values (or to set them as default) in combination with a certain instrument.
        I like the idea most that I could "wrap" this strategy into another one and then simply put in all the params I need and thats it. But if it's not possible then I probably can't solve this problem somehow elegant :-/.

        Thanks anyways!
        Steakley

        Comment


          #5
          Hello Steakley,

          Thank you for your response.

          Unfortunately, there is no option to save multiple templates for the strategy parameters. I will have forward this to our development team as a suggestion.

          Please let me know if I may be of further assistance.

          Comment


            #6
            Hello steakley,

            Thank you for your suggestion on how we can improve our product. It has been inserted into our tracking system with the unique ID # 50.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by RideMe, 04-07-2024, 04:54 PM
            6 responses
            31 views
            0 likes
            Last Post RideMe
            by RideMe
             
            Started by tkaboris, Today, 05:13 PM
            0 responses
            2 views
            0 likes
            Last Post tkaboris  
            Started by GussJ, 03-04-2020, 03:11 PM
            16 responses
            3,281 views
            0 likes
            Last Post Leafcutter  
            Started by WHICKED, Today, 12:45 PM
            2 responses
            19 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by Tim-c, Today, 02:10 PM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X