Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to access multiple accounts in strategy?

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

    How to access multiple accounts in strategy?

    Hi,

    I want to create a strategy that enter order on two different accounts. How do I access / specify those two accounts in the code?

    For example, I want to buy on one account, and if certain condition is met, sell on the other account.

    Thank you.

    #2
    Originally posted by mrgreentrading View Post
    Hi,

    I want to create a strategy that enter order on two different accounts. How do I access / specify those two accounts in the code?

    For example, I want to buy on one account, and if certain condition is met, sell on the other account.

    Thank you.
    You would need to run 2 strategies and have each one linked to the seperate account or you need to use a copy trader.

    Comment


      #3
      In the case of what you suggest, how do you communicate between two strategies?

      I'm still curious if I can access to multiple accounts from the same strategy, hopefully will hear from a support staff on that.

      Comment


        #4
        You need to do this through an AddOn that can subscribe to multiple accounts. etc.

        Comment


          #5
          Hi Wessel,

          What is the AddOn? Is it something I have to purchase? Do you have any code example? Thanks.

          Comment


            #6
            Originally posted by mrgreentrading View Post
            Hi Wessel,

            What is the AddOn? Is it something I have to purchase? Do you have any code example? Thanks.
            Basically what I mentioned in regards to a "copy trader"
            example: https://ninjatraderecosystem.com/use...-trade-copier/

            Comment


              #7
              Yes, but I want to be able to do that in code, not using some other people final product, since I can't modify it or tweak it how I want. They are able to do it, so must be a way to do it in code, I just need an example.

              Comment


                #8
                You should be able to download that trade copier and view the code they used. Shouldn't you? The only code that I am unable to view would be indicator/ strategies outside of the ninjatrader ecosystem. I could be wrong though.

                Comment


                  #9
                  Hello mrgreentrading,

                  Thank you for your post.

                  A strategy can only trade on one account, so you would need to use the add-on approach to trade with multiple accounts by submitting the orders directly to the account.

                  The Add-on/Account class page of our Help Guide has an example that shows how to find an account (Sim101) and subscribe to it:To place an order to an account, you would use Account.CreateOrder to create an order and Account.Submit to submit it:The NinjaScript that mw_futures linked to is also an example of how to assign accounts and subscribe to them. If you wish to view the code, you may import the add-on, open the NinjaScript Editor, and find the indicator or add-on in the NinjaScript Explorer on the right side of the editor.
                  • Control Center>New>NinjaScript Editor> NinjaScript Explorer
                  Here is a basic guideline on how to import NinjaScript add-ons in NinjaTrader:
                  1. Download the NinjaScripts to your desktop, and keep them in the compressed .zip file.
                  2. From the Control Center window, click Tools > Import > NinjaScript Add-on...
                  3. Select the downloaded .zip file
                  4. NinjaTrader will then confirm if the import has been successful.
                  Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc., and ask if you want to replace them, Always select 'No'.

                  Once installed, you may add the indicator to a chart by right-clicking in your Chart > Indicators > and double-clicking the Indicator from the 'Available' list on the left.

                  Here is a short video demonstration of the import process - How to Install a 3rd Party Indicator or App

                  The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

                  Please let me know if I may be of any further assistance.​

                  Comment


                    #10
                    Hi NinjaTrader_Eduardo,

                    Thank you for the pointer. I coded it up but I need to wait for the market to go live again to test. I do have some questions:

                    - I want to use an ATM strat when I submit the order. I follow the example and created something like this:

                    Code:
                    if (longAccount != null)
                    {
                         Order longOrder;
                         longOrder = longAccount.CreateOrder(Bars.Instrument, OrderAction.Buy, OrderType.Market, OrderEntry.Automated, TimeInForce.Day, 1, 0, 0, "HedgeBuy", "Entry", DateTime.Now, null);
                         NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(ATMStratName, longOrder);
                    }
                                    
                    if (shortAccount != null)
                    {
                         Order shortOrder;
                         shortOrder = shortAccount.CreateOrder(Bars.Instrument, OrderAction.Sell, OrderType.Market, OrderEntry.Automated, TimeInForce.Day, 1, 0, 0, "HedgeSell", "Entry", DateTime.Now, null);
                         NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(ATMStratName, shortOrder);
                    }​
                    My question is: would the code above work? I feel like it would only start the ATM strat on the account that the strat is running right?

                    If that is the case, I would have to create / submit manual type of order, so I can create profit target and stop loss. How do I go about that? Just listen to order update and submit profit / stop loss orders on each account?

                    Thanks.
                    Last edited by mrgreentrading; 04-27-2025, 01:51 AM.

                    Comment


                      #11
                      Hello mrgreentrading,

                      Thank you for your reply.

                      In the code you provided, I see that CreateOrder method is being used with longAccount and shortAccount. The code would submit the entry order to the account used in CreateOrder.

                      If you wish to submit ATM strategies to multiple accounts, you would use CreateOrder to create an entry order with each account, then use the order as an argument in StartAtmStrategy.

                      StartAtmStrategy()

                      With StartAtmStrategy, you are submitting entry orders with ATM Strategies (templates). These would be the same ATM Strategy templates that you see in the ATM Strategy selector, and these templates are where the profit target and stop loss orders are defined.

                      Please let me know if I may be of any further assistance.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by NullPointStrategies, Today, 05:17 AM
                      0 responses
                      50 views
                      0 likes
                      Last Post NullPointStrategies  
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      126 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      69 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      42 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      46 views
                      0 likes
                      Last Post TheRealMorford  
                      Working...
                      X