Strategy vault / Trend following
Dynamic Trend Following Strategy Based on Relative Strength and RSI
This strategy is a trend following system based on Supertrend, Relative Strength (RS), and Relative Strength Index (RSI). By integrating these three technical indicators, it enters trades when market trends are clear…

Overview
This strategy is a trend following system based on Supertrend, Relative Strength (RS), and Relative Strength Index (RSI). By integrating these three technical indicators, it enters trades when market trends are clear and implements dynamic stop-loss for risk management. The strategy primarily aims to capture strong upward price trends while using RSI to confirm trend sustainability.
Strategy Principles
The strategy employs a triple-filtering mechanism for trade signals:
- Uses Supertrend indicator to determine overall trend, considering uptrend when indicator direction is up.
- Calculates Relative Strength (RS) value, percentizing price position within high-low range over 55 periods to measure price strength.
- Utilizes RSI to judge overbought/oversold conditions, confirming upward momentum when RSI exceeds 60. Trade entry requires simultaneous satisfaction of all three conditions: Supertrend up, RS above 0, and RSI above threshold. Exit occurs when any two indicators signal reversal. A fixed 1.1% stop-loss manages risk.
Strategy Advantages
- Multiple technical indicators confirmation enhances signal reliability.
- Supertrend effectively tracks trends, reducing false signals in choppy markets.
- RS indicator captures price strength changes promptly, improving entry timing accuracy.
- RSI confirms trend momentum, avoiding entries during trend exhaustion.
- Fixed stop-loss sets clear risk control boundaries.
- Flexible exit conditions respond promptly to market changes.
Strategy Risks
- Multiple indicators may cause signal lag, missing optimal entry points.
- Frequent trading in choppy markets may increase transaction costs.
- Fixed stop-loss might trigger easily in highly volatile markets.
- RSI may remain in overbought territory during strong trends, missing opportunities.
- Multiple exit conditions might lead to premature profit taking.
Strategy Optimization Directions
- Introduce adaptive indicator parameters adjusting dynamically with market volatility.
- Add volume indicators for signal confirmation enhancement.
- Design dynamic stop-loss mechanism based on ATR values.
- Optimize RSI thresholds, considering different values for various market conditions.
- Add trend strength filtering to reduce trading frequency in weak trends.
- Consider implementing trailing stop-profit mechanism for better profit retention.
Summary
The strategy constructs a relatively comprehensive trend following trading system by integrating Supertrend, RS, and RSI indicators. Its main advantage lies in the multiple signal confirmation mechanism enhancing trade reliability, while clear risk control mechanisms provide trading safeguards. Despite potential risks, suggested optimization directions can further improve strategy stability and profitability. This strategy is particularly suitable for markets with clear trends and can serve as a foundation framework for medium to long-term trading.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-04 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Sanjay RS&RSI Strategy V3 for nifty 15min, SL-1.3", overlay=true)
// Inputs
atrLength = input.int(10, title="ATR Length")
factor = input.float(3.0, title="ATR Multiplier")
rsPeriod = input.int(55, title="RS Period")
rsiPeriod = input.int(14, title="RSI Period")
rsiThreshold = input.float(60, title="RSI Threshold")
stopLossPercent = input.float(2.0, title="Stop Loss (%)", step=0.1) // Adjustable Stop Loss in Percentage
// Supertrend Calculation
[supertrendDirection, supertrend] = ta.supertrend(factor, atrLength)
// RS Calculation
rs = (close - ta.lowest(close, rsPeriod)) / (ta.highest(close, rsPeriod) - ta.lowest(close, rsPeriod)) * 100
// RSI Calculation
rsi = ta.rsi(close, rsiPeriod)
// Entry Conditions
buyCondition = (supertrendDirection > 0) and (rs > 0) and (rsi > rsiThreshold)
// Exit Conditions
exitCondition1 = (supertrendDirection < 0)
exitCondition2 = (rs <= 0)
exitCondition3 = (rsi < rsiThreshold)
exitCondition = (exitCondition1 and exitCondition2) or (exitCondition1 and exitCondition3) or (exitCondition2 and exitCondition3)
// Plot Supertrend
plot(supertrend, title="Supertrend", color=supertrendDirection > 0 ? color.green : color.red, linewidth=2)
// Strategy Entry
if (buyCondition)
strategy.entry("Buy", strategy.long)
// Add Stop Loss with strategy.exit
stopLossLevel = strategy.position_avg_price * (1 - stopLossPercent / 100)
strategy.exit("SL Exit", from_entry="Buy", stop=stopLossLevel)
// Strategy Exit (Additional Conditions)
if (exitCondition)
strategy.close("Buy")
Published by ChaoZhang on the FMZ strategy square · last modified 2025-01-06. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Dynamic-Trend-Following-Strategy-Based-on-Relative-Strength-and-RSI.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Advanced Supertrend Indicator Trading Mechanism Optimization StrategyPine Script · Trend following · 1d
- Supertrend Advance StrategyPine Script · Trend following · 5m
- Supertrend and Moving Average Crossover StrategyPine Script · Trend following · 2h
- Trend Tracking and Short term Trading Strategy Based on ADX IndicatorPine Script · Trend following · 1d
- Advanced Quantitative Trading Strategy Multi Dimensional Super Trend ATR Dynamic Tracking SystemPine Script · Trend following · 1h
- Dual Timeframe Supertrend with RSI Optimization SystemPine Script · Trend following · 1h