Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Working orders detected in OnOrderUpdate but not OnExecution method

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

    Working orders detected in OnOrderUpdate but not OnExecution method

    I am trying to get my OnExecution method to perform some actions when it detects a working order, like this:

    Code:
    protected override void OnExecution(IExecution execution)
    {
                if (execution.Order != null && _yEntryOrder == execution.Order &&
                execution.Order.OrderState == OrderState.Working)
                { 
                    Print(execution.ToString() + "\t\tOrder working.");
                }
    }
    When I run this in live simulation, OnExecution detects my filled and cancelled orders, but doesn't detect my working orders.

    On the other hand, if I used the OnOrderUpdate method to detect any working orders, like this:

    Code:
    protected override void OnOrderUpdate(IOrder order)
    {
                if (_yEntryOrder != null && _yEntryOrder == order && 
                _yEntryOrder.OrderState == OrderState.Working)
                {
                    Print("Order working.");
                }
    }
    ...the print action is carried out correctly. Is there a reason why OnExecution can't detect working orders? Is this just a simulation behavior?

    Thanks!

    #2
    llstelle, this would be expected and you would see the same live as well - OnExecution strictly deals with feedback on executions only, this would not include an order update going to 'working' state.

    Comment


      #3
      Thank you!

      Can I also confirm that OnExecution does not deal with the following order states?

      - OrderState.Cancelled
      - OrderState.PendingSubmit
      - OrderState.Accepted
      - OrderState.Unknown

      Comment


        #4
        Originally posted by llstelle View Post
        Thank you!

        Can I also confirm that OnExecution does not deal with the following order states?

        - OrderState.Cancelled
        - OrderState.PendingSubmit
        - OrderState.Accepted
        - OrderState.Unknown
        That's correct.

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          That's correct.
          Thank you so very much. I hope you have a wonderful week ahead of you!

          Comment


            #6
            best wy to check if I have pending orders

            Hi there

            I run a script that alerts me via email when the market is favorable for my trading, however when the strategy sends an order to the market (limit or stop) I would like to avoid getting alerts, whats the best way to filter this?

            would something like this work?
            Code:
            else if (Position.MarketPosition == MarketPosition.Flat && (entryOrderShort !=null || entryOrderLong !=null)) 										
            				{

            Comment


              #7
              yades, yes checking for the flat state in OnBarUpdate() with the 'non taken' IOrder objects should be sufficient, so you're not getting alerted anymore once that changes to having a position or any order long / short would be working hence the IOrder used.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              639 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              366 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              107 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              569 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              572 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X