Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with monitoring Stop orders

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

    Help with monitoring Stop orders

    Hi,

    I want to be able to ensure that the proper quantity of my stop orders is matched with the entries that were filled at all times. For example, if I submit a 10 lot and it gets filled, I immediately place a 10 lot stop order. However if the entry order is partially filled, I then place the stop order with the partially filled quantity and amend it with every fill coming in in the OnExecution method. That seems to work just fine.

    What I want to do is write a method (lets call it CheckStops) that essentially goes through and 'matches' my entries with my placed stops - for quantity and to ensure that the stops are in fact placed (working or accepted). I call this method within OnBarUpdate with COBC=false. This is because my strategy is tick based and I want to ensure at all times that my entries have the properly placed stops for the entries. Under normal circumstances this is no problem. However once the stop gets partially filled, my STOP's quantity will be not equal to the entry's quantity (I guess I can check if the STOP is partially filled and then check the filled+quantity maybe) to determine if it adds up to it's entry.

    However the trickier portion of this is to check the OrderState of the STOP orders. Essentially I'll be checking for whether the STOP is working, accepted, partially filled or filled. The problem is that because of the asynchronous nature of getting fills (of the STOPs) and checking quantities, my per-tick check seems to be insufficient.

    In psuedocode this is what I'm doing in CheckStops():

    //assume entryOrder and stopOrder are my C# Dictionaries
    //assume my entry orders are named entry1, entry2, etc
    //assume my stop orders are named entry1Stop, entry2Stop, etc

    foreach entryKey in entryOrder
    {
    foreach stopKey in stopOrder
    {
    if stopKey.startsWith(entryKey)
    {
    // stop Order has been found for the entry order
    // i want to make sure the quantity matches and the STOP is existent
    // UNDER ALL CIRCUMSTANCES
    }

    }
    }

    Does anyone have a "trick" or some code I can look at that does this?
    I'm using Unmanaged = true.

    thanks!

    #2
    jonmoron, havw you considered checking the status in OnOrderUpdate()?

    Comment


      #3
      Bertrand,

      Im not sure you understand the purpose behind this method. I want to check my stop order's presence at every tick and make sure the proper quantity is placed and working for my position.

      This is why I call CheckStops() in OnBarUpdate. I was looking for a nice algo that would satify my needs.

      thanks

      Comment


        #4
        Perhaps not, but what I understood is you looked for a way to access the different orderstates (partials) your stops would go through, this can be done in the OnOrderUpdate() for your strategy, as it would be called for each orderstate change.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X