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

It is possible to place duplicate orders for different accounts

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

    It is possible to place duplicate orders for different accounts

    Hi everybody! I would like to know if I can operate for two accounts at the same time with duplicated orders. I have a proprietary trade firm account and I wanted to trade simultaneously from the proprietary trade firm account and my personal account, with identical orders at the same time, replicated.

    #2
    Welcome to the forums!

    If you are proficient with C# and NinjaScript, you can certainly
    build an AddOn to do this.

    You can also try using a third-party 'trade copier', like this one.
    Last edited by bltdavid; 10-16-2020, 03:55 PM.

    Comment


      #3
      Thanks a lot, David!

      Comment


        #4
        Hello jorgeaug,

        Welcome to the forums and thank you for your post.

        I understand that you would like to submit an order to one account and have the same order submitted on a second account.

        Account-level OrderUpdate events could be used to pick up orders from one account and submit orders to another account. To accomplish this, you would need to create a script that subscribes to account-level OrderUpdate events to monitor orders sent to the first account. Then, in OnOrderUpdate you could check if an order is filled and if the order is long or short. If the order IsLong, then you can use Account.CreateOrder() to create a buy order followed by calling Account.Submit to submit that order to the second account. If the order IsShort, you could use Account.CreateOrder() to create a sell order followed by calling Account.Submit to submit that order to the second account.

        Please see the attached example script that demonstrates how this is accomplished.

        Also, please see the following help guides linked below for more information.

        OrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

        CreateOrder - https://ninjatrader.com/support/help...tegycreate.htm

        Let us know if we may further assist.
        Attached Files
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_BrandonH View Post
          Hello jorgeaug,

          Welcome to the forums and thank you for your post.

          I understand that you would like to submit an order to one account and have the same order submitted on a second account.

          Account-level OrderUpdate events could be used to pick up orders from one account and submit orders to another account. To accomplish this, you would need to create a script that subscribes to account-level OrderUpdate events to monitor orders sent to the first account. Then, in OnOrderUpdate you could check if an order is filled and if the order is long or short. If the order IsLong, then you can use Account.CreateOrder() to create a buy order followed by calling Account.Submit to submit that order to the second account. If the order IsShort, you could use Account.CreateOrder() to create a sell order followed by calling Account.Submit to submit that order to the second account.

          Please see the attached example script that demonstrates how this is accomplished.

          Also, please see the following help guides linked below for more information.

          OrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

          CreateOrder - https://ninjatrader.com/support/help...tegycreate.htm

          Let us know if we may further assist.

          hello
          thank you for the script
          i have 1 question

          the script will submit and sell order if i click on buy and also the more the more i use the script the more order this will buy for example the first time will buy 1 and sell 2 and the second time will buy 1 and sell 6 or more .

          so my question is do you know what part of the script i need to fix to make this go long or short on both the account with the same amount of contract or the same atm

          Comment


            #6
            Hello jhontorres,

            Thank you for your note.

            You may modify the OnOrderUpdate section of the previously attached example script to submit long or short orders to the second account. Currently, OnOrderUpdate checks if the position is long on account one and submits a long order on the second account for the same quantity. Also, it checks if the position of account one is short and submits a sell order to the second account for the same quantity.

            When submitting a buy order on the first account, are you seeing a sell order placed on the second account?

            Please see the video linked below which demonstrates testing the CheckOrderAcc1SubmitOrderAcc2Mod example script. When submitting a buy order to the first account, a buy order is placed for the same quantity on the second account. When placing a sell order on the first account, a sell order for the same quantity is placed on the second account.



            Also, here is a help guide page about OnOrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

            Please let us know if we may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_BrandonH View Post
              Hello jhontorres,

              Thank you for your note.

              You may modify the OnOrderUpdate section of the previously attached example script to submit long or short orders to the second account. Currently, OnOrderUpdate checks if the position is long on account one and submits a long order on the second account for the same quantity. Also, it checks if the position of account one is short and submits a sell order to the second account for the same quantity.

              When submitting a buy order on the first account, are you seeing a sell order placed on the second account?

              Please see the video linked below which demonstrates testing the CheckOrderAcc1SubmitOrderAcc2Mod example script. When submitting a buy order to the first account, a buy order is placed for the same quantity on the second account. When placing a sell order on the first account, a sell order for the same quantity is placed on the second account.



              Also, here is a help guide page about OnOrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

              Please let us know if we may assist further.
              notice that the issue only show when i use a template

              Comment


                #8
                Hello jhontorres,

                Thank you for your note.

                The original example gives a rough outline and does not support ATM strategies. This would be possible, but you would have to ensure that you are starting a new ATM strategy for the second account with StartAtmStartegy, and the order name for the entry order must match "Entry".

                Please also note that cases for "Exit" and "Close" would need to be handled in your AddOn. The attached example can give some further direction for handling that, but this example is meant to be educational, not to be a drop-in replacement that is fully functional under all cases.

                Here is a help guide link for more information about StartATMStrategy - https://ninjatrader.com/support/help...tmstrategy.htm

                Also, here is a help guide link for more information about CloseStrategy - https://ninjatrader.com/support/help...sestrategy.htm

                Let us know if we may assist further.
                Attached Files
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_BrandonH View Post
                  Hello jhontorres,

                  Thank you for your note.

                  The original example gives a rough outline and does not support ATM strategies. This would be possible, but you would have to ensure that you are starting a new ATM strategy for the second account with StartAtmStartegy, and the order name for the entry order must match "Entry".

                  Please also note that cases for "Exit" and "Close" would need to be handled in your AddOn. The attached example can give some further direction for handling that, but this example is meant to be educational, not to be a drop-in replacement that is fully functional under all cases.

                  Here is a help guide link for more information about StartATMStrategy - https://ninjatrader.com/support/help...tmstrategy.htm

                  Also, here is a help guide link for more information about CloseStrategy - https://ninjatrader.com/support/help...sestrategy.htm

                  Let us know if we may assist further.
                  okay thank you
                  i will work on making on making this a addon now
                  thank you for the help

                  Comment


                    #10
                    Originally posted by NinjaTrader_BrandonH View Post
                    Hello jorgeaug,

                    Welcome to the forums and thank you for your post.

                    I understand that you would like to submit an order to one account and have the same order submitted on a second account.

                    Account-level OrderUpdate events could be used to pick up orders from one account and submit orders to another account. To accomplish this, you would need to create a script that subscribes to account-level OrderUpdate events to monitor orders sent to the first account. Then, in OnOrderUpdate you could check if an order is filled and if the order is long or short. If the order IsLong, then you can use Account.CreateOrder() to create a buy order followed by calling Account.Submit to submit that order to the second account. If the order IsShort, you could use Account.CreateOrder() to create a sell order followed by calling Account.Submit to submit that order to the second account.

                    Please see the attached example script that demonstrates how this is accomplished.

                    Also, please see the following help guides linked below for more information.

                    OrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

                    CreateOrder - https://ninjatrader.com/support/help...tegycreate.htm

                    Let us know if we may further assist.
                    Hello,
                    This skript and the later video is currently what I am looking for, thanks for that!
                    But I do have a question: How are the Orders managed after their creation? I have a Strategy that attaches TakeProfit and StopLoss Properties to my Orders, does the skript Close all open Positions when the MainAccount does?

                    Comment


                      #11
                      Hello Foxmark,

                      Thank you for your post.

                      Orders are managed in the Account update event. Please note that there is no managed approach for handling orders when using AddOn Framework.

                      Please see this help guide link for more information - https://ninjatrader.com/support/help...ount_class.htm

                      My example script from this post does not demonstrate propagating close orders and is a simple example to demonstrate how an order would be detected and then using logic, submit an order to another account.

                      Your script could use custom logic to detect an order submitted with the close button and then submit an order to close positions on another account.

                      Please let us know if we may assist further.
                      Brandon H.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_BrandonH View Post
                        Hello jorgeaug,

                        Welcome to the forums and thank you for your post.

                        I understand that you would like to submit an order to one account and have the same order submitted on a second account.

                        Account-level OrderUpdate events could be used to pick up orders from one account and submit orders to another account. To accomplish this, you would need to create a script that subscribes to account-level OrderUpdate events to monitor orders sent to the first account. Then, in OnOrderUpdate you could check if an order is filled and if the order is long or short. If the order IsLong, then you can use Account.CreateOrder() to create a buy order followed by calling Account.Submit to submit that order to the second account. If the order IsShort, you could use Account.CreateOrder() to create a sell order followed by calling Account.Submit to submit that order to the second account.

                        Please see the attached example script that demonstrates how this is accomplished.

                        Also, please see the following help guides linked below for more information.

                        OrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

                        CreateOrder - https://ninjatrader.com/support/help...tegycreate.htm

                        Let us know if we may further assist.


                        Hello BrandonH

                        First of all, thank you for the script

                        Well, watching the video you uploaded (https://www.screencast.com/t/jbbL2vvlVZJW) I see the script (CheckOrderOnAcc1SubmitOrderToAcc2.zip) instantly copy the trade placed in an account into a second account, what it is a very good feature.

                        And the situation I have is how I could do this copying process you show in the video but between 2 different PCs that sometimes are in the same local network but also a good part of the time the 2 PCs are in 2 separate places with 2 separate networks?

                        For example, when you have 1 main PC at the office with a NT8 connection X, and you also have another secondary backup PC at home with a NT8 connection Y. Both PCs with different Brokers and maybe with the same datafeed provider but maybe no, but both computers normally in 2 different places.

                        This would be a good and useful built-in feature for the script here to cover those others scenarios where the 2 accounts could be in different computers and also could be in different places (not the same local network).


                        Thank you!

                        Comment


                          #13
                          Hello futurenow,

                          Thanks for your note.

                          If the PCs are on the same network then PC 1 could listen to Order update events in OnOrderUpdate() for orders that are in OrderState.Submitted and then write an OIF file on PC 2's incoming folder.

                          If the PCs are on separate networks then this would be best done through a VPN, however, this would go outside the scope of support we would be able to provide.

                          Let us know if we may further assist.
                          Brandon H.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_BrandonH View Post
                            If the PCs are on the same network then PC 1 could listen to Order update events in OnOrderUpdate() for orders that are in OrderState.Submitted and then write an OIF file on PC 2's incoming folder.
                            Thank you for your response

                            Could you please add this feature you describe to the more updated script? And in that way to be able to replicate the orders in the 2 computers that are in the same network. Just for test I just tried with the 2 scripts attached in this thread and I can't see the accounts from the other computer, and suppose this happens because it is needed what you describe above.


                            Please just to clarify, when I mean the 2 computers are in the same network, I mean both are connected to the same internet modem/router (the one for "home" that provide the telecom company). But there is not any special network configuration in the PCs other than one is connected by Ethernet cable and the other to the Wi-Fi, both to the same router.



                            Oh, one important detail I just noticed is that when you have opened 2-or-more orders in the Sim101 side that were instantly replicated in the Sim102 side, then when you click on Close button on the Sim101 side what happens is that only 1 order is closed in the Sim102 side and the rest of orders keep opened in the Sim102 side. I understand this can be done by entering the opposite order in the Sim102 side, but this feature about the Close button operation replicates the same in both sides could be crucial when you need to close everything in a quick way, because when you have just 1 extra account, the yes, it can be done in a relatively fast way (or maybe not), but if you have maybe 4 accounts and you need to close everything at the moment, then this could be a critical point.



                            Thank you in advance, I need this exact function for NT8 and now I just only need it be able to work in 2 computers in the same network to use this useful tool. Thank you!



                            Comment


                              #15
                              Hello futurenow,

                              Thanks for your note.

                              Unfortunately, I do not have multiple PCs in order to test this type of feature implementation. Also, the previously attached script is intended to be a simple example demonstrating how Account-level OrderUpdate events could be used to pick up orders from one account and submit orders to another account. Note that in the support department at NinjaTrader, it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services in our support. This is so that we can maintain a high level of service for all of our clients as well as our partners.

                              That said, you would need to log into Account A from PC 1, then you would need to log into Account B from PC 2. You would then modify the script so that PC 1 listens to Account-level OrderUpdate events for orders that are in OrderState.Submitted. You would then use a StreamWriter to write an OIF file to PC 2's Documents/NinjaTrader 8/incoming folder. Note that PC 2 would need to have the AT Interface enabled in order to use OIFs. You can enable the AT Interface under the Automated trading interface category from the Options menu (Tools > Options).

                              See the help guide documentation below for more information.

                              OrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm
                              SampleStreamWriter: https://ninjatrader.com/support/help...o_write_to.htm
                              OIFs: https://ninjatrader.com/support/help..._files_oif.htm

                              In regard to the behavior of clicking the Close button when multiple orders are placed, this is because the order quantity being submitted is set to 1. Instead, the order fill quantity would need to be used for the order quantity. I have attached a modified version of the strategy which demonstrates this fix. I have also replaced the script attached in post #4 with this modified version.

                              Let us know if we may assist further.
                              Attached Files
                              Brandon H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ScottWalsh, Today, 04:29 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by rtwave, 04-12-2024, 09:30 AM
                              2 responses
                              21 views
                              0 likes
                              Last Post rtwave
                              by rtwave
                               
                              Started by tsantospinto, 04-12-2024, 07:04 PM
                              5 responses
                              69 views
                              0 likes
                              Last Post tsantospinto  
                              Started by cre8able, Today, 03:20 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post cre8able  
                              Started by Fran888, 02-16-2024, 10:48 AM
                              3 responses
                              49 views
                              0 likes
                              Last Post Sam2515
                              by Sam2515
                               
                              Working...
                              X