if any one order gets executed, the other order has to be canelled. for example if HDFC executes, it has to cancel order for ICICI. My suggestion is, you may provide option to enter the order number(Which needs to be cancelled upon execution of this order) in buy/sell window. For example,I am placing a limit buy order for X. While creating it, some number needs to be allotted for this order. Say 123. I create another limit order for Y. its order no is 124. in buy/sell window of 123, there shall be an option to cancel 124 if 123 is executed. BO and CO will work only for same script. but this has to work for any script. if target hits, it may cancel SL order like CO/BO. if one leg option is executed, the other leg option shall be executed at market price.