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

Two independent strategies on the same futures contract

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

    Two independent strategies on the same futures contract

    Hello,

    I want to run two different custom strategies (not ATM) on the same futures contract. I setup two different charts, each chart has it's own custom strategy.

    If first strategy goes long and second strategy goes short on the same contract, would it violate broker's policy or NT platform would take care of it for me?

    I have read that NT allows to have simultaneous long/short positions for multiple ATMs, but not sure if it works the same way for custom strategies.

    Thank you

    #2
    Hello yDiamond,

    When trading the same instrument on the same account, the performance of each trade on the Account Performance tab of the Control Center would match in the order the orders are received.

    The position for the account and the position for the strategy are separate. It is possible for the position of a strategy to be out of sync with the position of an account.

    From the help guide:
    "Note: Please be aware that these options will only help you sync your Account Position to your Strategy Position once on startup. These options will not guarantee your Account Position remains in sync afterward. Any active orders you may have had on your account prior to strategy start that was not generated by your strategy would not have been cancelled on start and can lead to your Account Position being out of sync from your Strategy Position. Placing manual trades or running multiple strategies on the same instrument can also lead to your Account Position being out of sync from your Strategy Position."

    Below are links to the NinjaTrader 7 and NinjaTrader 8 help guides on this.
    https://ninjatrader.com/support/help..._positions.htm
    https://ninjatrader.com/support/help..._account_p.htm
    https://ninjatrader.com/support/help..._positions.htm


    Using two NinjaScript Strategies that are placing orders in opposite directions would also be affected by this. The Strategy Position is separate from the Account Position. This means that if one strategy has taken a long position and is showing long 1, and the other has taken a short position and is showing short 1, the account position would be flat and neither strategy would be in sync with the account.

    Further, NinjaTrader does not support hedging.

    All links below are publicly available.

    Below is a public link to a video that demonstrates the Start Behavior for NinjaTrader 7.
    https://www.youtube.com/watch?v=US9c...A14C398CA140D7

    And a link to a video that demonstrates Start Behavior for NinjaTrader 8.
    https://drive.google.com/file/d/1nXrEz7Rw5C66xiKuuaw0qwju9LaCTeP5/view?usp=drive_link

    Showing an atm strategy with a long position on one DOM or Chart and a short position on another DOM or Chart on the same instrument and account by setting 'ATM Strategy Selection Mode' to 'Display Selected ATM Strategy Only' does not result in two separate account positions on the same instrument. In this situation the account is flat.

    However, this does allow to see the working orders, position, and performance for each active Atm instance separately. These would appear as a virtual long and short position with working stops and targets.

    Below is a public link to a video on this for NinjaTrader 7.


    And a public link to a video on this for NinjaTrader 8.


    As well as links to the help guide.
    https://ninjatrader.com/support/help...ction_mode.htm
    https://ninjatrader.com/support/help...ction_mode.htm

    If one order takes the account position long as an entry and places a stop and target with an Atm, then on a second chart a sell order is placed as an entry with an atm and this fills, the account will be flat but the Atm Strategies will work separately (with 'Display Selected ATM Strategy Only' selected). It will appear that the positions are separate as only the selected Atm is visible on that Chart or DOM, however, the account position is flat. Then the target of the first order may fill and this will take the account into a short position with the atm of the second entry remaining. Once the Atm of the second position fills the account is back to flat again.

    In the account performance the trades are matched with the entry to the entry and the exit to the exit (as this is the sequence that NinjaTrader sees as the actual trades were filled in with First In First Out).

    Instead, we visually show you the performance of this one open trade without showing the performance of other trades running different instances of Atm Strategies. Showing this is the equivalent of multiple positions (without accounting for leverage or loss).. Being long 1 and short 1 is the same as being flat. This works the same as when you call your broker on the phone. You can imagine virtual positions taken from different events and try and put the profit and loss between arbitrary orders together if you would like. But with your broker it's First In First out. Meaning any reporting in NinjaTrader is based on when we have indications of when an order was submitted, became working, and was filled.

    We have very sophisticated ways of connecting orders based on signal name to assist with creating the performance reports, but its still based on what is marked as an entry and what is marked as an exit and at what time and what what price..

    In NinjaScript we also try and match these orders based on signal name and from entry signal.

    Below are links to the help guide on the Trade Performance window for account performance.
    https://ninjatrader.com/support/help...rmance_tab.htm
    https://ninjatrader.com/support/help...erformance.htm

    And viewing the Strategy Performance window for the individual instance of the strategy's performance.
    https://ninjatrader.com/support/help...ed_strateg.htm
    https://ninjatrader.com/support/help...egies_tab2.htm
    https://ninjatrader.com/support/help...egyPerformance
    https://ninjatrader.com/support/help...egyPerformance


    To truly have an open long account position and an open short account position on the same instrument (instead of a net flat account position), this would require placing trades to two different accounts. One account to hold a long position, the other account to hold a short position.

    In NinjaTrader it is possible to create addition Sim accounts to use for practice trading this scenario, however, with NinjaTrader 7 these would require a live license key to utilize as it does require Global Simulation Mode to be disabled so that the Account drop-down is not grayed (disabled) on all trade windows.

    With NinjaTrader 8 this would not require a live license key to utilize and can be done with the Free Simulation License. NinjaTrader 8 allows for additional Sim accounts to be selected even when Global Simulation Mode is enabled.

    To add additional Sim accounts in NinjaTrader 7:
    • Disconnect from all connections
    • Ensure a Live license key is entered in Help -> License Key...
    • Click Tools -> Options... -> Simulator -> Accounts...
    • Type a new name for the new account (for example Sim102)
    • Click OK
    • Reconnect to your connection -> disable Global Simulation Mode
    • Select the new account in the Account drop-down of Chart Trader, SuperDOM, or other trade window
    http://ninjatrader.com/support/helpG...n_accounts.htm
    http://ninjatrader.com/support/helpG...ulator_tab.htm

    To add addition Sim accounts in NinjaTrader 8:
    • On the Control Center select the Accounts tab
    • Right-click the grid in the Accounts tab -> select Add Simulation Account
    • Type a name for the new account in the Name field if desired
    • Click OK
    https://ninjatrader.com/support/help...n_accounts.htm
    http://ninjatrader.com/support/helpG...TheAccountsTab

    But with all of that said, most hedging (going long and short at the same time) is based on risk and margin. Sometimes with a broker its more expensive to take short positions than long positions and you can incur larger losses. Some brokerages, such as NinjaTrader Brokerage, do not allow hedging with multiple accounts.

    But many are wanting to just keep track of what would have happened if you had taken the opposite trade at the same time. And in that case, its absolutely helpful to have multiple accounts (sim, live demo, or actual funded brokerage account).
    Last edited by NinjaTrader_ChelseaB; 09-28-2022, 04:00 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by yDiamond View Post

      If first strategy goes long and second strategy goes short on the same contract, would it violate broker's policy or NT platform would take care of it for me?
      Your short sale would not be against the box. Futures is more forgiving than stocks. Your broker would consider you flat if same number of contacts,etc.

      Comment


        #4
        I reactivate the post.
        I have a dozen strategies created with ninjascript 8. Some LONG and some SHORT.
        It is possible with a real account (real account = real live transactions) to have one account for LONG positions and one for SHORT positions. Should these accounts both refer to my checking account? If yes, how does it work?

        Comment


          #5
          Originally posted by Apo84 View Post
          I reactivate the post.
          I have a dozen strategies created with ninjascript 8. Some LONG and some SHORT.
          It is possible with a real account (real account = real live transactions) to have one account for LONG positions and one for SHORT positions. Should these accounts both refer to my checking account? If yes, how does it work?
          Yes, having two separate accounts with the same broker is the
          preferred way to trade the same instrument both long and short
          at the same time.

          Just be very very careful -- the acct you choose for long strategies
          should never open a short position -- and vice versa.

          Typically, a brokerage acct at a futures brokerage is a completely
          separate thing, with its own application process and with its own
          funds -- meaning after you open it, you need to fund it with money
          in order to trade from that account, either by sending a check or
          doing a wire transfer.

          [EDIT: If you open two accts at the same broker, the application
          process for the 2nd acct will be abbreviated, but you will (usually)
          still send two separate checks/wire transfers to fund your two
          separate accounts.]

          As far as having your brokerage account "connected" to your
          checking account, ask your broker about if and how this feature
          is supported.
          Last edited by bltdavid; 07-14-2020, 09:57 AM.

          Comment


            #6
            Hello Apo84,

            Thank you for your post.

            bltdavid is on the money here, we would suggest if you're wanting to have some strategies go long and some short on the same instrument that you use different accounts to trade those. We would encourage only using one strategy per instrument/account combination to avoid situations in which the strategy position and account position could get out of sync.

            A brokerage account would be separate from your checking account. You would need to talk to your broker about options for multiple accounts hooked to the same login as well as if they provide connectivity to your checking account.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by Apo84 View Post
              It is possible with a real account (real account = real live transactions) to have one account for LONG positions and one for SHORT positions.
              You should re-read post #2 very carefully.

              It says this,
              "To truly have an open long account position and an open short account position on the same instrument (instead of a net flat account position), this would require placing trades to two different accounts. One account to hold a long position, the other account to hold a short position."

              Comment


                #8
                Thanks for the answers.

                So in summary, with ninjatrader I can create multiple simulation accounts (for example one for long positions and one for short positions).
                To trade instead I need to ask my broker for the possibility of using two separate accounts which I will probably have to finance separately.

                It's correct?
                Thanks

                Comment


                  #9
                  Hello Apo84,

                  Thank you for your reply.

                  Yes, that is correct.

                  Please let us know if we may be of further assistance to you.
                  Kate W.NinjaTrader Customer Service

                  Comment


                    #10
                    I'm interested in trading multiple positions on the same contract as independent trades. Each with its profit target, scale outs, and stop loss and independently of the order in which the positions were taken. Is trading each position on a different account the only way to do it or is there any other way to trade multiple independent positions. Since default NT8 trade management is FIFO I can't do it right now.

                    Thank you

                    Comment


                      #11
                      Hello crmtrader,

                      Thank you for your reply.

                      Two separate accounts would be the only way to keep the positions completely independent, that is correct.

                      Please let us know if we may be of further assistance to you.
                      Kate W.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_ChelseaB View Post
                        Hello yDiamond,

                        When trading the same instrument on the same account, the performance of each trade on the Account Performance tab of the Control Center would match in the order the orders are received.

                        The position for the account and the position for the strategy are separate. It is possible for the position of a strategy to be out of sync with the position of an account.

                        From the help guide:
                        "Note: Please be aware that these options will only help you sync your Account Position to your Strategy Position once on startup. These options will not guarantee your Account Position remains in sync afterward. Any active orders you may have had on your account prior to strategy start that was not generated by your strategy would not have been cancelled on start and can lead to your Account Position being out of sync from your Strategy Position. Placing manual trades or running multiple strategies on the same instrument can also lead to your Account Position being out of sync from your Strategy Position."

                        Below are links to the NinjaTrader 7 and NinjaTrader 8 help guides on this.
                        https://ninjatrader.com/support/help..._positions.htm

                        https://ninjatrader.com/support/help..._positions.htm


                        Using two NinjaScript Strategies that are placing orders in opposite directions would also be affected by this. The Strategy Position is separate from the Account Position. This means that if one strategy has taken a long position and is showing long 1, and the other has taken a short position and is showing short 1, the account position would be flat and neither strategy would be in sync with the account.

                        Further, NinjaTrader does not support hedging.

                        All links below are publicly available.

                        Below is a public link to a video that demonstrates this for NinjaTrader 7.
                        https://www.youtube.com/watch?v=US9c...A14C398CA140D7

                        And a link to a video that demonstrates this for NinjaTrader 8.


                        Showing an atm strategy with a long position on one DOM or Chart and a short position on another DOM or Chart on the same instrument and account by setting 'ATM Strategy Selection Mode' to 'Display Selected ATM Strategy Only' does not result in two separate account positions on the same instrument. In this situation the account is flat.

                        However, this does allow to see the working orders, position, and performance for each active Atm instance separately. These would appear as a virtual long and short position with working stops and targets.

                        Below is a public link to a video on this for NinjaTrader 7.


                        And a public link to a video on this for NinjaTrader 8.


                        As well as links to the help guide.
                        https://ninjatrader.com/support/help...ction_mode.htm


                        If one order takes the account position long as an entry and places a stop and target with an Atm, then on a second chart a sell order is placed as an entry with an atm and this fills, the account will be flat but the Atm Strategies will work separately (with 'Display Selected ATM Strategy Only' selected). It will appear that the positions are separate as only the selected Atm is visible on that Chart or DOM, however, the account position is flat. Then the target of the first order may fill and this will take the account into a short position with the atm of the second entry remaining. Once the Atm of the second position fills the account is back to flat again.

                        In the account performance the trades are matched with the entry to the entry and the exit to the exit (as this is the sequence that NinjaTrader sees as the actual trades were filled in with First In First Out).

                        Instead, we visually show you the performance of this one open trade without showing the performance of other trades running different instances of Atm Strategies. Showing this is the equivalent of multiple positions (without accounting for leverage or loss).. Being long 1 and short 1 is the same as being flat. This works the same as when you call your broker on the phone. You can imagine virtual positions taken from different events and try and put the profit and loss between arbitrary orders together if you would like. But with your broker it's First In First out. Meaning any reporting in NinjaTrader is based on when we have indications of when an order was submitted, became working, and was filled.

                        We have very sophisticated ways of connecting orders based on signal name to assist with creating the performance reports, but its still based on what is marked as an entry and what is marked as an exit and at what time and what what price..

                        In NinjaScript we also try and match these orders based on signal name and from entry signal.

                        Below are links to the help guide on the Trade Performance window for account performance.
                        https://ninjatrader.com/support/help...rmance_tab.htm
                        https://ninjatrader.com/support/help...erformance.htm

                        And viewing the Strategy Performance window for the individual instance of the strategy's performance.
                        https://ninjatrader.com/support/help...ed_strateg.htm
                        https://ninjatrader.com/support/help...egies_tab2.htm
                        https://ninjatrader.com/support/help...egyPerformance
                        https://ninjatrader.com/support/help...egyPerformance


                        To truly have an open long account position and an open short account position on the same instrument (instead of a net flat account position), this would require placing trades to two different accounts. One account to hold a long position, the other account to hold a short position.

                        In NinjaTrader it is possible to create addition Sim accounts to use for practice trading this scenario, however, with NinjaTrader 7 these would require a live license key to utilize as it does require Global Simulation Mode to be disabled so that the Account drop-down is not grayed (disabled) on all trade windows.

                        With NinjaTrader 8 this would not require a live license key to utilize and can be done with the Free Simulation License. NinjaTrader 8 allows for additional Sim accounts to be selected even when Global Simulation Mode is enabled.

                        To add additional Sim accounts in NinjaTrader 7:
                        • Disconnect from all connections
                        • Ensure a Live license key is entered in Help -> License Key...
                        • Click Tools -> Options... -> Simulator -> Accounts...
                        • Type a new name for the new account (for example Sim102)
                        • Click OK
                        • Reconnect to your connection -> disable Global Simulation Mode
                        • Select the new account in the Account drop-down of Chart Trader, SuperDOM, or other trade window
                        http://ninjatrader.com/support/helpG...n_accounts.htm
                        http://ninjatrader.com/support/helpG...ulator_tab.htm

                        To add addition Sim accounts in NinjaTrader 8:
                        • On the Control Center select the Accounts tab
                        • Right-click the grid in the Accounts tab -> select Add Simulation Account
                        • Type a name for the new account in the Name field if desired
                        • Click OK
                        https://ninjatrader.com/support/help...n_accounts.htm
                        http://ninjatrader.com/support/helpG...TheAccountsTab

                        But with all of that said, most hedging (going long and short at the same time) is based on risk and margin. Sometimes with a broker its more expensive to take short positions than long positions and you can incur larger losses. Some brokerages, such as NinjaTrader Brokerage, do not allow hedging with multiple accounts.

                        But many are wanting to just keep track of what would have happened if you had taken the opposite trade at the same time. And in that case, its absolutely helpful to have multiple accounts (sim, live demo, or actual funded brokerage account).
                        Hi Chelsea,
                        I am running a strategy on different instruments (a unique chart for each) on the same account. How can I control the Daily Loss/Profit for the Account the strategies are running on?

                        For example, let's assume I have 2 charts, one for each instrument: RTY, CL. Both run the same strategy on the same APEX account. I want to limit the Account's Daily Loss to $300. Say RTY lost $200 and CL lost $150. How can code into my ninjascript strategy that it need to stop trading on both charts?

                        Thanks,

                        Bobperez

                        Comment


                          #13
                          Originally posted by bobperez View Post

                          Hi Chelsea,
                          I am running a strategy on different instruments (a unique chart for each) on the same account. How can I control the Daily Loss/Profit for the Account the strategies are running on?

                          For example, let's assume I have 2 charts, one for each instrument: RTY, CL. Both run the same strategy on the same APEX account. I want to limit the Account's Daily Loss to $300. Say RTY lost $200 and CL lost $150. How can code into my ninjascript strategy that it need to stop trading on both charts?

                          Thanks,

                          Bobperez
                          Hello Bobperez,

                          Thank you for your inquiry.

                          If you would like information about the account's profit and loss information, you could consider adding the OnAccountItemUpdate() method to your strategy logic. This would allow you to get AccountItem information from the account the strategy instances are running on. They could check, and if an item such as GrossRealizedProfitLoss hits a certain value, you could call CloseStrategy() to full stop and disable the strategy. Otherwise, if you don't want the strategy to be disabled, you could try something like a bool that allows for trading, then when the GrossRealizedProfitLoss hits a certain value you could toggle that bool so trades are not submitted anymore.

                          For more information, please see the following pages:Please feel free to reach out with any additional questions or concerns.
                          Emily C.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_Emily View Post

                            Hello Bobperez,

                            Thank you for your inquiry.

                            If you would like information about the account's profit and loss information, you could consider adding the OnAccountItemUpdate() method to your strategy logic. This would allow you to get AccountItem information from the account the strategy instances are running on. They could check, and if an item such as GrossRealizedProfitLoss hits a certain value, you could call CloseStrategy() to full stop and disable the strategy. Otherwise, if you don't want the strategy to be disabled, you could try something like a bool that allows for trading, then when the GrossRealizedProfitLoss hits a certain value you could toggle that bool so trades are not submitted anymore.

                            For more information, please see the following pages:Please feel free to reach out with any additional questions or concerns.
                            Ok, I'll try that. Thank you! If you have an example, please include the link here.

                            BobPerez
                            Last edited by bobperez; 07-17-2023, 11:17 AM.

                            Comment


                              #15
                              Emily,

                              How can I provide the user with one Parameters window to define the account limits only once and not on each strategy instance?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by morrnel, 05-12-2024, 06:07 PM
                              10 responses
                              185 views
                              1 like
                              Last Post SnailHorn  
                              Started by SherwoodJP, 06-04-2024, 06:55 AM
                              4 responses
                              45 views
                              0 likes
                              Last Post SherwoodJP  
                              Started by dibDab, 11-09-2022, 09:04 AM
                              13 responses
                              122 views
                              0 likes
                              Last Post MisterTee  
                              Started by LordNoah, Today, 06:15 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post LordNoah  
                              Started by oneybuchi2, Today, 03:48 PM
                              2 responses
                              23 views
                              0 likes
                              Last Post oneybuchi2  
                              Working...
                              X