Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to detect an overfill ?

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

    How to detect an overfill ?

    After submit a CancelOrder(iorder), how can I check if that order returns an overfill state ?

    I've read in the help guide all about it, however I can't find a clear example, just in the iOrder properties and methods that says : **A bool value representing if the order is an overfill but there's no an example to learn from.

    Can you write a little example how to detect if a CancelOrder returns an overfill afterwards ?

    It seems that is not something to check in the OnOrderUpdate, cause there is not any "overfill" state, so where and how to detectd that OverFill bool variable?

    Overfills probabilities will depend on your logic algo and market conditions, even with low probabilities, to have an Algo disable is not something that I'd like.

    Looking forward
    Last edited by pstrusi; 09-29-2015, 01:51 PM.

    #2
    Hello pstrusi,

    Thank you for your post.

    You would first ensure you are using the Unmanaged Approach: http://ninjatrader.com/support/helpG...d_approach.htm

    You would also use the IgnoreOverFill bool: http://ninjatrader.com/support/helpG...reoverfill.htm

    Then override OnOrderUpdate() and check the IOrder's OverFill bool:
    Code:
    		protected override void OnOrderUpdate(IOrder o)
    		{
    			if(o.OverFill)
    				Print("Over fill");
    		}

    Comment


      #3
      Thanks a lot Patrick.

      I have a doubt. Finally I've just seen another post regards to the same matter, but the way to do it is a little different, cause it seems to be done under OnBarUpdate, so I'm little confused. What would it be the fastest and efficient way to detect the OverFill ?

      Following what I read:
      Originally Posted by NinjaTrader_ChelseaB View Post
      Hi koganam,

      If there has been an overfill on an order the IOrder handle will have an Overfill object that will be true.

      For example:

      private IOrder myOrder = null;

      myOrder = EnterLongLimit();

      if (myOrder.Overfill == true)
      // overfill detected
      Last edited by pstrusi; 09-29-2015, 02:30 PM.

      Comment


        #4
        Hello pstrusi,

        What you quoted there is correct. OnOrderUpdate() would make sense as this is when the order updated. If you ran OnBarUpdate() the bar may update after or before the overfill event. So it would still pick it up but I would not say it would be faster. I would expect OnOrderUpdate() to be the "fastest" means to get the OverFill bool on an IOrder object.

        Comment


          #5
          Originally posted by pstrusi View Post
          Thanks a lot Patrick.

          I have a doubt. Finally I've just seen another post regards to the same matter, but the way to do it is a little different, cause it seems to be done under OnBarUpdate, so I'm little confused. What would it be the fastest and efficient way to detect the OverFill ?

          Following what I read:
          I understood Chelsea to mean that the check should be done in the most efficient place, which would be OnOrderUpdate().

          You will notice that the code he provided has no section delineators at all.
          Last edited by koganam; 06-02-2016, 08:56 AM. Reason: Corrected spelling and grammar.

          Comment


            #6
            Hi Ninjas,

            Regarding to OverFill situation, I'm still struggling to build a secure procedure to address it, cause there's certain detail info not quite well understood by me since I'm not an advanced programmer. Well, I'll put this situation in order to state my doubts:

            When a signal to reverse a position is triggered by the Algo's logic ( when OnBarUpdate=true ) , the first logic step is to check and cancel if there's any old-live order, when doing so, an OverFill is produced, here my doubts:

            1. Is correct this snippet to detect an OverFill and actual cancelled status afterwards ?
            Code:
            protected override void OnOrderUpdate(IOrder order)
            {
                 if (lEntryOrder != null && lEntryOrder == order)					
            			{					
            				if(lEntryOrder.OverFill)				
            				{				
            					// OverFill ! do something			
            				}				
            			
                                           if (order.OrderState == OrderState.Cancelled)				
            				{				
            					lEntryOrder = null;			
            				}
                                   }
            }
            2. After OverFill, when I check the new OrderState in the 2nd condition ( since there was a PartFilled or Filled ) will the new OrderState come as Cancelled ?

            3. In the Algo's logic, the first step is cancel any old-live orders and the second step is obviously submit the order to reverse the position, the quantity that will be in that order is calculated as any old Position.Quantity plus my Position.NewQuantity. Returning to the example above, if there was an OverFill: Will the old Position.quantity be updated correctly before the order is submitted ?

            I hope that with this clarified I can be able to finish the correct procedure.

            Thanks
            Last edited by pstrusi; 10-05-2015, 03:48 PM.

            Comment


              #7
              Originally posted by pstrusi View Post
              Hi Ninjas,

              Regarding to OverFill situation, I'm still struggling to build a secure procedure to address it, cause there's certain detail info not quite well understood by me since I'm not an advanced programmer. Well, I'll put this situation in order to state my doubts:

              When a signal to reverse a position is triggered by the Algo's logic ( when OnBarUpdate=true ) , the first logic step is to check and cancel if there's any old-live order, when doing so, an OverFill is produced, here my doubts:

              1. Is correct this snippet to detected an OverFill and actual cancelled status afterwards ?
              Code:
              protected override void OnOrderUpdate(IOrder order)
              {
                   if (lEntryOrder != null && lEntryOrder == order)					
              			{					
              				if(lEntryOrder.OverFill)				
              				{				
              					// OverFill ! do something			
              				}				
              			
                                             if (order.OrderState == OrderState.Cancelled)				
              				{				
              					lEntryOrder = null;			
              				}
                                     }
              }
              2. After OverFill, when I check the new OrderState in the 2nd condition ( since there was a PartFilled or Filled ) will the new OrderState come as Cancelled ?

              3. In the Algo's logic, the first step is cancel any old-live orders and the second step is obviously submit the order to reverse the position, the quantity that will be in that order is calculated as any old Position.Quantity plus my Position.NewQuantity. Returning to the example above, if there was an OverFill: Will the old Position.quantity be updated correctly before the order is submitted ?

              I hope that with this clarified I can be able to finish the correct procedure.

              Thanks
              According to your description, you only cancelled orders. That should have no effect on the position.

              Comment


                #8
                If there's an OverFill is cause there was a PartialFilled or Filled of an old order, thus the Position.quantity has to have changed, state that you should check in OnPositionUpdate, ButI'd want to be sure that these processes are done in the correct timing
                Last edited by pstrusi; 10-05-2015, 03:45 PM.

                Comment


                  #9
                  Originally posted by pstrusi View Post
                  If there's an OverFill is cause there was a PartialFilled or Filled of an old order, thus the Position.quantity have to have changed, state that you should check in OnPositionUpdate, ButI'd want to be sure that these processes are done in the correct timing
                  In that case check the position quantity before you place the reversal order.

                  Even then, still, as you describe it, the overfill came from the cancel order, possibly followed by an order that got sent before the cancel order was executed. So, still, as no order was filled, the position would not have changed. However, it would still be best to check the position before you issue the new order.
                  Last edited by koganam; 10-05-2015, 11:09 AM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by bmartz, Today, 09:30 AM
                  2 responses
                  11 views
                  0 likes
                  Last Post bltdavid  
                  Started by f.saeidi, Today, 11:02 AM
                  1 response
                  3 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by geotrades1, Today, 10:02 AM
                  4 responses
                  12 views
                  0 likes
                  Last Post geotrades1  
                  Started by rajendrasubedi2023, Today, 09:50 AM
                  3 responses
                  16 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by lorem, Today, 09:18 AM
                  2 responses
                  11 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X