本策略是一个多时间框架非重绘RSI策略,仅在两个更高时间框架超卖时做多。我在BTC/USD的1分钟线上编写,但逻辑可应用于其他资产。旨在资产处于下跌趋势时盈利。
对角层叠指入场和退出条件分布在不同时间框架上。通常,指标可能变得无利可图,因为在下跌趋势中,当前时间框架的超买区未被触及,而是先触及更高时间框架的超买区,然后发生回调。对角层叠策略通过对角方式减轻这一问题,即当更快时间框架超买时卖出,当更慢时间框架超卖时买入。
因此,本策略是对角层叠的。我可能会创建一个单独的脚本,根据总体趋势在对角向上和对角向下之间切换,因为在延长的上涨趋势期间,该指标可能不会频繁闪烁。这在时间序列与时间框架图表上可以视为“X”形。这是值得考虑的……
本策略overall是一个非常有效的下跌趋势交易策略。利用多时间框架RSI指标和对角层叠入场方式,能在下跌阶段捕捉反弹机会。同时非重绘特性也提高了信号的可靠性。通过优化参数,添加过滤器和做空策略,可以将其打造成一个适应任何市场的强大策略。
/*backtest
start: 2022-09-21 00:00:00
end: 2023-06-24 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/
// © wbburgin
//@version=5
strategy("MTF Layered RSI - Bitcoin Bot [wbburgin]",overlay=false, pyramiding = 20, initial_capital=10000)
length = input.int(7,"RSI Length")
tf2 = input.timeframe("3",title="HT 1")
tf3 = input.timeframe("5",title="HT 2")
ob = input.int(80,"Overbought Level")
os = input.int(20,"Oversold Level")
rsi = ta.rsi(close,length)
rsi2 = request.security(syminfo.tickerid, tf2, rsi[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
rsi3 = request.security(syminfo.tickerid, tf3, rsi[1], barmerge.gaps_off, lookahead=barmerge.lookahead_on)
plot(rsi,color=color.yellow,title="RSI Current TF")
plot(rsi2,color=color.new(color.yellow,50),title="RSI HT1")
plot(rsi3,color=color.new(color.yellow,75),title="RSI HT2")
lm=hline(os,title="Oversold")
hm=hline(ob,title="Overbought")
fill(hm,lm,color=color.new(color.blue,95))
htCross = (ta.crossover(rsi2,os) and rsi3>os and rsi>os) or (ta.crossover(rsi3,os) and rsi2>os and rsi>os)
buySig = (ta.crossover(rsi,os) and rsi2 < os and rsi3 < os) or htCross
sellSig = ta.crossunder(rsi,ob)
if buySig
strategy.entry("Long",strategy.long)
if sellSig
strategy.close("Long")
plotshape(buySig,title="Buysig",style=shape.triangleup,location=location.bottom,color=color.green,size=size.tiny)
plotshape(sellSig,title="Sellsig",style=shape.triangledown,location=location.top,color=color.red,size=size.tiny)