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

Is execution.Order.OrderState dynamic?

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

    Is execution.Order.OrderState dynamic?

    Hi NT experts,

    I am wondering if execution.Order.OrderState dynamic? In the case of partial fill, execution.Order.OrderState will have the value
    OrderState.PartFilled at the begining. When the whole order is filled by several partial fills, will the value of execution.Order.OrderState become
    OrderState.Filled?

    Regards,

    #2
    Yes. It will return the value of the underlying IOrder object. Be careful. You should not trigger logic based off of an OrderState from the executions since the OrderState can be ahead of the particular execution you are processing. Instead if you want to know when you are filled, count the received executions and self determine if the quantities have been met then do something.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh. You are right. This is actually a question on using what to trigger a logic.

      Is execution.Order.Filled dynamically updated in the case of partial fills? If so, then I would assume it can be used to manually check against the specified entry amount.

      And can you also comment on what is the difference between execution.Order.Filled and execution.Order.Quantity?

      Regards,

      Comment


        #4
        All of the .Order.____ properties are updated and should not be used if you are trying to create some logic in OnExecution. If you want to test quantity use execution.Quantity. You know the quantity you submitted at. Just self aggregate the execution.Quantities that come in and then you will know when the full position has been filled.

        .Order.Quantity is the amount you submitted at .Order.Filled is the amount filled.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thank Josh. But I am not certain how to aggregate execution.Quantity.

          I would assume different partial fills will have different executionID even for a same execution.Order.Token. Then summing the execution.Quantity up for all these executionIDs?

          Do you have a couple of lines of sample codes handy?

          Regards,

          Comment


            #6
            Here is what i am trying to check partial fills against submitted amount before triggering an stop order. Please take a look if it makes sense:

            private int totalFilledQuantity1 =0;
            .....
            protectedoverridevoid OnExecution(IExecution execution)
            {

            if (entryOrder1 != null && entryOrder1.Token == execution.Order.Token && Position.MarketPosition == MarketPosition.Long)
            {
            if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
            {

            totalFilledQuantity1 = totalFilledQuantity1 + execution.Quantity;

            if (totalFilledQuantity1 == execution.Order.Quantity)
            {
            stopOrder1 = ExitLongStop(
            0, true, totalFilledQuantity1, stopPrice, "SL1", "Entry1");
            if (execution.Order.OrderState != OrderState.PartFilled)
            {
            entryOrder1 =
            null;
            }

            }
            }
            }
            }

            Comment


              #7
              You already got the jist idea. You can check either Order.Name, Order.Token, with the order you want to track. Then just run your own variable that adds quantity to itself.
              Josh P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by rocketman7, Today, 02:12 AM
              7 responses
              29 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by guillembm, Yesterday, 11:25 AM
              3 responses
              16 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by junkone, 04-21-2024, 07:17 AM
              10 responses
              148 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by tsantospinto, 04-12-2024, 07:04 PM
              6 responses
              101 views
              0 likes
              Last Post tsantospinto  
              Started by trilliantrader, 04-18-2024, 08:16 AM
              7 responses
              28 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Working...
              X