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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      177 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      332 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      254 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      356 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      184 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X