Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Dealing with Overfill

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

    Dealing with Overfill

    Hi,

    Why does overfill only occur on my Live Data Account, but never on Sim Data?
    Is there a reason for this?

    And is there any relatively simple way to deal with Overfill? That is to eliminate it from happening?

    Thank you.

    #2
    Hello WilliamW,

    Thanks for your post.

    Over-Fills are a serious issue that can occur when using complex entry conditions that bracket the market in both directions end up with both entries being filled instead of one being cancelled. Over-Fills can also occur when you place a trade quickly hoping to close a position while a prior order to close the same position already had an in-flight execution. The exact scenarios in which an over-fill can occur is highly dependent on the specific strategy programming.

    If you are using EnterLong or EnterShort method and also ExitLong or ExitShort, for example: If you exit and then call an entry method in the same run of OnBarUpdate, the OnPositionUpdate() will not have yet run and NinjaTrader will not have known that your position is closed. This will cause both actions to complete and end up sending 3 orders. The first order is the exit position from your exit method, the second order is to close the position from NinjaTrader automatically reversing your position, the third order is to enter you into the opposite position.

    This can happen with live data because orders are transmitted asynchronously to the code execution and would be somewhat dependant upon the time it takes for the orders to be transmitted, received by the broker/exchange, acted upon and then acknowledged back to your PC.

    You would need to review your code to see if, for example, you are calling to exit a position and then enter a position at the same time or exit a position by more than one means at the same time such as exitlong and setstoploss.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi gplatis,

      Thank you for your response. I will give this a try and see how it goes.

      Comment


        #4
        instead of `Position.Quantity` we could use `Position.MarketPosition` to determine the side. But I don't think that will help, because the problem here, is that `Position` object is not quickly updated when order is still being processed (in quick scenarios when multiple orders happens in same seconds).
        So, i think I should use variables (c# dictionary) to store each order's boolean state of processing step..

        Comment


          #5
          Originally posted by TazoTodua View Post
          instead of `Position.Quantity` we could use `Position.MarketPosition` to determine the side. But I don't think that will help, because the problem here, is that `Position` object is not quickly updated when order is still being processed (in quick scenarios when multiple orders happens in same seconds).
          So, i think I should use variables (c# dictionary) to store each order's boolean state of processing step..
          1. Disable Overfill processing.
          2a. Store desired size in variable.
          2b. Make Order
          3. Use OnPositionUpdate() to check that your position is the desired size: compare Position.Quantity to the stored value from Step 2 above.
          If the position is not the desired size, check if an overfill occurred, and issue new orders to bring the position to the correct size.

          Comment


            #6
            i will say once again, that BarsSinceEntry is not ideal to overcome overfill (especially in fast markets). it's all about the time needed before one order is processed completely, and only then should be fired other orders, so, not BARS amount, but time matter more.
            so, someone might check if i.e. 10 seconds is gone from last operation, and after that execute next command. However, best is to have private variables for states.



            Originally posted by koganam View Post
            1. Disable Overfill processing.
            in managed strategies, how to disable overfill processing? do you mean `IgnoreOverfill` which is only used in unmanaged?
            Last edited by ttodua; 05-23-2018, 02:27 AM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by timmbbo, Today, 08:59 AM
            0 responses
            1 view
            0 likes
            Last Post timmbbo
            by timmbbo
             
            Started by bmartz, 03-12-2024, 06:12 AM
            5 responses
            33 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Started by Aviram Y, Today, 05:29 AM
            4 responses
            13 views
            0 likes
            Last Post Aviram Y  
            Started by algospoke, 04-17-2024, 06:40 PM
            3 responses
            28 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by gentlebenthebear, Today, 01:30 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X