Strategy vault / Mean reversion
RSI Divergence Reversal Strategy
This strategy is a reversal strategy based on the RSI indicator. It calculates two RSI lines with different lookback periods and enters long or short trades when the two RSI lines cross over.
Overview
This strategy is a reversal strategy based on the RSI indicator. It calculates two RSI lines with different lookback periods and enters long or short trades when the two RSI lines cross over.
Strategy Logic
Calculate two RSI lines, one with shorter period and one with longer period.
When the shorter period RSI crosses above the longer period RSI, determine a bullish signal for going long.
When the shorter period RSI crosses below the longer period RSI, determine a bearish signal for going short.
When going long, set stop loss at the latest price.
When going short, set stop loss at the latest price.
If price hits stop loss, exit the current position.
Advantages
Using RSI to identify potential reversal points is reasonably reliable.
Dual RSI crossover filters out some false signals.
Stop loss controls risk for each position.
Simple and intuitive logic, easy to implement.
Customizable RSI parameters suit different markets.
Risks
RSI lag may miss reversal timing of sudden trend changes.
Improper stop loss setting may cause unnecessary losses.
Dual RSI cannot fully avoid false breakout risks.
Risk 1 can be mitigated by combining indicators like Bollinger Bands.
Risk 2 can be improved via trailing or pending order stops.
Risk 3 can be reduced by adding trend filters.
Enhancement Opportunities
Test effectiveness of different RSI period combinations.
Evaluate combining with indicators like MACD, KD etc.
Add stop loss techniques like trailing stops or pending orders.
Add trend filter to avoid trading reversals.
Assess performance across different products and timeframes.
Conclusion
This strategy executes simple reversal trades using RSI divergences. Dual RSI and stops control risks. Further improvements can be made through combining indicators, optimizing stops and more.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 25 | length1 |
| v_input_2 | 100 | length2 |
Source Pine Script
/*backtest
start: 2023-08-18 00:00:00
end: 2023-09-17 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI cross Strategy by alireza v1.1.1", overlay=true)
length1 = input( 25 )
length2 = input( 100 )
price = close
vrsi1 = ta.rsi(price, length1)
vrsi2 = ta.rsi(price, length2)
GC = (close > open)
RC = (open > close)
HH = (close > close[2])
LL = (close < close[2])
cu = ta.crossover(vrsi1, vrsi2)
cd = ta.crossunder(vrsi1, vrsi2)
if (not na(vrsi1))
if (cu)
sll=price
strategy.entry("BUY", strategy.long )
strategy.exit("SL" , limit = sll )
if (cd)
sls=price
strategy.entry("SELL", strategy.short )
strategy.exit("SL" , limit = sls )
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-18. 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/RSI-Divergence-Reversal-Strategy.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 15 Minute Chart Trading Signal StrategyPine Script · Mean reversion · 3h
- Momentum Reversal Trend Tracking StrategyPine Script · Mean reversion
- Quantitative Trading Strategy Based on Bollinger Bands and RSIPine Script · Mean reversion · 1h
- RSI Fibonacci Retracement StrategyPine Script · Mean reversion · 1d
- CCTBBO Reversal Tracking StrategyPine Script · Mean reversion · 45m
- Multi Timeframe Gold Reversal Tracking StrategyPine Script · Mean reversion · 2h