Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Detecting when an order has been filled

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

    Detecting when an order has been filled

    Hey fellas -

    I've been using the Position.MarketPosition == MarketPosition.Long and Position.MarketPosition == MarketPosition.Short statements to take some actions once an order has been filled and that has been working.

    However, there is one instance where it doesn't work and I'd like some suggestions. Since I have the strategy set to OnBarClose, if an order fills and hits the stop loss on the same bar, neither of those Position statements get executed.

    Is there an alternative way of detecting when an order has been filled (managed and unmanaged)?

    #2
    Hello PN720,

    Thank you for the post.

    Generally, it is suggested to use the OnOrderUpdate and OnExecutionUpdate overrides for this purpose. If you run into situations where you need the actual events of the orders, this is a good use case for these overrides.

    https://ninjatrader.com/support/help...xecutionUpdate
    https://ninjatrader.com/support/help...ghtsub=onorder

    We have a sample that demonstrates tracking orders and submitting protective orders using these overrides here: https://ninjatrader.com/support/help...and_onexec.htm

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hey fellas,

      Thanks for the prompt response.

      If I want to stay with Managed orders, is there a way I can just detect that the order has been executed via a count or something?

      Comment


        #4
        Hello PN720,

        My prior reply was in regard to both Managed and Unmanaged, the overrides work with both.

        It would still be suggested to use OnExecutionUpdate to know when an order fills specifically. If you wanted to use a counter, you could implement one and increment it when you Enter, but that doesn't account for any order errors or problems. The most accurate way to track your orders would be to use the OnExecutionUpdate to know they filled. You could also use this to increment a counter or do any other logic, but this ensures the order was filled first.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Originally posted by PN720 View Post
          If I want to stay with Managed orders
          OnOrderUpdate and OnExecutionUpdate are methods available for use with both Manage and Unmanaged mode. In fact, the use or (non-use) of these 2 methods is completely independent of the 'mode' chosen.

          Your statement is a non-sequitur, and shows that you may be overlooking the usefulness and purpose of these functions.

          Originally posted by PN720 View Post
          is there a way I can just detect that the order has been executed via a count or something?
          At some point, Position.Quantity becomes > 0 to reflect the position's size.

          Otherwise, the 'count' you're looking for is provided through the 2 methods above.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Unsuitable, Today, 08:41 AM
          0 responses
          1 view
          0 likes
          Last Post Unsuitable  
          Started by newdill, Today, 07:54 AM
          0 responses
          4 views
          0 likes
          Last Post newdill
          by newdill
           
          Started by qwertyjjj, Today, 06:52 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by NeverDownMoney, 09-25-2020, 09:40 PM
          1 response
          14 views
          0 likes
          Last Post NT-Roland  
          Started by wjadevries, Today, 04:21 AM
          1 response
          12 views
          0 likes
          Last Post wjadevries  
          Working...
          X