RSI与随机RSI背离交易策略是一种高级技术分析方法,专为识别市场中的关键反转点而设计。该策略结合了相对强弱指标(RSI)和随机相对强弱指标(SRSI)的威力,通过监测价格与这些动量指标之间的背离来预测潜在的趋势变化。此外,策略还整合了指数移动平均线(EMA)作为趋势过滤器,并应用精确的摆动距离过滤器,确保捕捉到有意义的市场结构变化而非市场噪音。
该策略的核心原理基于技术分析中的背离概念。背离发生在价格走势与技术指标走势不一致时,通常表明当前趋势可能即将逆转。该策略专注于四种类型的背离:
该策略使用了严格的过滤条件来确保背离信号的质量: - 使用回溯期间(默认40个周期)来寻找显著的摆动点 - 要求最小摆动距离百分比(默认1.5%)来过滤微小波动 - 要求与最后摆动点的最小价格变动百分比(默认0.5%)
当检测到背离时,策略会在图表上绘制标签和连接线,使交易者能够直观地识别这些关键信号。并且,策略根据背离信号自动生成做多和做空的入场信号。
为减轻这些风险,建议: - 将背离信号与其他技术指标或分析方法结合使用,如支撑/阻力水平、烛台形态或成交量分析 - 在不同市场条件下测试和优化参数设置 - 实施适当的资金管理和止损策略 - 考虑背离信号在整体市场趋势背景下的意义
RSI与随机RSI背离交易策略是一种复杂而强大的技术分析工具,能够通过识别价格与动量指标之间的不一致来捕捉潜在的市场反转和趋势延续信号。该策略通过整合常规和隐藏背离检测,并应用精心设计的过滤器,提供了一种全面的方法来识别高概率交易机会。
然而,与所有技术分析方法一样,这种策略也存在局限性和风险。通过实施建议的优化,如添加风险管理机制、改进信号确认和整合动态参数调整,可以显著提高策略的稳健性和性能。
最终,该策略最适合作为更广泛交易系统的一部分,结合其他分析工具和适当的资金管理原则。对于理解技术分析和市场结构的交易者来说,这种背离策略可以成为发现高质量交易设置的宝贵工具。
/*backtest
start: 2024-06-26 00:00:00
end: 2025-06-24 08:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("RSI Divergence Strategy", overlay=true)
//strategy("RSI & SRSI Divergence Strategy with EMA & Min Swing Filter + Price Chart Lines", overlay=true)
rsiLength = input.int(14, title="RSI Length")
srsiLength = input.int(14, title="Stochastic RSI Length")
kLength = input.int(3, title="%K Length")
dLength = input.int(3, title="%D Length")
emaLength = input.int(200, title="EMA Length")
lookback = input.int(40, title="Lookback Period for Divergence")
minSwingDistPercent = input.float(1.5, title="Minimum Swing Distance (%)")
minPriceMovePercent = input.float(0.5, title="Minimum Price Move from Last Swing (%)")
rsi = ta.rsi(close, rsiLength)
srsi = ta.stoch(rsi, rsi, rsi, srsiLength)
k = ta.sma(srsi, kLength)
d = ta.sma(k, dLength)
ema200 = ta.ema(close, emaLength)
// === Bullish Regular Divergence ===
var float lastLowPrice = na
var float lastLowRsi = na
var float lastLowSrsi = na
var int lastLowIndex = na
bullishDiv = false
if ta.lowestbars(low, lookback) == 0
if not na(lastLowPrice) and not na(lastLowRsi) and not na(lastLowSrsi)
swingDistLow = math.abs(low - lastLowPrice) / lastLowPrice * 100
priceMoveLow = math.abs(low - lastLowPrice) / lastLowPrice * 100
if swingDistLow >= minSwingDistPercent and priceMoveLow >= minPriceMovePercent
if (low < lastLowPrice and rsi > lastLowRsi) or (low < lastLowPrice and k > lastLowSrsi)
bullishDiv := true
lastLowPrice := low
lastLowRsi := rsi
lastLowSrsi := k
lastLowIndex := bar_index
else
lastLowPrice := low
lastLowRsi := rsi
lastLowSrsi := k
lastLowIndex := bar_index
// === Bearish Regular Divergence ===
var float lastHighPrice = na
var float lastHighRsi = na
var float lastHighSrsi = na
var int lastHighIndex = na
bearishDiv = false
if ta.highestbars(high, lookback) == 0
if not na(lastHighPrice) and not na(lastHighRsi) and not na(lastHighSrsi)
swingDistHigh = math.abs(high - lastHighPrice) / lastHighPrice * 100
priceMoveHigh = math.abs(high - lastHighPrice) / lastHighPrice * 100
if swingDistHigh >= minSwingDistPercent and priceMoveHigh >= minPriceMovePercent
if (high > lastHighPrice and rsi < lastHighRsi) or (high > lastHighPrice and k < lastHighSrsi)
bearishDiv := true
lastHighPrice := high
lastHighRsi := rsi
lastHighSrsi := k
lastHighIndex := bar_index
else
lastHighPrice := high
lastHighRsi := rsi
lastHighSrsi := k
lastHighIndex := bar_index
// === Bullish Hidden Divergence ===
bullishHiddenDiv = false
if ta.lowestbars(low, lookback) == 0
if not na(lastLowPrice) and not na(lastLowRsi) and not na(lastLowSrsi)
swingDistLowHidden = math.abs(low - lastLowPrice) / lastLowPrice * 100
priceMoveLowHidden = math.abs(low - lastLowPrice) / lastLowPrice * 100
if swingDistLowHidden >= minSwingDistPercent and priceMoveLowHidden >= minPriceMovePercent
if (low > lastLowPrice and rsi < lastLowRsi) or (low > lastLowPrice and k < lastLowSrsi)
bullishHiddenDiv := true
// === Bearish Hidden Divergence ===
bearishHiddenDiv = false
if ta.highestbars(high, lookback) == 0
if not na(lastHighPrice) and not na(lastHighRsi) and not na(lastHighSrsi)
swingDistHighHidden = math.abs(high - lastHighPrice) / lastHighPrice * 100
priceMoveHighHidden = math.abs(high - lastHighPrice) / lastHighPrice * 100
if swingDistHighHidden >= minSwingDistPercent and priceMoveHighHidden >= minPriceMovePercent
if (high < lastHighPrice and rsi > lastHighRsi) or (high < lastHighPrice and k > lastHighSrsi)
bearishHiddenDiv := true
// === PLOTS ===
plot(ema200, title="EMA 200", color=color.purple, linewidth=2)
// === STRATEGY ENTRIES ===
if bullishDiv or bullishHiddenDiv
strategy.entry("Long", strategy.long)
if bearishDiv or bearishHiddenDiv
strategy.entry("Short", strategy.short)