When the price closes above the 20 SMA high and RSI is greater than 60. The stop loss can be taken as the 20 SMA low.
When the price closes below the 20 SMA low and RSI is less than 40. The stop loss can be taken as the 20 SMA high.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.