Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I know if an IOrder is already exited?

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

    How do I know if an IOrder is already exited?

    E.g. i have a list of IOrder objects, and I want to loop over them, and find out which ones have hit stop losses, and which are still open?

    #2
    AntiMatter, you would need to check their respective fillstates, for examle in OnOrderUpdate().

    Comment


      #3
      After the initial entry order being filled, isn't this always "OrderState.Filled", even if we have since closed this position? I would like to know if an entryOrder is now closed/flat.

      Comment


        #4
        Correct, after an order is filled, you would see the terminal .Filled state being reported - if you'd like to check the strategy position state you can use Position.MarketPosition

        Comment


          #5
          The problem I have is that I have multiple entry orders for a given instrument. Thus I could still be long with Order1, but now flat (having hit my stoploss) with order2.

          With Position.MarketPosition, it will reveal that I am long
          With OrderState, both will be Filled.

          How do I determine that Order1 is still long, but order2 is now flat?
          Last edited by AntiMatter; 07-06-2011, 07:20 AM.

          Comment


            #6
            AntiMatter, it sounds like you'll need to write some custom code to keep track of the position. You could keep track of executions in OnExecution() and then every time Order1 is filled long, you add 1 to the position counter and every time it is filled short you subtract 1 from the position counter.
            Last edited by NinjaTrader_Austin; 07-06-2011, 10:04 AM. Reason: grammer corrections
            AustinNinjaTrader Customer Service

            Comment


              #7
              OK, no shortcuts, darn it.

              Thanks nonetheless.

              Comment


                #8
                Hmmmn, how do I catch that my stoploss has been hit?

                Comment


                  #9
                  Hello,

                  You would need to compare the order ID of your stop loss to the order ID that got filled.

                  Please see this sample monitoring your stop loss:

                  Monitoring Stop-Loss and Profit Target Orders

                  Let me know if I can be of further assistance.
                  BrettNinjaTrader Product Management

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  670 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  379 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  111 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  575 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  582 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X