Hi
Probably several ways to address this.
In the Stop-Loss settings you can automatically match unmatched bets under certain criteria.
Or use a trigger action: match unmatched back bets or match unmatched lay bets. This will give you better control than the settings option above. For example use a condition to trigger this x seconds after tradeout trigger fired.
Or use a back or lay trigger (whichever is appropriate for your tradeout) but set the price x ticks above or below current tradeout price.
If opening bet is back and want to trade out with a lay set the price for the lay bet as r_ticks(lay_price, x)
If opening bet is lay and want to trade out with a back set the price for the back as r_ticks(back_price, -x)
e.g. lay at r_ticks(lay_price, 6) will send a lay bet 6 ticks higher than current best lay price. Betfair will match it at best available lay price.
Or use a back or lay trigger as appropriate to trade out and use "best" in the price field. Betfair will match at best available price.