Tags: RSIATR

The RSI Trend Reversal Strategy is a quantitative trading strategy based on the Relative Strength Index (RSI) and Average True Range (ATR). It dynamically adjusts the take profit and stop loss (TP/SL) levels to adapt to rapid market fluctuations and capture trend reversal opportunities. The strategy centers around the RSI, combined with ATR to measure volatility, and constructs two adaptive dynamic bands as the basis for opening and closing positions. This strategy can be used independently or as a take profit and stop loss module for other strategies. It has been well-tested on 15-minute data of stocks such as Tesla (TSLA), Apple (AAPL), and Nvidia (NVDA).

The core of the RSI Trend Reversal Strategy lies in the construction of dynamic TP/SL bands. First, it uses custom highest_custom and lowest_custom functions to find the highest and lowest prices since the last crossover, forming the basis of the bands. Then, it calculates the RSI and ATR with a length specified by the user and performs the following calculations:

- Lower Band = Highest Price × [1 - (ATR/Price + 1/(RSI Lower Band × multiplier))]
- Upper Band = Lowest Price × [1 + (ATR/Price + 1/(RSI Upper Band × multiplier))]

Here, multiplier is a user-defined band expansion factor. If the price breaks above the upper band, it goes long; if it breaks below the lower band, it goes short. The colors of these two bands also change according to the position of the price relative to the bands, making it easy to observe.

- High adaptability: The TP/SL bands can automatically adjust based on price volatility, promptly responding to market changes.
- Adjustable parameters: By adjusting parameters such as length and multiplier, the sensitivity of the strategy can be flexibly controlled.
- Clear logic: The code structure is reasonable and easy to understand and develop further.
- Wide applicability: It can be used independently as a strategy or add TP/SL functionality to other strategies.
- Computational efficiency: By using custom functions like highest_custom, it avoids the massive repetitive calculations caused by using series types.

- Improper parameter selection may bring additional risks. For example, a small length may lead to frequent trading, and a large multiplier may lead to overly loose stop losses.
- Performance may be poor in specific market conditions, such as frequent consolidation and false breakouts in a volatile market, which may result in more losing trades.
- The strategy itself does not have a trend judgment function and needs to be used in combination with other signals.

- Consider adding trend indicators, such as moving averages, to only trade at reversal points in the direction of the major trend.
- Optimize parameters to find the best combination of length, multiplier, etc.
- Combine with other technical indicators or market sentiment indicators to improve the accuracy of entry and exit points.
- Add position management to strictly control the risk exposure of each trade.

The RSI Trend Reversal Strategy utilizes RSI and ATR to construct adaptive bands that can dynamically adjust TP/SL points and promptly respond to market changes. The strategy has clear logic, wide applicability, and can be a powerful tool for quantitative traders. However, in practical use, attention still needs to be paid to parameter selection and risk control, and it is recommended to use it in combination with other indicator signals to improve overall performance. The strategy has further room for optimization, such as adding trend filters and parameter optimization. Overall, the RSI Trend Reversal Strategy provides a simple yet effective approach to quantitative trading.

/*backtest start: 2023-04-22 00:00:00 end: 2024-04-27 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("RSI Trend Reversal", overlay=true, max_bars_back = 4999, calc_on_every_tick = false) //INPUTS rsi_length = input.int(title = "Lenght", defval = 8) rsi_mult = input.float(title = "Multiplier", defval = 1.5, step = .05) lookback = input.int(title = "Delay to prevent idealization", defval = 1) sltp = input.float(title = "Minimum Difference", defval = 10) src = input.source(title = "Source Input", defval = close) //PARAMETERS INITILIZATION hclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, src) //FUNCTION INITILIZATION highest_custom(src, length) => x = src for i = 0 to length if src[i] > x x := src[i] x lowest_custom(src, length) => x = src for i = 0 to length if src[i] < x x := src[i] x rsilev(src, length, mult, sltp) => sl = (100 - sltp) / 100 tp = (100 + sltp) / 100 var bool crossup = na var bool crossdown = na var float dir = na dir_change = ta.change(dir) var float BearGuy = 0 BullGuy = ta.barssince(crossup or crossdown) if na(BullGuy) BearGuy += 1 else BearGuy := BullGuy var float upper = na var float lower = na rsilower = ta.rsi(src, length) rsiupper = math.abs(ta.rsi(src, length) - 100) atr = ta.atr(length) / src lower := highest_custom(math.max(highest_custom(highest_custom(src, BearGuy) * (1 - (atr + ((1 / (rsilower) * mult)))), BearGuy), src * sl), BearGuy) upper := lowest_custom(math.min(lowest_custom(lowest_custom(src, BearGuy) * (1 + (atr + ((1 / (rsiupper) * mult)))), BearGuy), src * tp), BearGuy) var float thresh = na if na(thresh) thresh := lower if na(dir) dir := 1 if crossdown dir := -1 if crossup dir := 1 if dir == 1 thresh := lower if dir == -1 thresh := upper crossup := ta.crossover(src, thresh) crossdown := ta.crossunder(src, thresh) thresh rsiclose = rsilev(hclose, rsi_length, rsi_mult, sltp) //PLOTTING var color col = color.lime if hclose > rsiclose col := color.lime if hclose < rsiclose col := color.red plot(rsiclose, linewidth = 2, color = col) //STRATEGY buy = ta.crossover(hclose, rsiclose) sell = ta.crossunder(hclose, rsiclose) if buy[lookback] strategy.entry("long", strategy.long) if sell[lookback] strategy.entry("Short", strategy.short)

- Turnaround Tuesday Strategy (Weekend Filter)
- Han Yue - Trend Following Trading Strategy Based on Multiple EMAs, ATR and RSI
- RSI50_EMA Long Only Strategy
- AlphaTradingBot Trading Strategy
- Reverse Volatility Breakout Strategy
- Multi-Indicator Trend Following Strategy
- Multi-Indicator Trend Following Dynamic Risk Management Strategy
- SPARK Dynamic Position Sizing and Dual Indicator Trading Strategy
- Enhanced EMA Crossover Strategy with RSI/MACD/ATR
- MACD Valley Detector Strategy

- GBS TOP BOTTOM Confirmed Strategy
- Multi-Indicator Trend Following Strategy
- Squeeze Backtest Transformer v2.0
- Fibonacci Trend Reversal Strategy
- HTF Zigzag Path Strategy
- WaveTrend Cross LazyBear Strategy
- CCI, DMI, and MACD Hybrid Long-Short Strategy
- AlphaTradingBot Trading Strategy
- Vegas SuperTrend Enhanced Strategy
- Quantitative Trading Strategy Based on Modified Hull Moving Average and Ichimoku Kinko Hyo
- Stochastic Crossover Indicator Momentum Trading Strategy
- RSI and Dual EMA Crossover Signal Quantitative Strategy
- Elliott Wave Theory 4-9 Impulse Wave Automatic Detection Trading Strategy
- Stochastic Oscillator and Moving Average Crossover Strategy with Stop Loss and Stochastic Filter
- Intraday Scalable Volatility Trading Strategy
- KRK aDa Stochastic Slow Mean Reversion Strategy with AI Enhancements
- Real-time Trendline Trading Based on Pivot Points and Slope
- EMA23/EMA50 Double Moving Average Crossover Quantitative Trading Strategy
- Trend-Capturing Strategy with Horizontal Line Breakout
- Moving Average Crossover with Multiple Take Profits Strategy