Stoploss and profit booking scripts for expert adviser

HI

How to set the SCRIPT FOR BACKTEST exit long position when

close is 100 points LOWER OR 300 points HIGHER than buy signal

similareLY

exit short when close is 100 points HIGHER OR 300 points LOWER than sell signal

IN SHORT SETTING 1:3 AS RISK REWARD

Thanks

you can do it manually by price alert indicator, https://zerodha.com/expert-advisors/code/price-alert-indicator

Yes it can be done while trade is on
but my question is whether this condition can be incorporated while backtesting using script say for exit long close<buyprice -100 or close> buyprice + 300