Quote from TheGoonior:
Don't think you can do it on the standard TWS. It seems like they continue to think about adding a custom indicator to their triggers, but I haven't seen it implemented yet.
The actual exit at 20 SMA and placing orders is not difficult in TWS. How much monitoring you want to have in place will dictate how big your coding effort is (i.e: you leave for a month and let it run adds much more work as opposed to you sitting in the next room).
Remember that you'll be at the mercy of your internet connection when implementing this exit, since this logic isn't on the TWS server side. With something like this, I'd have a stop order placed at TWS that you modify once your condition is met. This way you'll already have a "Get Out Of Dodge" order on the TWS side in the event your system drops out.