Need Code for this Strategy with RSI and ATR

Need Code for this and please some backtest it and post the result

Basic set up : 5 Minute NIFTY FUTURES Chart with 1 day backfill.
RSI : 7 period RSI below price chart (Signal line not required) with 75 (overbought) and 25(oversold) lines.
ATR : A 10 period ATR for stop loss.
Risk-Reward 1:1 or Follow trailing stop loss method.

BUY Signal  After a sharp sell off, when market enters oversold zone (i.e. RSI below 25 reading), stay tight & ready (BUT DO NOT ENTER in to the TRADE right now). I have seen RSI falling to single digit. Once Market is coming out of oversold on candle close basis (do not trade while candle is still forming), Buy above high of that candle after adding 2 points as filter. Stop loss will be 2x ATR . (if ATR is 8 then stop loss will be of 16 points) if 2x ATR is more then days low, you can keep stop loss as days low to save some bucks. Target will be at least 16 points. You can ride on with trailing stop loss method you chose to follow.

SELL Signal  same way, after a sharp rally, when market exits overbought zone (75 reading) on closing basis, go short below low of closing candle (after deducting 2 filter points) with 2x ATR stop loss (or days high) for 1:1 Risk reward or trail your stop loss according to your own method.

For the above condition

Buy script:


Sell Script:


for stoploss it is not possible to define ATR with respect to points