Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Compose strategies

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

    Compose strategies

    Hi all,

    I have a few strategies, each based on a different indicator. The logic is simple: whenever the underlying indicator signals "short" or "long", the strategy enters the market. Trade management is done by the strategy afterwards.

    I want to create an additional strategy, which would combine all these indicators. I.e. whenever any of the indicators signals "short" or "long", the strategy would enter the market and manage the trade (PT and SL).

    Is this even possible given the current architecture? First of all, I do not know how to assign data to the "sub-strategies" (i.e. the Input IDataSeries). Also I need to know how to ensure that "OnBarUpdate" is being called (since it is a protected method) - but I hope this would be solved once the sub-strategy would get a reference to the processed data series (similarly to how indicators handle this).

    I am not asking about the intercommunication of the strategies; this I hope I can handle. However I am unable to execute synchronously a strategy from another strategy.

    Any help would be much appreciated!

    Best regards.

    #2
    Hi Goshewan,

    Thanks for the post and welcome to the NT forums! Yes, NinjaScript is built with C# so you can use standard programming conventions, like OR operator ||. Your indicators need to return a value you could check for your entry conditions.

    OnBarUpdate() is a required handler in all strategies and indicators. It's raised whenever there is a bar update. The timing of this event can be controlled with CalculateOnBarClose setting. When set to false, it's raised on every incoming tick. When set to true, it's raised only on bar close.

    You can learn more about basic C# syntax to help with II operator here:


    An overview of the strategy development process is available here:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan M,

      thanks for the reply. I might have made it clearer that I have already several implemented strategies in the NinjaScript and I need to learn how to use a strategy from within another strategy (in the meaning of the type of the object). I am quite familiar with C# with several years of experience.

      Basically I want to instantiate few custom strategies within my new "ComplexStrategy" and somehow ensure that they will be notified when the OnBarUpdate occurs (and subsequently do their computing). The resulting actions are not of the concern right now.

      Thanks!

      Comment


        #4
        Strategies cannot call other strategies. You need to have exposed values from your indicators and can then integrate this into one strategy.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Is there no way of doing that? It would reduce the code duplication significantly, not mentioning the maintenance.

          Comment


            #6
            Right - there's no way for a strategy to call another strategy. We appreciate the feedback and I will forward your comments and suggestions to our development team.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            663 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            376 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            110 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            575 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            580 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X