I'm back-testing and RSI(6) strategy. I want it to buy on the SECOND CROSSING of the 30 oversold line(When it is going back up) and Sell on the SECOND CROSSING of the 70 oversold line(when it is going down). I can only get it to buy and sell when it immediately crosses the overbought/oversold line which is not why I'm trying to do. I'm also trying to add a 10% stop loss. Does anyone have any ideas how to implement those orders? This is my code so far.
strategy("RSI", overlay = true)
longcon = rsi(close, 6) < 30
closecon = rsi(close,6) > 70
//backtest from 2015
_year = 2015
strategy.entry("long", strategy.long, when = longcon and year >= _year)
strategy.close("long", when = closecon)
plot(close)
