This strategy builds a trading system using RSI indicator to determine overbought and oversold levels, together with dynamic trailing stop loss and profit target exit. It goes short when RSI crosses above overbought level and goes long when RSI crosses below oversold level. Trailing stop loss and profit target exit are used to close positions.
This strategy uses 14-period RSI indicator to judge market technical patterns. RSI reflects the ratio of rising and falling power over a period of time, to tell if the market is overbought or oversold. The RSI length here is 14. When RSI crosses above 70, the market is considered overbought, and we go short. When RSI crosses below 30, the market is considered oversold, and we go long.
In addition, this strategy uses dynamic trailing stop loss mechanism. When holding long position, trailing stop price is set at 97% of closing price. When holding short position, trailing stop price is 103% of closing price. This locks in most profits while avoiding being stopped out by market noise.
Finally, this strategy uses profit target exit. When position profit reaches 20%, it will be closed. This locks in some profits and avoids profit retracement.
The advantages of this strategy include:
Some risks of this strategy to note:
To cope with these risks, optimizing RSI parameters, adjusting stop loss percentage, relaxing profit target requirements reasonably can help.
Some directions to optimize the strategy:
The strategy has clear logic of using RSI to determine overbought/oversold market, with dynamic stops and profit taking. Its pros are easy understanding and implementation, good risk control, and high extensibility. Next step is to enhance signal quality, auto-tune parameters etc to make strategy more intelligent.
/*backtest start: 2024-01-04 00:00:00 end: 2024-02-03 00:00:00 period: 4h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Modified RSI-Based Trading Strategy", overlay=true) // RSI settings rsiLength = input(14, title="RSI Length") overboughtLevel = 70 oversoldLevel = 30 // User-defined parameters trailingStopPercentage = input(3, title="Trailing Stop Percentage (%)") profitTargetPercentage = input(20, title="Profit Target Percentage (%)") rsiValue = ta.rsi(close, rsiLength) var float trailingStopLevel = na var float profitTargetLevel = na // Entry criteria enterLong = ta.crossover(rsiValue, oversoldLevel) enterShort = ta.crossunder(rsiValue, overboughtLevel) // Exit criteria exitLong = ta.crossover(rsiValue, overboughtLevel) exitShort = ta.crossunder(rsiValue, oversoldLevel) // Trailing stop calculation if (strategy.position_size > 0) trailingStopLevel := close * (1 - trailingStopPercentage / 100) if (strategy.position_size < 0) trailingStopLevel := close * (1 + trailingStopPercentage / 100) // Execute the strategy if (enterLong) strategy.entry("Buy", strategy.long) if (exitLong or ta.crossover(close, trailingStopLevel) or ta.change(close) > profitTargetPercentage / 100) strategy.close("Buy") if (enterShort) strategy.entry("Sell", strategy.short) if (exitShort or ta.crossunder(close, trailingStopLevel) or ta.change(close) < -profitTargetPercentage / 100) strategy.close("Sell") // Plot RSI and overbought/oversold levels plot(rsiValue, title="RSI", color=color.blue) hline(overboughtLevel, "Overbought", color=color.red, linestyle=hline.style_dashed) hline(oversoldLevel, "Oversold", color=color.green, linestyle=hline.style_dashed)