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

IExecution.Price or IExecution.Order.AvgFillPrice

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

    IExecution.Price or IExecution.Order.AvgFillPrice

    Hello


    i need to retrieve the AvgEntryPrice for the order that just got filled.

    So i did an override of the OnExecution() method

    but now i have a dilemna, what is the difference between

    IExecution.Price
    and
    IExecution.Order.AvgFillPrice

    if IExecution.Price is the total price of the operation
    then does IExecution.Price / IExecution.Quantity give the same result as the Order.AvgFillPrice ?
    (with a round2tick() i suppose)

    Thank you


    edit:

    Also, when OnExecution() is called
    do i need to check the Order.OrderState ? Or will they all be OrderState.Filled ?
    Last edited by zark.be; 10-27-2008, 03:35 AM.

    #2
    Hello,


    AvgFillPrice is the average fill price for the order. Price is the price of that execution, which may or may not be for the entire order quanitity.

    OnExecution event does not guarantee you to have an OrderState of Filled. You can easily be in a PartFilled state so you will need to check the OrderState if your logic requires it.
    DenNinjaTrader Customer Service

    Comment


      #3
      Basically, if i do an EnterLong(10)

      two cases could happen :

      1/ onExecution() is called once because i was completely filled.

      2/ onExecution() is called n-1 times with PartFilled and 1 with Filled


      Correct ?


      So in case
      1/
      IExecute.Order.AvgPrice will therefore show the average price for the 10 contracts.

      2/ in the (n-1) calls to onExecution() with a PartFilled order, they will each show a different AvgPrice.
      Does the avgprice reflect that of the Partial order ? Or that of the full order updated with current values ? So that the last call to onExecution being the Filled Orderstate will have the correct AvgPrice ?

      Comment


        #4
        1) Correct.

        2) Remember, NinjaTrader is multi-threaded and as such this matter is not that simple. Order.AvgPrice will give you the average price of the ENTIRE order at any point in time. Due to the multi-threaded nature of NinjaTrader you can still be processing the first partial fill in OnExecution, but your Order.AvgPrice will be returning the average price of your entire order which is already completely filled.

        Does this make sense? While you are processing an OnExecution event your order can already be in a Filled state and as such when you access Order.AvgPrice it is not reflective of the average price during the OnExecution event, but it is reflective of the average price of the latest possible moment of the order.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks josh,

          yes i understand that the reference IExecution.Order points to an IOrder object that is background updated by another NT Thread.


          so basically all i need to do in my OnExecution() is check for a OrderState = Filled
          Because that way i'll know for sure that the IObject referenced has the latest AvgPrice value.
          (and for every call to OnExecution i will actually receive the same reference to the same IObject, only that it's a way for me to know that it has been updated)

          Okay i understand now, it makes sense
          It's all quite logical, but it's just lacking a bit of documentation.

          Comment


            #6
            Glad you got it resolved.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by MGHORBEL, 05-06-2024, 06:41 AM
            4 responses
            21 views
            0 likes
            Last Post MGHORBEL  
            Started by ChastiJose, Today, 03:37 AM
            0 responses
            7 views
            0 likes
            Last Post ChastiJose  
            Started by Klaus Hengher, Today, 03:13 AM
            0 responses
            8 views
            0 likes
            Last Post Klaus Hengher  
            Started by ewileznwpods, Today, 02:57 AM
            0 responses
            4 views
            0 likes
            Last Post ewileznwpods  
            Started by 1001111, Today, 01:35 AM
            0 responses
            6 views
            0 likes
            Last Post 1001111
            by 1001111
             
            Working...
            X