The more conventional solution: Just exit the current trade at limit, then open the new one. As you would also do in manual trading.