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 NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        86 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        151 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        79 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        53 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        61 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X