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 kinfxhk, 07-14-2026, 09:39 AM
    0 responses
    10 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    59 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    41 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    47 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    38 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X