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

Multiple Strategies on the same ticker/instrument

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

    Multiple Strategies on the same ticker/instrument

    Hello, I use ninjatrader for automated equities trading with my TDA account. I am trying to figure out what is the best way to run multiple strategies on a single instrument such as SPY. So for example let use assume I have a trend strategy and a mean reversion strategy and I would like to have both strategies running on SPY. I do not want to combine the logic of both strategies as I also run them on different tickers as well. I also do not want to create a different account as that is not feasible for the amount of strategies I run. I do not care that the strategies are in sync with my account position and should work independently of one another. Considering you can only have 1 active strategy with IsAdoptAccountPositionAware, what would be the best way to run these strategies. I do not want to wait until flat and I dont want to submit any historical orders in the queue. I just want to activate each strategy and have it enter/exit based on the rules of the respective strategy without it effecting the other strategy or my existing account position for that ticker. Hope my question makes sense...Thank you in advance for any support.


    #2
    Originally posted by proptradingshop View Post
    I do not care that the strategies are in sync with my account position
    This will cause you problems.

    -- Assuming the same account ---

    Strat #1 enters SPY via BUY 100 (AcctPos is LONG 100)
    Strat #2 enters SPY via SELL 100 (AcctPos is FLAT)
    ...
    ... time passes, each strategy manages their own
    ... position, oblivious to all other running strategies
    ...
    Strat #1 exits SPY via SELL 100 (AcctPos is SHORT 100)
    Strat #2 exits SPY via BUY 100 (AcctPos is FLAT)

    You really think the amount of profit made (or lost)
    by Strat #1 and #2 will be accurately reflected
    in your real live account?

    Maintaining that accuracy is precisely what 'keeping
    your strategies in sync with your account position'
    means.

    Could you explain your reasons why you would choose
    to not care about that?

    If choose to do this anyways, each strategy's
    performance will be a lie -- your real account
    will most likely not reflect what the combined
    strategy performances say it should.


    Comment


      #3
      And that's just two strategies!

      And you want advice on running multiple
      strategies on the same instrument in the
      same account?

      The results will be unpredictable.
      Your strategy performance will be unreliable.
      Your real world PnL will be hard to follow.
      You'll lose faith in your strategies.

      The best advice is don't do it.

      But if you insist on trying ... good luck!


      Comment


        #4
        Originally posted by bltdavid View Post
        The best advice is don't do it.
        I mean, don't do it in one account.

        Don't allow one or more strategies to run
        in the same account where by LONG and
        SHORT positions could be entered for the
        same instrument at the same time.

        -=o=-

        Is there an relatively easy way around that?

        Yes, if you restrict all running strategy
        instances to only take LONG positions,
        or just SHORT positions, then you'll be
        fine.

        So, to do this right, you would only need
        two separate accounts, one account is
        dedicated to LONG positions, and the
        other account is dedicated to SHORT
        positions.

        Then let 'em rip ... and you'll be safe,
        and each strategy's performance will
        be reliable.

        My point is:
        The best advice is to use two accounts.


        Comment


          #5
          bltdavid I do not understand your intentions in spamming this post with unsolicited advice. I have been running these strategies for close to a decade on a separate platform with no issues and expected results. Some instruments I trade have over a dozen strategies running on them simultaneously. Think of different strategies that have filters for different market regimes and different time frames can have different market structures so they are traded accordingly. I appreciate your concern with my PnL but I am not looking for advice on whether my approach is to your liking. I am looking for guidance on how to setup a similar structure within NT. The examples you gave are my exact expected behavior and I expect my account position to not be in sync with the strategies position. How can I start multiple strategies on the same instrument without trying to have the strategies sync account position?
          Last edited by proptradingshop; 03-07-2024, 08:08 AM.

          Comment


            #6
            Hello proptradingshop,

            While you cannot prevent the strategies start behavior beng run you can add a condition to prevent the strategies from trading historically to avoid it entering into any trades before realtime. You could combine that with Immediately submit which assumes both the account and strategy position are where you want them before it starts.

            Code:
            if(State == State.Historical) return;
            Another approach would be to not use strategies and use indicators instead. Using the addon framework you can submit orders and monitor order events/account values. That would remove the strategy specific behaviors and let you work with the account directly. The downside to doing that is those would not be backtestable and you would also lose the isolated performance information that strategies have.




            JesseNinjaTrader Customer Service

            Comment


              #7
              NinjaTrader_Jesse Thank you for the suggestions, this is exactly what I was looking for. Appreciate the support.

              Comment


                #8
                NinjaTrader_Jesse One other related question I have is how can I make it so exit on session close only closes strategy position and not full account position?

                Comment


                  #9
                  Hello proptradingshop,

                  The strategies exit on session close should only exit positions that the individual strategy has, if you are seeing something else happening I would likely suggest to disable that feature and use time conditions instead. A time condition can be used to restrict entries to certain times of day, the same can be done to exit the strategies individual position after a certain time of day. There is a sample of limiting a window of time here: https://ninjatrader.com/support/help...ightsub=totime

                  You can also find a sample of creating a custom exit on session close logic in the unmanaged sample here: https://forum.ninjatrader.com/forum/...elp#post770579



                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    NinjaTrader_Jesse So today one of my strategies with exit on session close marked true took on an equity position of 5L when I already had 300L. At the end of the session it closed all 305 instead of the 5L that was entered by the strategy...is this not expected behavior?

                    Comment


                      #11
                      Hello proptradingshop,

                      Without knowing the strategies virtual position at that time it would be hard to say why that may have happened if you have more than 1 strategy running. For your described use case and because that goes beyond how strategies are intended to operate I would suggest to avoid the strategy based features like ExitOnClose and instead use your own logic to control exiting. That would allow you to target the individual virtual position using its Position object and quantity.
                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        NinjaTrader_Jesse I only had 1 strategy running on the instrument. It was set to adopt account position...I am assuming this is the cause correct?

                        Comment


                          #13
                          Hello proptradingshop,

                          Yes in that case it would have been managing the entire accounts position so it should have closed the whole position in addition to the other amount that it had placed its self.
                          JesseNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Balage0922, Today, 07:38 AM
                          0 responses
                          5 views
                          0 likes
                          Last Post Balage0922  
                          Started by JoMoon2024, Today, 06:56 AM
                          0 responses
                          6 views
                          0 likes
                          Last Post JoMoon2024  
                          Started by Haiasi, 04-25-2024, 06:53 PM
                          2 responses
                          19 views
                          0 likes
                          Last Post Massinisa  
                          Started by Creamers, Today, 05:32 AM
                          0 responses
                          6 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  
                          Working...
                          X