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

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 elirion, Today, 09:32 PM
            0 responses
            3 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by cre8able, Today, 09:15 PM
            1 response
            7 views
            0 likes
            Last Post bltdavid  
            Started by cummish, Today, 08:43 PM
            0 responses
            12 views
            0 likes
            Last Post cummish
            by cummish
             
            Started by Option Whisperer, Today, 07:58 PM
            4 responses
            21 views
            0 likes
            Last Post Option Whisperer  
            Started by ETFVoyageur, 05-07-2024, 07:05 PM
            13 responses
            87 views
            0 likes
            Last Post ETFVoyageur  
            Working...
            X