该策略主要利用相对强弱指数(RSI)来判断市场超买超卖情况,结合价格在200日简单移动平均线(SMA)之上作为趋势过滤条件,以此来决定是否进场交易。该策略通过三重RSI指标共同构建开仓条件,只有当短期RSI小于35且连续三个周期呈下降趋势,同时第三周期RSI小于60,且当前收盘价在200日SMA之上时,才会做多。平仓条件为RSI上穿50。
该策略通过三重RSI构建开仓条件,结合价格在长期均线之上作为趋势过滤,以此捕捉超卖反转行情。策略逻辑简单明了,易于实现和优化。但是策略也存在信号滞后、交易频率低、只能捕捉单边行情等风险和不足,需要在实际应用中不断调试和改进。通过引入止损止盈、仓位管理、结合其他指标等方法,可以进一步提升策略的稳定性和收益性。
/*backtest start: 2023-05-15 00:00:00 end: 2024-05-14 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 //@author Honestcowboy // strategy("Triple RSI [Honestcowboy]" ) // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ >> // ---------> User Inputs <----------- >> // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ >> rsiLengthInput = input.int(5, minval=1, title="RSI Length", group="RSI Settings") rsiSourceInput = input.source(close, "Source", group="RSI Settings") // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ >> // ---------> VARIABLE CALCULATIONS <----------- >> // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ >> up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput) down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ >> // ---------> CONDITIONALS <----------- >> // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ >> rule1 = rsi<35 rule2 = rsi<rsi[1] and rsi[1]<rsi[2] and rsi[2]<rsi[3] rule3 = rsi[3]<60 rule4 = close>ta.sma(close, 200) longCondition = rule1 and rule2 and rule3 and rule4 closeCondition = rsi>50 // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ >> // ---------> GRAPHICAL DISPLAY <----------- >> // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ >> hline(30, title="Long Condition Line") hline(50, title="Exit Condition Line") plot(rsi) plotshape(longCondition ? rsi-3 : na, title="Long Condition", style=shape.triangleup, color=color.lime, location=location.absolute) plotshape(closeCondition and rsi[1]<50? rsi+3 : na, title="Exit Condition", style=shape.triangledown, color=#e60000, location=location.absolute) // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ >> // ---------> AUTOMATION AND BACKTESTING <----------- >> // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ >> if longCondition and strategy.position_size==0 strategy.entry("LONG", strategy.long) if closeCondition strategy.close("LONG")