Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limit order overfilled

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

    #16
    I just made 2 mistakes on my explanation. This is the right one (changes in red):

    -----------------------------------------------------------
    hbMilles,

    THe code I added to my strategy to avoid overfilling is disseminated along the strategy. Better than doing this I will explain my solution as a pseudo-code

    THe scenario that produced the error was:
    - I launch an EnterLongLimit() to open a position.
    - On the next bar I launch an ExitLongLimit() order to set a sort of stop profit target.
    - If, when launching the ExitLongLimit() order, the EnterLongLimit() wasn't completely filled and a new partial fill came after this point this caused the error.

    Following the instructions of the customer service the rule to follow to avoid this problem is to never have two active limit orders competing at the same time.

    So, I had to change the code to avoid the EnterLongLimit() and the ExitLongLimit() orders being active at the same time.

    The new steps to do the same are:
    1- I launch an EnterLongLimit() to open a position.
    2- I set two conditions and one of them must be accomplished before launching the ExitLongLimit() order.
    -- First condition: the order must be filled. For this I use IOrder handling (http://www.ninjatrader-support.com/H...de.html?IOrder)
    -- Second condition: I'm never sure that an order will be completely filled. To solve this I wait a prudential number of bars and then I cancel the EnterLongLimit() order. This code could be useful: http://www.ninjatrader-support.com/H...ml?CancelOrder
    3- After one of these conditions are accomplished I cancel EnterLongLimit() order and I can launch the ExitLongLimit() order without creating an overfill issue.

    Hope it helps
    -----------------------------------------------------------

    Comment


      #17
      guillembm, thank you for your explanation of how you solved this issue.
      AustinNinjaTrader Customer Service

      Comment


        #18
        guillembm,

        thanks - I really appreciate your feedback & it helped very much.
        hbmiles2000

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        25 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        115 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        69 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        225 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        411 views
        0 likes
        Last Post CaptainJack  
        Working...
        X