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 NullPointStrategies, Today, 05:17 AM
    0 responses
    52 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X