本文详细阐述了一种基于相对强弱指标(RSI)的低高点背离趋势交易策略。该策略通过识别价格与RSI指标之间的背离情况,捕捉潜在的趋势反转机会,为交易者提供精准的入场和出场信号。策略独特地结合了视觉化信号和技术指标分析,旨在提高交易决策的准确性和及时性。
策略的核心原理基于相对强弱指标(RSI)的低高点背离理论。具体实现包括以下关键步骤:
动态RSI低高点背离趋势策略通过精准的技术指标分析和可视化信号,为交易者提供了一种相对高效的趋势交易方法。通过持续优化和风险管理,该策略有望在不同市场环境中保持稳定的表现。
/*backtest
start: 2024-03-31 00:00:00
end: 2025-03-29 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("RSI Divergence Strategy - Visible Signals", overlay=true)
// 1. Basic Inputs (Keep it simple)
rsiLength = input.int(14, "RSI Length")
lookback = input.int(10, "Lookback Period", minval=5)
oversold = input.int(30, "Oversold Level")
overbought = input.int(70, "Overbought Level")
// 2. Calculate Indicators
rsi = ta.rsi(close, rsiLength)
priceLow = ta.lowest(low, lookback)
priceHigh = ta.highest(high, lookback)
rsiLow = ta.lowest(rsi, lookback)
rsiHigh = ta.highest(rsi, lookback)
// 3. Simple Divergence Detection
bullishDiv = low == priceLow and rsi > rsiLow and rsi < oversold
bearishDiv = high == priceHigh and rsi < rsiHigh and rsi > overbought
// 4. Visual Signals (Large and Clear)
plotshape(bullishDiv, "Buy", shape.triangleup, location.belowbar,
color=color.new(color.green, 0), size=size.large)
plotshape(bearishDiv, "Sell", shape.triangledown, location.abovebar,
color=color.new(color.red, 0), size=size.large)
// 5. Optional: Add Background for Better Visibility
bgcolor(bullishDiv ? color.new(color.green, 90) : bearishDiv ? color.new(color.red, 90) : na)
// 6. Basic Strategy Execution
if bullishDiv
strategy.entry("Long", strategy.long)
if bearishDiv
strategy.entry("Short", strategy.short)
// 7. Debugging Table (To verify values)
var table debugTable = table.new(position.top_right, 4, 1)
if barstate.islast
table.cell(debugTable, 0, 0, "RSI: " + str.tostring(rsi))
table.cell(debugTable, 1, 0, "Price Low: " + str.tostring(priceLow))
table.cell(debugTable, 2, 0, "RSI Low: " + str.tostring(rsiLow))
table.cell(debugTable, 3, 0, "Signal: " + (bullishDiv ? "BUY" : bearishDiv ? "SELL" : "NONE"))
// Test Settings (paste these above the strategy call)
//rsiLength := 5
//lookback := 5
//oversold := 20
//overbought := 80