Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I find the orders belonging to an open position?

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

    How do I find the orders belonging to an open position?

    1 position can be created by multiple orders (add to position).
    1 order can have multiple executions (in case of partial fills).
    An execution has a direct link to one order that generated it.
    But how do I find the orders belonging to an open position?

    #2
    Hello wjadevries,

    If you are using the addon account you could reference the Orders collection to find any Order objects:



    You would need to use a condition to find orders by the instrument type for the position you are trying to find. To know if it was active you could check if the orders quantity matched its filled amount and check that its OrderState is not Filled. You could also potentially use the IsTerminalState method the order has to check if it was terminated.




    I look forward to being of further assistance.

    Comment


      #3
      Hello wjadevries,

      Thanks for your question.

      A position is not tied to an order and NinjaTrader does not track orders with the Position object.

      If you want to identify which orders have opened a position, you will need to track Orders/Executions as they come through and see when the position changes.

      For example, you could subscribe to ExecutionUpdate events in your indicator to keep track of executions that have just taken place. When you also subscribe to PositionUpdate events, you can see when the position changes, and then you can reference the recent executions tracked from the ExecutionUpdate event, or you can check the Account.Executions collection and see which executions have just taken place which would have modified the position.

      ExecutionUpdate - https://ninjatrader.com/support/help...tionupdate.htm

      PositionUpdate - https://ninjatrader.com/support/help...tionupdate.htm

      Account.Executions collection - https://ninjatrader.com/support/help...executions.htm

      We look forward to assisting.

      Comment


        #4
        Are orders in the Orders collection stored sequentially, so that the last order would be the last index (Count-1)?
        In that case could I also work backwards, so collect (Entry) orders from Count-1 summing Order.Filled until I have the full Position.Quantity?

        Comment


          #5
          Hello wjadevries,

          The Orders collection will reflect what you see in the Accounts tab of the Control Center. Yes, the last order in the collection would be Count-1.

          Yes, you could work backwards to subtract the Order.Filled quantity for orders made [in the same direction as your position] from Position.Quantity and this would tell you what orders contributed to the position.

          We look forward to assisting.

          Comment


            #6
            Thanks, that's what I needed to know!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X