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

How to submit an order for a specific account

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

    How to submit an order for a specific account

    In the strategy I can use EnterLong or EnterShort method to place an order for the active account associated with the strategy. On the event OnExecutionUpdate, I place another order for a different account with code anotherAccount.CreateOrder(), then anotherAccount.Submit(). However, that code does not work as expected. NinjaTrader shows up popup message "Sim101, Order 'xxx' can't be submitted. Exceeds instruments maximum position quantity...". The Orders tab also shows those orders are rejected.

    This is how I want to write my copy trade code. OnExecutionUpdate event of a strategy will create a same order for another account. But it does not work. Is there a way to execute an order for any specific account, not the active account?

    Thank you!
    Last edited by excelxp; 02-09-2022, 10:52 PM.

    #2
    A strategy is associated with a single account, chosen when
    the strategy is started.

    If you want to submit orders for two different accounts, start
    the strategy in both accounts, or use a trade copier.

    Comment


      #3
      Thank you for your answer. It is not what I want to do as I am writing a trade copier by myself, not want to use any trader copier plugin. My trade copier does not copy orders but to copy executions which are completed orders, not ongoing orders.

      If there is code to execute an order for any account within a strategy, it would be help. My code inside OnExecutionEvent event does not work when I use anotherAccount.CreateOrder(), then anotherAccount.Submit()

      Comment


        #4
        Maybe don't use a Strategy, have you tried either an Indicator or an Addon?

        Comment


          #5
          Hello excelxp,

          In general for what you are asking it would suggested to use a indicator or addon which is account neutral, then you would add all the accounts you wanted to use in code. You could use the addon framework within a strategy however in that context you would have to develop two separate sets of logic, one for the strategy side using strategy methods/properties/events and one for the addon side.


          JesseNinjaTrader Customer Service

          Comment


            #6
            Hi Jesse, your solution sounds good for me. I will separate two sets of logic.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Waxavi, 04-19-2024, 02:10 AM
            2 responses
            36 views
            0 likes
            Last Post poeds
            by poeds
             
            Started by chbruno, Yesterday, 04:10 PM
            1 response
            43 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by Max238, Today, 01:28 AM
            1 response
            23 views
            0 likes
            Last Post CactusMan  
            Started by giulyko00, Yesterday, 12:03 PM
            2 responses
            10 views
            0 likes
            Last Post giulyko00  
            Started by r68cervera, Today, 05:29 AM
            0 responses
            4 views
            0 likes
            Last Post r68cervera  
            Working...
            X