Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

execution.Order null in OnExecution

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

    execution.Order null in OnExecution

    Sometimes, I get execution.Order being null in the optimizer in OnExecution. This didn't happen in NT 6.5.

    protected override void OnExecution(IExecution execution)
    {
    if (execution.Order == null) {
    Print("execution.Order is null for: " + execution.Name);
    // My code here...
    }
    }

    Most of the problem was "Exit on close" executions, so I manually ignore those in OnExecution. Maybe this info will help others that run into this:

    protected override void OnExecution(IExecution execution)
    {
    if (execution.Order == null) {
    if (execution.Name != "Exit on close") {
    Print("execution.Order is null for: " + execution.Name);
    // My code here...
    }
    }
    }

    But, I also see very rare cases of a null Order for the "Close position" execution name. Does anyone know why this might happen? TraceOrders reports:

    3/27/2009 11:00:00 PM Entered internal PlaceOrder() method at 3/27/2009 11:00:00 PM: Action=BuyToCover OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='HighRangeExit' FromEntrySignal='HighRange'
    execution.Order is null for: Close position
    3/27/2009 11:00:00 PM Entered internal PlaceOrder() method at 3/27/2009 11:00:00 PM: Action=Buy OrderType=Market Quantity=100 LimitPrice=0 StopPrice=0 SignalName='LongBounce2' FromEntrySignal=''

    It also happens after Buy actions, so it isn't specific to being after BuyToCover actions.

    #2
    Anagoge, IOrder objects have changed in several ways with NT7 - they are unique now and reflect current states of the order, which could lead to discrepancies depending on from which event you access them - http://www.ninjatrader-support.com/H...er_18_2009.pdf

    Comment


      #3
      I didn't see anything related to execution.Order being null in there, but I'm just ignoring the case where it is null now (I only need to know of new positions opened, not closed) and that is a reasonable workaround for me for now.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      601 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      347 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      559 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      558 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X