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

OnExecution Partial Fill

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

    OnExecution Partial Fill

    Hello

    I rely on the OnExecution event to know when my position is closed. My question is:

    a. Since for the same order can be several OnExecution events (in case of a partial fill) how do I know at the OnExecution event that all parts were filled and my order is completely executed? For example, if I have an exit order with a size of 10 and it was executed with partial fills of 6, 3 and 1, in that order, I want to know at the last execution of 1 that it was the last one.

    b. In case I have several partial fills how do I know my FINAL average fill price?
    In the example above if the price was 10, 11 and 9 then the average price is (6 X 10 + 11 X 3 + 1 X 9) / 10 = 10.2

    Thanks

    #2
    Hello kiss987,

    Thanks for your inquiry.

    OnExecution() contains an IExecution that also contains an IOrder representing the associated order. The Execution object can tell you the quantity of the execution filled.

    You can detect if the underlying order reaches OrderState.PartFilled in OnExecution(), and you can see if the underlying order's IOrder.Filled property equals the IOrder.Quantity property to represent a partial fill closing a position.

    Once you see that the IOrders Filled property matches the Quantity property, the AvgFillPrice property will reflect the final average fill price for that order.

    I've included documentation links to the IExecution IOrder documentation so you can reference the properties used to create this logic.

    IExecution - https://ninjatrader.com/support/help...iexecution.htm

    IOrder - https://ninjatrader.com/support/help...t7/?iorder.htm

    Please let me know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you

      You mean that once the Filled value reaches the target (10 in my example), the AvgFillPrice value will be set to the final value (10.2 in the example)?

      Comment


        #4
        Hello kiss987,

        Yes, once the Order object's Filled property equals its Quantity property, the AvgFillPrice will represent the average fill price for the all of the order's fills.

        Please let us know if we can be of further help.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        11 responses
        39 views
        0 likes
        Last Post cmtjoancolmenero  
        Started by FrazMann, Today, 11:21 AM
        0 responses
        5 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        26 views
        0 likes
        Last Post DayTradingDEMON  
        Started by George21, Today, 10:07 AM
        1 response
        22 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X