Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about OrderState.Filled

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

    Question about OrderState.Filled

    I'm using the OnExecution procedure to check on an order fill:
    protectedoverridevoid OnExecution(IExecution execution)
    {
    if(iOrderFirstAddContracts != null && iOrderFirstAddContracts == execution.Order)
    if(execution.Order.OrderState == OrderState.Filled)
    {
    writeInfo(
    "firstAddContracts");
    }
    }

    iOrderFirstAddContracts was set as the return of the entry order.
    I'm trying to get the report of a 5 contract fill. writeInfo was called three times. I have a later "if" statement for a different entry that is only for 1 contract and writeInfo then was only called once. I assume that it was called three times in the above code because of partial fills, but I thought that by using OrderState.Filled on execution it would wait until the order was completely filled.
    What am I doing wrong?



    #2
    Hello Sgordet,

    First step here is to print more relevant information. Snippet below will print execution details for the order, so you can check price, quantity, etc.

    if(execution.Order.OrderState == OrderState.Filled)
    {
    Print(execution.Order.ToString());
    }

    The OnExecution() event is called with any change in execution, so I'm not sure that counting the number of times writeInfo is called will give you anything useful.
    Last edited by NinjaTrader_RyanM1; 01-27-2011, 03:15 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I'm sorry. I'm not understanding. I thought that by using
      if(execution.Order.OrderState == OrderState.Filled)
      the consequent code would only be executed if the order was completely filled. Is that incorrect?

      Comment


        #4
        Yes, that's true. You'll still want to print useful output to identify what's happening here.

        The state of the order persists until there's a new state, so counting the number of times it writes to a file is not telling you anything useful.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        368 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        571 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X