Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Overfill at crossover

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

    Overfill at crossover

    Hello,
    When I am trading crossovers, there are times when the strategy enters double the number of contracts at crossover. This happens when my trailing stop is within + or - 1 tick from the crossover price.
    Since I am using market orders, I.e enterlong and entershort, is there an order type that could help avoid the double fill?
    Thanks,
    Kiriru

    #2
    Originally posted by kiriru View Post
    Hello,
    When I am trading crossovers, there are times when the strategy enters double the number of contracts at crossover. This happens when my trailing stop is within + or - 1 tick from the crossover price.
    Since I am using market orders, I.e enterlong and entershort, is there an order type that could help avoid the double fill?
    Thanks,
    Kiriru
    Kiriru, unfortunately this is one of the risk of electronic trading you're running into : inflight executions as your working orders are very close to the inside market.



    You could work with the advanced order handling concepts and thus be able to check current states explicitly, thus cancel your trails, wait for a confirmed cancellation and then issue the market orders to reverse.

    Comment


      #3
      Got it!
      Thanks!

      Comment


        #4
        Betrand,
        I am trying to use the below to solve the overfill problem:
        protected override void OnOrderUpdate(IOrder order)


        {

        {
        if(order.OrderType == OrderType.Stop && (order.OrderState == OrderState.PendingSubmit || order.OrderState == OrderState.PendingCancel))
        {
        pendingStopOrder = order;
        }
        if(pendingStopOrder != null && order.OrderType == OrderType.Stop && order.OrderState == OrderState.Filled)
        {
        pendingStopOrder = null;
        }

        I have declared pendingstopoder under variables. I have placed : if(pendingStopOrder == null)
        before my entry conditions.
        Now, I get very few trades when I backtest with the above. Also, when I ran this in realtime, some event seems to stop my strategy from taking anymore trades.
        Do you have any ideas as to what could be populating the variable when its not supposed to?

        Comment


          #5
          kiriru, I would suggest you print the value of the variable from the OnOrderUpdate and also print the states your stop would have, for example a cancelled stop or partial fill is not covered in your code.

          For the 'event' stopping your strategy, please see the log tab at this time and work with TraceOrder = true in the Initialize() so helpful order debug info can be reviewed in the output window to assist.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by cmoran13, Yesterday, 01:02 PM
          0 responses
          27 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          18 views
          0 likes
          Last Post PaulMohn  
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          160 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          95 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          148 views
          2 likes
          Last Post CaptainJack  
          Working...
          X