This strategy identifies potential buy and sell opportunities in the market by calculating the Relative Strength Index (RSI). It utilizes the RSI indicator to spot points where price may reverse from a trend to a counter-trend, in order to capture reversal opportunities. Trading signals are generated when the RSI reverses from overbought or oversold territories.
The core indicator of this strategy is RSI. It shows the ratio of upward price closes to downward price closes over a period of time, used to judge if an asset is overvalued or undervalued. RSI fluctuates between 0 to 100, with high values indicating a strong upward market and low values indicating a strong downward market.
The strategy first sets the parameters for RSI, including period length (default 14) and threshold values for overbought/oversold territories (default 70/30). It then calculates the RSI value based on closing prices. Buy signals are generated when RSI crosses above the oversold threshold, and sell signals when RSI crosses below the overbought threshold.
The strategy also plots the RSI line, as well as the threshold lines. Buy and sell signals are marked on the price chart with text and shapes. Additionally, the percentage change since the last signal is calculated and plotted to give traders an intuitive view of post-signal price moves.
This strategy is designed based on the reversal trading logic of RSI, mainly judging if assets are significantly overbought or oversold in the short-term, in order to capture subsequent reversals. The percentage change calculation and visual trading prompts can aid in trading decisions. RSI parameters can be customized based on user preferences. Combining with other indicators to improve signal reliability and proper optimizations to reduce fake signals are future enhancement directions for this strategy.
/*backtest start: 2023-01-19 00:00:00 end: 2024-01-25 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Improved RSI Strategy", overlay=true) // Define RSI parameters rsiLength = input(14, title="RSI Length") rsiOversold = input(30, title="Oversold Threshold") rsiOverbought = input(70, title="Overbought Threshold") // Calculate RSI rsiValue = ta.rsi(close, rsiLength) // Define entry conditions longCondition = ta.crossover(rsiValue, rsiOversold) shortCondition = ta.crossunder(rsiValue, rsiOverbought) // Plot RSI and thresholds plot(rsiValue, title="RSI", color=color.blue) hline(rsiOversold, title="Oversold Threshold", color=color.red) hline(rsiOverbought, title="Overbought Threshold", color=color.green) // Calculate percentage change since last signal var float percentageChange = na lastCloseValue = ta.valuewhen(longCondition or shortCondition, close, 1) if longCondition or shortCondition percentageChange := (close - lastCloseValue) / lastCloseValue * 100 plot(percentageChange, color=color.blue, style=plot.style_histogram, linewidth=1, title="% Change since last signal") // Execute strategy if longCondition strategy.entry("RSI Long", strategy.long) if shortCondition strategy.entry("RSI Short", strategy.short) // Plot shapes and text for buy/sell signals plotshape(series=longCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY") plotshape(series=shortCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")