Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Converting target limit order to market order

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

    Converting target limit order to market order

    Hello,

    I have some strategies that don't perform as well as backtest results due to higher than expected hit-but-no-fill when the target is hit. Often times the target isn't hit again and they get stopped out. I want to explore converting the target limit order immediately to a market order when this happens, with the understanding that there might be some slippage, in the hope that I might mitigate some of this and still come out ahead. Do you have any suggestion or sample code on how to do this? Is there a particular OrderState or combination that would reveal this? My code is unmanaged and implemented in OnExecuteOrder and is quite robust and fleshed out.

    Thanks,
    silverm3170

    #2
    Hello silverm3170,

    To accomplish what you're asking, you would need to add logic that checks if the order's price has been met and the order has not been filled and then wait a short time to ensure it does not fill. At that point, you could submit a cancel on that order and observe a OnOrderUpdate when the order is canceled. Once you know the order is canceled, you could submit a market exit order. If you don't do the cancel process, you run the risk of having that order fill and also submitting an exit order at the same time, thereby doubling the exit. I'm not aware of any specific code samples for that concept, but you can use the OnOrderUpdate example as a reference for how to observe order updates.

    Comment


      #3
      Thanks Jesse. I just found out about MIT orders. What if I used an ExitLongMIT when initially setting up the target instead of a ExitLongLimit? I understand it would always be market with potential slippage but perhaps OK if a very liquid market.

      Comment


        #4
        Hello silverm3170,

        Yes you can also try that type of order to see how it may work with your trading goals. You would need to test that and see if the trigger and slippage is acceptable, the alternative would be the process I had explained.

        Comment


          #5
          Thanks Jesse. For the solution you proposed, would I need to monitor the price change within OnMarketData? I'm currently running my strategy OnBarClose. Would I need to change to OnPriceChange, or even switch to tick replay?

          From an event-based programming perspective, does NT have an event handler for processing time deltas, e.g. trigger x milliseconds later from a reference time in OnMarketData, to check if it got filled (where I would have tagged it as filled during an intervening OnExecutionUpdate call), or do I need to look at some C# system object?

          Comment


            #6
            Hello silverm3170,

            Yes those would all be options, you can also use OnBarUpdate depending on the frequency you want that checked.

            There is not a built in method to trigger an action later, you would have to use logic or variables to do that type of action. You could look at using a C# timer for that type of action as well.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            574 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            332 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            553 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X