Strategies
基于RSI均值回归的交易策略RSI-Average-Reversion-Trading-Strategy
ChaoZhang · PineScript · Mean Reversion · 2023-09-20 15:38:45
Filter
Sizing
—
Risk control
Exit
—
Overview
This strategy uses RSI average based on multiple price inputs to determine overbought/oversold and trades mean-reversion.
Principle
- Calculate RSI values based on close, open, high etc.
- Take arithmetic average of the RSI values to derive RSI mean.
- RSI mean above 0.5 indicates overbought, below 0.5 oversold.
- RSI mean reversion to the 0.5 midpoint generates trading signals.
- Set RSI mean exit thresholds, like close long above 0.65, close short below 0.35.
- Simple and clear trading logic easy to implement.
Advantages
- RSI mean improves stability using multiple price inputs.
- Trading signals from RSI mean reversion, combining trend and reversal.
- Intuitive RSI mean curve forms clear visual trading signals.
- Default parameters simple and practical for mean reversion.
- Concise code easy to understand and modify for beginners.
Risks
- RSI prone to false reversal signals resulting in losses.
- Inappropriate RSI parameters and threshold setups affect performance.
- Relying solely on single RSI indicator leads to higher systematic risk.
- Unable to confirm price reversal sustaining power.
- Trending markets tend to produce losses.
Optimization
- Test and optimize RSI period for higher sensitivity.
- Evaluate price input impacts on RSI mean.
- Add trend filter to avoid counter-trend trades.
- Incorporate other factors to confirm reversal signals.
- Build dynamic stops mechanism for risk control.
- Optimize entry, stop loss, take profit for higher efficiency.
Summary
This strategy trades RSI mean reversion simply and viably for beginners. But risks include signal errors and trends exist. Multi-factor optimization and risk management improvements can make the strategy more robust and efficient as a reliable reversal system. [/trans]
Parameters
| Parameters | Default | Description |
|---|---|---|
| v_input_float_1 | 0.65 | v_input_float_1 |
| v_input_float_2 | 0.35 | v_input_float_2 |
| v_input_bool_1 | true | (?Entries Type)Allow Long entries |
| v_input_bool_2 | true | Allow Short entries |
Source code (44 lines)
/*backtest
start: 2022-09-13 00:00:00
end: 2023-09-19 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © exlux99
//@version=5
strategy("RSI Average Swing Bot")
long_only=input.bool(true, title="Allow Long entries", group="Entries Type")
short_only=input.bool(true, title="Allow Short entries", group="Entries Type")
rsiohlc4= ta.rsi(ohlc4,50)/100
rsiclose= ta.rsi(close,50)/100
rsiopen= ta.rsi(open,50)/100
rsihigh= ta.rsi(high,50)/100
rsihlc3= ta.rsi(hlc3,50)/100
rsihl2= ta.rsi(hl2,50)/100
hline(0.3, color=color.white, linestyle=hline.style_dashed, linewidth=2)
hline(0.5, color=color.white, linestyle=hline.style_dotted, linewidth=2)
hline(0.7, color=color.white, linestyle=hline.style_dashed, linewidth=2)
rsi_avg = (rsiohlc4+rsiclose+rsiopen+rsihigh+rsihl2+rsihlc3)/6
culoare = rsi_avg > 0.50? color.green : rsi_avg<0.50 ? color.red : color.yellow
plot(rsi_avg,color=culoare )
long = rsi_avg > 0.5 and rsi_avg[1]< 0.5
longexit = rsi_avg >= input.float(0.65, step=0.05)
short = rsi_avg < 0.5 and rsi_avg[1] >0.5
shortexit=rsi_avg<=input.float(0.35, step=0.05)
if(long_only)
strategy.entry("long",strategy.long,when=long)
strategy.close("long",when=longexit or short)
if(short_only)
strategy.entry("short",strategy.short,when=short)
strategy.close("short",when=shortexit or long)