Short straddle code on sl

How to create code for short straddle if one leg SL hitted then the other leg should exit when the moving average cross take place eg 5ema with 9sma in 5 minutes of the traded instrument?