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 cmoran13, Yesterday, 01:02 PM
        0 responses
        27 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        18 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        160 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        95 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        148 views
        2 likes
        Last Post CaptainJack  
        Working...
        X