Strategy vault / Mean reversion
Dual Overbought Oversold Strategy Based on RSI Indicator
This strategy is named "Dual Overbought/Oversold Strategy Based on RSI Indicator". It uses both the RSI indicator and the Stoch RSI indicator to determine overbought and oversold conditions for more reliable trade…
This strategy is named "Dual Overbought/Oversold Strategy Based on RSI Indicator". It uses both the RSI indicator and the Stoch RSI indicator to determine overbought and oversold conditions for more reliable trade signals.
The RSI indicator reflects overbought/oversold levels in prices. RSI above 70 suggests overbought state, while below 30 is oversold. The Stoch RSI indicator shows if the RSI itself has entered overbought or oversold zones.
The trading logic is:
When RSI crosses above the user-defined overbought line, it signals overbought conditions for considering short trades.
When RSI falls below the user-defined oversold line, it flags oversold conditions for considering long trades.
Meanwhile, Stoch RSI also needs to show overbought or oversold signals to confirm the corresponding entry signals.
This dual condition combines to filter more ambiguous signals and avoid false breakouts.
The advantage of this strategy is utilizing RSI's various derived indicators for more accurate overbought/oversold range judgment. But optimization overfitting risks should be noted. Stop loss is also indispensable.
In summary, indicator combinations need careful balancing. Reasonable usage can improve results but may also bring overoptimization risks. Traders still need flexible judgment.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 14 | k length |
| v_input_2 | 3 | d length |
| v_input_3 | 5 | RSI |
| v_input_4 | 80 | over brought |
| v_input_5 | 20 | over sold |
Source Pine Script
/*backtest
start: 2023-01-01 00:00:00
end: 2023-09-12 00:00:00
period: 4d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("test1","t1",overlay=true, default_qty_type = strategy.percent_of_equity,default_qty_value=100,initial_capital=200, currency=currency.USD)
//user input
k_param = input(title = "k length", type = input.integer, defval = 14)
d_param = input(title = "d length", type = input.integer, defval = 3)
rsi_param = input(title = "RSI", type = input.integer, defval = 5)
upper = input(title = "over brought", type = input.integer, defval = 80)
lower = input(title = "over sold", type = input.integer, defval = 20)
//calculation
rsi = rsi(close,rsi_param)
stochastic = 100*(rsi - lowest(rsi,k_param))/(highest(rsi,k_param)-lowest(rsi,k_param))
SMA = sma(stochastic,d_param)
//DRAW
plot(upper,color = color.blue,linewidth = 2, title ="Overbought")
plot(lower,color = color.blue,linewidth = 2, title ="Oversold")
plot(rsi,color = rsi>upper ?color.red:rsi<lower? color.green:color.black, linewidth=2,title ="risOverbought and Oversold")
plot(stochastic,color = color.purple,title="Volatility Index")
plot(SMA, color = color.orange,title="Moving Average")
//trading
shortposition = crossover(rsi,upper)
longposition = crossunder(rsi,lower)
strategy.entry("Sell",false,when =(shortposition))
strategy.entry("Buy",true,when = (longposition))
strategy.exit("take profit",profit = close*0.013/syminfo.mintick)Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-13. 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/Dual-Overbought-Oversold-Strategy-Based-on-RSI-Indicator.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
- Bollinger Bands Stochastic RSI Extreme Strategy BBSR Extreme StrategyPine Script · Mean reversion · 1h
- BuySell Strategy depends on AOStochRSIATRPine Script · Mean reversion · 30m
- Byron Serpent Cloud Quant StrategyPine Script · Mean reversion · 1h
- Dual Momentum Trend Reversal Strategy Based on RSI and Stochastic RSIPine Script · Mean reversion · 1h
- Dynamic Adaptive Multi Timeframe Trend Following and Range Reversal Hybrid StrategyPine Script · Mean reversion · 2d