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

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.




    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 kevinenergy, 02-17-2023, 12:42 PM
          115 responses
          2,698 views
          1 like
          Last Post kevinenergy  
          Started by prdecast, Today, 06:07 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by Christopher_R, Today, 12:29 AM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by chartchart, 05-19-2021, 04:14 PM
          3 responses
          577 views
          1 like
          Last Post NinjaTrader_Gaby  
          Started by bsbisme, Yesterday, 02:08 PM
          1 response
          15 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X