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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Working...
    X