Buy stop Sell stop script

 
I'm looking for a script that will

Take the High (buy stop script) or the low (Sell Stop Script) of the previous candle.

Buy Stop script
When the price breaks to the high side 3 pips above the trigger candle's high a stop is placed 5 pips below the low of the same candle. Now this is the previous candle

Sell Stop Script
When the price breaks to the low side 3 pips below the trigger candles low a stop is placed 5 pips above the high of the same candle. now this is the previous candle

Reason: