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

Overfill issue

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

    Overfill issue

    I use IB for trade and unmanaged orders mode. Recently I came across with the overfill issue (see the picture in attachments)

    The strategy put limit order and then cancelled it. While the order was in the state of cancelling the broker filled it. As a result - the overfill error

    I've attached the log of my strategy also.
    Pay attention that last OnOrderUpdate returned the order in CancelSubmitted state and with filled price

    After that the strategy was stopped by NT. My question: how can I prevent overfill? And what's more important, if I can't prevent it, what can I do to recover my strategy?
    Attached Files

    #2
    Hello,

    Thank you for writing to the support team.

    I am reviewing your inquiry and will be back with a reply shortly.

    I look forward to assisting further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello rfsettling,

      Thanks for your patience.

      First, I would suggest to reproduce the scenario in Market Replay data and use Trace Orders and Prints to follow your strategies logic and order submission as it executes in the NinjaScript Output Window. You also may wish to comment out and reduce parts of the strategy so you can focus on how the order submissions get placed and result in an over fill.

      Our help guide has this note listed for Overfills from Unmanaged Strategies:

      Over-Fills

      ... The exact scenarios in which an over-fill can occur is highly dependent on the specific strategy programming. You should you decide to custom program your own over-fill handling it is up to you to either prevent over-fills from being a possibility in your code or by introducing logic to address over-fills should one occur.



      Once you understand the cause of the over fill, you can then correct the strategy by canceling any orders that create the over fill or by ignoring the overfill errors reported with IgnoreOverFill.

      Also from the IgnoreOverFill section of the help guide:

      An overfill is categorized as when an order returns a "Filled" or "PartFilled" state after the order was already marked for cancellation. The cancel request could have been induced by an explicit CancelOrder() call, from more implicit cancellations like those that occur when another order sharing the same OCO ID is filled, or from things like order expirations.

      You can trap such cases by looking for such events in OnOrderUpdate() and handling them appropriately for your strategy. Here are some links to resources discussed:

      IgnoreOverFill — https://ninjatrader.com/support/help...reoverfill.htm

      OnOrderUpdate() — https://ninjatrader.com/support/help...rderupdate.htm

      TraceOrders — http://ninjatrader.com/support/forum...ead.php?t=3627

      Market Replay — https://ninjatrader.com/support/help...ket_replay.htm

      Please let me know if I may be of further help.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Hello, Chris


        Thank you for your answer. I use IgnoreOverfill to prevent strategy stopping as you advised. I understand the reason why overfill comes across: I put some pending order and after a while cancel it (in OnBarUpdate). At the same moment broker fills my order and - voila - here is an overfill

        Ussually it can't be repeated neighter with market replay mode nor even with Sim account. Usually it happens with real account. I suspect that market replay and sim account have too ideal conditions to have this error.

        Comment


          #5
          Hello rfsettling,

          Thank you for the follow up.

          Situations like in-flight executions can not be recreated in Market Replay, however, order fill logic is handled by your computer so it is up to the programmer to code the strategy such that over fills are handled properly. OnOrderUpdate() is the key to handling cancellations and other order state change events. So your issues with canceling orders should be reproducible.

          If there is anything else I may assist with please let me know.
          Chris L.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Jon17, Today, 04:33 PM
          0 responses
          1 view
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          4 views
          0 likes
          Last Post Javierw.ok  
          Started by timmbbo, Today, 08:59 AM
          2 responses
          10 views
          0 likes
          Last Post bltdavid  
          Started by alifarahani, Today, 09:40 AM
          6 responses
          41 views
          0 likes
          Last Post alifarahani  
          Started by Waxavi, Today, 02:10 AM
          1 response
          19 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Working...
          X