¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Merging stop loss orders


 

Hi everyone,

I am currently writing an application that allows me to issue orders with attached stop loss as bracket order. I am using it to issue multiple adds for winning trades. My question is:

Let's say I've added at 100,- with a stop loss at 99,- and I make another add at 105 with a stop loss at 104,-. I now have two stop loss orders, one at 99 and one at 104. If I wanted to mergen them into a single stop loss order at 104, what would be the best/safest way to do this in your opinion?

Thanks a lot in advance.


Nick
 

¿ªÔÆÌåÓý

Changing the stop price from 99 to 104 would be the safest but would leave you with two orders.

Since there are two different oca's I don't think there is a way to prevent a window where you are either unprotected or vulnerable to an overfill.


On 5/20/2021 8:39 PM, Jan Raddatz wrote:

Hi everyone,

I am currently writing an application that allows me to issue orders with attached stop loss as bracket order. I am using it to issue multiple adds for winning trades. My question is:

Let's say I've added at 100,- with a stop loss at 99,- and I make another add at 105 with a stop loss at 104,-. I now have two stop loss orders, one at 99 and one at 104. If I wanted to mergen them into a single stop loss order at 104, what would be the best/safest way to do this in your opinion?

Thanks a lot in advance.


 

¿ªÔÆÌåÓý

[I see Nick has beaten me to it, so consider this as an amplification of his much more concise comment.]

?

The safest way, and by far the simplest, is surely to simply keep two stop-loss orders and adjust their prices to be the same. But presumably you don't want to do that because you end up paying two commissions if the stop-loss is hit.

?

Any other approach necessarily involves a period of time where you either have too much or too little stop loss protection.

?

But I think I would favour something like this:

?

  1. Create a new 'emergency' stop-loss for the full amount at a price some distance below your lower existing stop-loss. (How far?
  2. Cancel the existing stop-loss orders.
  3. If you receive a fill for the higher existing order before its cancel status notification arrives, immediately amend the emergency stop-loss size accordingly.
  4. If you receive a fill for the lower existing order before its cancel status notification arrives, immediately cancel the emergency stop-loss.
  5. As soon as you receive the cancel status notification for the lower existing order (ie step 4 hasn't occurred), immediately update the emergency stop-loss price to your desired price.
  6. If step 4 has occurred, you might possibly get a fill for the 'emergency' stop loss before its ?cancel has taken effect. You'd have to be pretty unlucky for this to happen, especially if you priced it low enough initially. But in a 'flash crash' scenario it would be possible, and you'd end up with your original position either partly or fully reversed, depending on the exact sequence of events.

?

This sort of approach, I think, minimises the period of time during which you might end up with an unprotected ?position. ?But you really need to draw up a set of timelines showing every possible event and every sequence they can occur in, to analyse whether it's really providing much benefit.

?

Through all of this you also have to bear in mind that IB doesn't guarantee that stop orders will get filled at all, though the circumstances where they don't are presumably rare and unlikely. ?There is a residual risk in trading that you simply can't get rid of.

?

All things considered, I'd strongly recommend just sticking with the separate stop-loss orders and adjusting them as appropriate. IB's commissions are pretty reasonable, and the logic above is much more complex.

?

Richard

?

?

?

From: [email protected] <[email protected]> On Behalf Of Jan Raddatz
Sent: 21 May 2021 01:40
To: [email protected]
Subject: [TWS API] Merging stop loss orders

?

Hi everyone,

?

I am currently writing an application that allows me to issue orders with attached stop loss as bracket order. I am using it to issue multiple adds for winning trades. My question is:

?

Let's say I've added at 100,- with a stop loss at 99,- and I make another add at 105 with a stop loss at 104,-. I now have two stop loss orders, one at 99 and one at 104. If I wanted to mergen them into a single stop loss order at 104, what would be the best/safest way to do this in your opinion?

?

Thanks a lot in advance.


 

Thank you very much guys. I think you are right. I also don't want to be exposed with no stop loss or too much as mentioned in your posts.
I will stick with two individual stop loss orders then. Thanks again.