Hello!
Please see the triggers attached. Use the constants to adjust the settings of the triggers.
Note that cancelling the bets right before the off and changing their persistence to "take SP" is worse than placing the bets with the "take at SP" persistence right from the start. Both achieve your goals of matching the unmatched bets at SP after the off, but cancelling the bets and re-placing them removes them from the matching queue and decreases their chances of getting matched at better prices. I set the bets to be taken at SP from the start, but if you insist on cancelling them and placing at new lay prices, let me know.
Make sure you have tested the triggers in Test Mode.