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

Different instances of same strategy on same chart?

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

    Different instances of same strategy on same chart?

    Suppose I want to run 2 or 3 copies of the exact same strategy on the same chart at the same time, the only difference being that each instance of the strategy has a different profit target. First, is this possible? It looks like it is at first glance. Second, what happens if one instance receives a rejected stoploss order and shutrs down. Will it close/cancel all orders for all 2 (or 3) instances (ie every order on the chart)? Or will it close/cancel only those orders that were opened by this specific strategy instance?

    In other words, if I have 3 copies/instances of MyCustomStrategy running on the same chart, and the first copy received an order rejection error, will MyCustomStrategy automatically close just those orders opened by this copy of MyCustomStrategy, or will it close all orders for all 3 copies?

    Third question: How would this change if I opened 3 charts of the same instrument, and launched one separate copy of MyCustomStrategy on each chart?

    #2
    Hello westofpluto,

    Thanks for your post.

    When you apply an instance of your strategy, the instance is a copy of the strategy and is internally assigned a unique number and all orders of the instance of the strategy are unique to that strategy.

    When you place multiple strategies (copies or not) on the same instrument and same account the issue is that there can only be one account position for all three strategies (so long, short, or flat). When each strategy processes its orders it will maintain its own position virtually so that it can continue to execute its code according to your program. However, with only one account position, the long order from one strategy would close the short position of another strategy and this would cause the strategy to be out of sync with the account position. It can be extremely confusing when you are using more than one strategy on the same instrument and account and for this reason alone we do not recommend that process.

    If one strategy has an order rejected it would not affect the other strategies' virtual positions but it certainly would affect the account position when the strategy is disabled and positions closed.

    For your third question, it would be the same instrument and same account and the chaotic results would be the same.

    Reference: https://ninjatrader.com/support/help..._account_p.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul. I'm still a little unclear about what you are saying here. If I have 3 strategies on the same chart, and one strategy gets an order rejection that closes the strategy, does that close and cancel ALL order for that account on the chart? Or does it only close the "virtual" positions for that strategy that failed? Can you please clarify? Thanks.

      Comment


        #4
        Hello westofpluto,

        Thanks for your reply.

        If the strategy closes the account position, that closes the account position for all three strategies, keeping in mind that there can only be one account position per instrument. The remaining two strategies will continue to run and will continue to send live orders based on their own virtual position relative to their logic. Again multiple strategies on the same instrument and same account are not recommended due to the complexity of understanding which strategy should be in which position versus the account position.

        You can certainly test this, to some degree, with your sim101 account.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Paul, I'm sorry but your answer is still not clear. What exactly happens when one strategy gets an order rejection with RealtimeErrorHandling at its defaul setting (StopCancelClose)? Does this close the entire account position? Or does it only close the virtual positions created by this account?

          I'll give you an example: Let's say I run 2 strategies on the same chart. Strategy1 opens a long postion (position1) and Strateg2 also opens a long position (position2). Strategy1 tries to set a stoploss order that gets rejected. So when this happens, will Strategy1 close BOTH entries (position1 from Strategy1 and position2 from Strategy2)? Or will it close just the virtual entry for Strategy1 (ie position1)?

          If you aren't sure, could you please ask one of the other support people? Thanks.

          Comment


            #6
            Hello westofpluto,

            Thanks for your reply.

            When you apply any number of strategies to the same instrument and there is only one account, there can be only one account position. From the help guide link in post #2 are these definitions:

            An important concept to understand prior to using NinjaScript strategies in a real-time trading environment (live brokerage account, for example) is the difference between a Strategy Position and an Account Position.

            Strategy Position
            A Strategy Position is a virtual position that is created by the entry and exit executions generated by a strategy and is independent from any other running strategy’s position or an Account Position.

            Account Position
            An Account Position is the position you actually hold in a real-time trading account, whether it is a NinjaTrader internal simulation account (Sim101) or your live real-money brokerage account.


            If one of the strategies is closed, for whatever error reason, it will attempt to close any open orders of that strategy instance only and will attempt to close the current account position.

            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by pibrew, Today, 06:37 AM
            0 responses
            4 views
            0 likes
            Last Post pibrew
            by pibrew
             
            Started by rbeckmann05, Yesterday, 06:48 PM
            1 response
            14 views
            0 likes
            Last Post bltdavid  
            Started by llanqui, Today, 03:53 AM
            0 responses
            6 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            12 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            16 views
            0 likes
            Last Post AaronKoRn  
            Working...
            X