RSI区间突破策略是一种典型的趋势跟踪策略。它使用相对强弱指数(RSI)作为主要的技术指标,在RSI处于超买或超卖状态时,寻找突破进入区间的机会建立仓位,实现跟踪趋势运行的目的。
该策略主要依靠RSI指标判断市场的超买超卖状态。RSI指标的计算公式是:RSI=(上涨平均数值/上涨平均数值+下跌平均数值)×100。其中,上涨平均数值是过去N天内收盘涨幅的简单移动平均,下跌平均数值是过去N天内收盘跌幅的简单移动平均。
当RSI大于设定的超买线(默认80)时,表示市场处于超买状态;当RSI小于设定的超卖区间(默认35)时,表示市场处于超卖区间。策略在RSI向下突破超买线时寻找做空机会;在RSI向上突破超卖区间时,寻找做多机会。
具体来说,策略通过两个SMA均线判断RSI指标的趋势。当快线从下向上突破慢线,同时RSI突破超卖区间时,做多;当快线从上向下突破慢线,同时RSI突破超买线时,做空。策略还设定了止损线和止盈线来控制风险。
RSI区间突破策略整体来说是一个典型的趋势跟踪策略。它通过RSI指标判断买卖点,双SMA平均线过滤信号,并设定止损止盈来控制风险。但RSI指标存在滞后性问题,此外参数设置不当也会影响策略表现。通过进一步优化,可充分发挥该策略的趋势跟踪能力。
/*backtest start: 2023-09-10 00:00:00 end: 2023-10-10 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 //strategy("Strategy RSI | Fadior", shorttitle="Strategy RSI", pyramiding=10, calc_on_order_fills=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, currency="USD", default_qty_value=100, overlay=false) len = input(3, minval=1, title="RSI Length") threshLow = input(title="Treshold Low", defval=35) threshHigh = input(title="Treshold High", defval=80) rsiLength1 = input(title="RSI Smoothing 1", defval=3) rsiLength2 = input(title="RSI Smoothing 2", defval=5) SL = input(title="Stop loss %", type=float, defval=.026, step=.001) TP = input( defval=300) // 3 40 70 2 // 14 40 70 2 16 0.05 50 src = close up = rma(max(change(src), 0), len) down = rma(-min(change(src), 0), len) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) plot(sma(rsi,rsiLength2), color=orange) plot(sma(rsi,rsiLength1), color=green) band1 = hline(threshHigh) band0 = hline(threshLow) fill(band1, band0, color=purple, transp=90) strategy = input(type=bool, title="Long only ?", defval=true) strategy.risk.allow_entry_in(strategy ? strategy.direction.long : strategy.direction.all) longCondition = sma(rsi,rsiLength1) < threshLow and sma(rsi,rsiLength2) > sma(rsi,rsiLength2)[1] if (longCondition) strategy.entry("Long", strategy.long) //, qty=10) strategy.exit("Close Long", "Long", stop=src-close*SL, profit=TP) shortCondition = sma(rsi,rsiLength1) > threshHigh and sma(rsi,rsiLength2) < sma(rsi,rsiLength2)[1] if (shortCondition) strategy.entry("Short", strategy.short) //, qty=10) strategy.exit("Close Short", "Short") //, stop=src-close*SL, profit=TP)