双向RSI均线回复策略是一种趋势跟踪策略,它使用两个不同时间周期的RSI指标来识别超买和超卖状况。该策略旨在通过在超卖后做多、在超买后做空来获利。该策略使用平滑异同移动平均线、RSI指标和开仓颜色过滤器来识别交易机会。
该策略使用两个具有不同周期的RSI指标——一个在5分钟图表上,一个在1小时图表上。对于RSI指标,超卖水平被认定在30以下,超买水平在70以上。
它会追踪RSI值,寻找RSI持续一定周期处于超卖区或者超买区的情况,表明出现了扩张的超卖或超买状态。
此外,它使用平滑异同移动平均线,在进入交易前检查一定周期的红色或绿色K线来确认趋势方向。开仓颜色过滤器有助于避免假信号。
当RSI和平滑异同移动平均线条件都满足时,该策略会在超卖后做多,在超买后做空,押注价格重新回归均线。
每天结束时平仓,以避免过夜持仓。
双向RSI均线回复策略采用规则化方法交易动量。通过组合两个时间框架、超买超卖指标、K线形态分析和开仓过滤器,其目标是识别高概率均线回归机会。严格的风险管理和审慎的仓位控制有助于在获利的同时控制回撤。进一步优化和稳健性测试将有助于成功地在各类市场部署该策略。
/*backtest start: 2023-09-01 00:00:00 end: 2023-09-30 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //Gidra //2018 //@version=2 strategy(title = "Gidra's Vchain Strategy v0.1", shorttitle = "Gidra's Vchain Strategy v0.1", overlay = false, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 100) //Settings needlong = input(true, defval = true, title = "Long") needshort = input(true, defval = true, title = "Short") capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Lot, %") rsiperiod = input(14, defval = 14, minval = 2, maxval = 100, title = "RSI period") rsilimit = input(30, defval = 30, minval = 1, maxval = 50, title = "RSI limit") rsibars = input(3, defval = 3, minval = 1, maxval = 20, title = "RSI signals") useocf = input(true, defval = true, title = "Use Open Color Filter") openbars = input(2, defval = 2, minval = 1, maxval = 20, title = "Open Color, Bars") showrsi = input(true, defval = true, title = "Show indicator RSI") fromyear = input(2018, defval = 2018, minval = 1900, maxval = 2100, title = "From Year") toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year") frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month") tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month") fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From Day") today = input(31, defval = 31, minval = 01, maxval = 31, title = "To Day") //Heikin Ashi Open/Close Price o=open c=close h=high l=low haclose = (o+h+l+c)/4 haopen = na(haopen[1]) ? (o + c)/2 : (haopen[1] + haclose[1]) / 2 hahigh = max (h, max(haopen,haclose)) halow = min (l, min(haopen,haclose)) col=haopen>haclose ? red : lime plotcandle(haopen, hahigh, halow, haclose, title="heikin", color=col) //RSI uprsi = rma(max(change(close), 0), rsiperiod) dnrsi = rma(-min(change(close), 0), rsiperiod) rsi = dnrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / dnrsi)) uplimit = 100 - rsilimit dnlimit = rsilimit rsidn = rsi < dnlimit ? 1 : 0 rsiup = rsi > uplimit ? 1 : 0 //RSI condition rsidnok = highest(rsidn, rsibars) == 1? 1 : 0 rsiupok = highest(rsiup, rsibars) == 1? 1 : 0 //Color Filter bar = haclose > haopen ? 1 : haclose < haopen ? -1 : 0 gbar = bar == 1 ? 1 : 0 rbar = bar == -1 ? 1 : 0 openrbarok = sma(gbar, openbars) == 1 or useocf == false opengbarok = sma(rbar, openbars) == 1 or useocf == false //Signals up = openrbarok and rsidnok dn = opengbarok and rsiupok lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 : lot[1] //Indicator RSI colbg = showrsi == false ? na : rsi > uplimit ? red : rsi < dnlimit ? lime : na bgcolor(colbg, transp = 20) //Trading if up strategy.entry("Long", strategy.long, needlong == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59))) if dn strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59))) if time > timestamp(toyear, tomonth, today, 23, 59)// or exit strategy.close_all()