Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Logical question about SampleOnOrderUpdate

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

    Logical question about SampleOnOrderUpdate

    Hi,
    in SampleOnOrderUpdate: https://ninjatrader.com/support/help...and_onexec.htm

    On line 122:

    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0)){
    ...
    }

    Is it a redundant judgment condition?
    Is it possible to replace with:

    if (execution.Order.Filled > 0){
    ....
    }


    On line 125:
    Is sumFilled redundant?
    On line 142 it can be replaced with if (execution.Order.OrderState == OrderState.Filled){
    entryOrder = null;
    sumFilled = 0;
    }


    Attached Files

    #2
    Hello jetheil2,

    Thanks for your post.

    The sumFilled part was added to handle an edge case where you get a partial fill and a complete fill happening within 1/100th of a second.

    It does look like some of the logic can be optimized to remove some redundancies.

    I'll see about simplifying this and getting changes approved.

    EDIT: It was decided to leave the code as it is. Even though there are redundancies, the repeated code and logic is intended to be educational over being concise.

    We look forward to assisting.
    Last edited by NinjaTrader_Jim; 03-03-2022, 09:00 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X