Here is a little Excel spreadsheet that uses the TWS DDE link to submit a set or orders based on what has been discussed on this thread.
All this thing does is submit a set of 5 orders. You enter the price and click the right button. It will submit the following (for example, on a LONG 1 ES @ 900):
1. BUY 1 LIMIT 900 (transmitted)
2. SELL 1 LIMIT 901 and SELL 2 STOP 898.75 (not transmitted and linked together via OCA group quahESEXIT)
3. BUY 1 LIMIT 897.50 and BUY 1 STOP 900 (not transmitted and linked together via OCA group quahESREVERSE)
If you change your TWS layout to include a column for OCA, it will make it much easier to identify which order is what. The original entry order transmits on submission. Once that is filled, you can then transmit the "quahESEXIT" pair - when one of those fills, the other will be cancelled because of the OCA. If it was the stop that filled, you would then transmit the "quahESREVERSE" pair. If no reversal was required, you simply cancel that pair.
This is not intended to be some fancy order entry and tracking system - just a very simple and VERY crude method of getting the orders into TWS. They can be managed from TWS from that point.
Disclaimer - Everything I said above may or may not actually work in this spreadsheet - use at your own risk and it is for educational purposes only as a simple sample of how DDE works with TWS. Don't mess with the spreadsheet columns/positions - the cells are hard coded in the VBA code.
http://home.carolina.rr.com/quah/QuahOrder.xls
(editted to add: This will NOT WORK properly if the previous position is still open)