Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Which order gets executed first?

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

    Which order gets executed first?

    Hello,
    I'm developing a strategy that increases the number of contracts as the price moves in our favor (for instance, if we enter Long and the price rises, it adds positions).
    - The distance at which these orders are placed is configurable.
    - Targets and Stop Loss are also set for each executed entry, and they are configurable as well.
    - Additionally, I have a condition that if the position is set to Flat, all subsequent additional orders placed to enter the market are canceled. So that when it reaches a specific target and is set to flat, it does not make any more entries.

    The question is:
    - Given that the next entry is configurable and the Take Profit is configurable, there is a possibility that they are placed at the same price (assuming this is valid for now).
    - If there are 5 additional entries, and the first additional entry has the same price as the first original Take Profit, when it reaches the configured price, which order is executed first? Is it the Take Profit or the Additional Entry?

    In this scenario, I don't want the positions to be closed because I want the additional entry to be executed first, so it doesn't go flat, then open the new position, and finally, the Take Profit is executed. All this when it reaches the same price. Is it possible to do this? How?

    I conducted tests, and on one PC, it does one option, and on another PC, it does the other option. Hence the question.
    Since we are in LONG, the Take Profit order is a Limit, and the additional order is a Stop.
    I'll show the case in the attached image.​

    Click image for larger version

Name:	imagen.png
Views:	137
Size:	38.0 KB
ID:	1277871

    #2
    Hello ervin,

    If two orders are working at the same price, the order that was submitted first will most likely fill first.

    "In this scenario, I don't want the positions to be closed because I want the additional entry to be executed first, so it doesn't go flat, then open the new position, and finally, the Take Profit is executed"

    I'm not clear on why you would want to exit a position just to immediately enter the same position. Why not just keep the position open?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I'm not clear on why you would want to exit a position just to immediately enter the same position. Why not just keep the position open?
      It's because of the parameters. I'm aware that if I set the Take Profit parameters further away and the entries closer, everything works fine. However, I'm specifically inquiring about this scenario because it's permissible for the parameters to be in that situation, and I want to know how to program it when this occurs.

      Comment


        #4
        Hello ervin,

        Submitting the new entry first, should cause it to fill first. I would recommend that you ensure the new entry is in a working state before submitting the exit.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you Chelsea,
          I'm submiting new entry first, and then the Target.
          I would recommend that you ensure the new entry is in a working state before submitting the exit
          How do you sugest me to do that? Because when the Long position is opened, I use OnOrderUpdate to put the aditional orders, and I use on execution update to put the Targets. So because I read that I think OnOrderUpdate executes first than onexecutionupdate, right?

          Comment


            #6
            Hello ervin,

            Detecting the order.OrderState to be OrderState.Working would be in OnOrderUpdate().

            When an order fills, OnOrderUpdate() typically runs before OnExecutionUpdate() but this is not guaranteed.
            Hello, I see in the documentation you have fixed: 15048 Added Adapter, Rithmic Updated Rithmic API to version 11.3.0.0 Can you elaborate on that please? Will OnOrderUpdate() OnExecutionUpdate() and OnPositionUpdate() be called in the expected order?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thank you Chelsea, I'll check it out and let you know

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              50 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              126 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              69 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              42 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              46 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X