基于RSI指标的双重超买超卖策略


创建日期: 2023-09-13 16:58:55 最后修改: 2023-09-13 16:58:55
复制: 0 点击次数: 556
avatar of ChaoZhang ChaoZhang
1
关注
1362
关注者

本策略名称为“基于RSI指标的双重超买超卖策略”。该策略同时运用RSI指标和Stoch RSI指标判断超买超卖情况,实现更可靠的交易信号。

RSI指标反映价格的超买超卖水平。RSI高于70表示超买,低于30表示超卖。Stoch RSI指标看RSI指标自身是否进入超买或超卖状态。

本策略的交易逻辑:

当RSI指标上穿用户设定的超买线时,表示入局超买,考虑做空;

当RSI指标下穿用户设定的超卖线时,表示入局超卖,考虑做多;

同时,Stoch RSI也必须显示超买或超卖信号时,才确认对应的入场信号。

该双重条件组合,可以过滤更多不确定信号,避免假突破。

本策略优点是利用RSI的各种派生指标,更准确判断超买超卖区域。但需注意过优化带来的曲线拟合风险。止损策略也必不可少。

总体而言,指标组合使用需要谨慎权衡。合理使用可以提高效果,但也可能带来过度优化的风险。交易者仍需保持判断的灵活性。

策略源码
/*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 ="超买")
plot(lower,color = color.blue,linewidth = 2, title ="超卖")
plot(rsi,color = rsi>upper ?color.red:rsi<lower? color.green:color.black, linewidth=2,title ="ris超买超卖")
plot(stochastic,color = color.purple,title="震荡指数")
plot(SMA, color = color.orange,title="移动平均")

//trading
shortposition = crossover(rsi,upper)
longposition = crossunder(rsi,lower)
strategy.entry("卖",false,when =(shortposition))
strategy.entry("买",true,when = (longposition))
strategy.exit("止盈",profit = close*0.013/syminfo.mintick)