Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order.OrderId use for matching Execution to Order

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

    Order.OrderId use for matching Execution to Order

    Hello

    I need to use the Unmanaged option for my strategy.
    Could anybody confirm that the orderId that I get when I call submitOrder() is the same as the orderID i get in execution.Order.OrderId in OnExecution() ?

    Thanks
    Michael

    #2
    Hi Michael, generally you could not rely on the uniqueness of the order id, since for example brokerages could change it externally, with NT7 IOrder objects could be directly compared for equality now.

    This has been also discussed here - http://www.ninjatrader.com/support/f...ad.php?t=24666

    Comment


      #3
      So the best way to match a entryOrder to its execution in onExecution() is

      execution.Order.Equals(entryOrder)?

      I just tried it in code and doesnt seem to work in sim101.

      Thanks
      Michael

      Comment


        #4
        Correct, for example these both I would expect to get hit the same in OnExecution() -

        protected override void OnExecution(IExecution execution)
        {
        if (entry1 != null && entry1 == execution.Order)
        Print("1: " + execution.Order.OrderId.ToString());

        if (entry1 != null && execution.Order.Equals(entry1))
        Print("2: " + execution.Order.OrderId.ToString());
        }

        Comment


          #5
          what i do is this:

          entryOrder = submitOrder();

          later in onExecution():
          if (execution.Order != null && execution.Order==entryOrder)
          // horray found my order again

          In my environment the matching with order.orderId works better then the .Equals() when I use the Optimiser, I didnt test it using the broker.

          Is there a good example on unmanaged code with order execution matching in onExecution() ?

          Thanks
          Michael

          Comment


            #6
            Hi Michael, there would be no direct Unmanaged sample, however we did publish a system trading the Camarilla Levels which would be also available in an unmanaged version here - http://www.ninjatrader.com/support/f...d=5&linkid=571

            You could review it to get started in this area.

            Comment


              #7
              Thank you for the example.
              It seams that the way i do it using orderId works better in the optimiser than .equals().
              Would you know if the Camarilla code runs in the optimiser and broker accounts alike?

              Thanks
              Michael

              Comment


                #8
                Hi Michael, could not speak for actual trading this strategy, it's not a live traded system but shown for educational purposes only by us how such an approach could be implemented.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by DannyP96, 05-18-2026, 02:38 PM
                1 response
                27 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by CarlTrading, 05-11-2026, 05:56 AM
                0 responses
                117 views
                0 likes
                Last Post CarlTrading  
                Started by CarlTrading, 05-10-2026, 08:12 PM
                0 responses
                69 views
                0 likes
                Last Post CarlTrading  
                Started by Hwop38, 05-04-2026, 07:02 PM
                0 responses
                226 views
                0 likes
                Last Post Hwop38
                by Hwop38
                 
                Started by CaptainJack, 04-24-2026, 11:07 PM
                0 responses
                414 views
                0 likes
                Last Post CaptainJack  
                Working...
                X