
Chiến lược giao dịch này dựa trên sự khác biệt giữa chỉ số tương đối mạnh (RSI) và sự chuyển động của giá, nhằm mục đích nắm bắt cơ hội đảo ngược xu hướng tiềm năng. Chiến lược này tạo ra tín hiệu mua và bán bằng cách phát hiện sự khác biệt đa đầu và trái đầu, tương ứng. Khi RSI và giá xuất hiện, cho thấy xu hướng hiện tại có thể sắp đảo ngược, cung cấp cho nhà giao dịch cơ hội giao dịch tiềm năng.
Chiến lược giao dịch đảo ngược xu hướng dựa trên RSI bằng cách nắm bắt hiện tượng đảo ngược xu hướng giữa chỉ số RSI và xu hướng giá, xác định cơ hội đảo ngược xu hướng tiềm năng. Chiến lược đơn giản, dễ sử dụng và phù hợp với nhiều thị trường tài chính. Tuy nhiên, các nhà giao dịch cần chú ý đến các yếu tố rủi ro như tín hiệu giả, chậm trễ và nhạy cảm với tham số.
/*backtest
start: 2024-04-01 00:00:00
end: 2024-04-30 23:59:59
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI Divergence Strategy", overlay=true)
// Input parameters
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
lookback = input.int(5, title="Lookback Period for Divergence")
// Calculate RSI
rsi = ta.rsi(close, rsiLength)
// Function to detect bullish divergence
bullishDivergence(price, rsi, lookback) =>
var bool bullDiv = false
for i = 1 to lookback
if (low[i] < low and rsi[i] > rsi)
bullDiv := true
bullDiv
// Function to detect bearish divergence
bearishDivergence(price, rsi, lookback) =>
var bool bearDiv = false
for i = 1 to lookback
if (high[i] > high and rsi[i] < rsi)
bearDiv := true
bearDiv
// Detect bullish and bearish divergence
bullDiv = bullishDivergence(close, rsi, lookback)
bearDiv = bearishDivergence(close, rsi, lookback)
// Plot RSI
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)
plot(rsi, title="RSI", color=color.blue)
// Generate buy signal on bullish divergence
if (bullDiv and ta.crossover(rsi, rsiOversold))
strategy.entry("Buy", strategy.long)
// Generate sell signal on bearish divergence
if (bearDiv and ta.crossunder(rsi, rsiOverbought))
strategy.entry("Sell", strategy.short)
// Plot buy/sell signals on chart
plotshape(series=bullDiv, location=location.belowbar, color=color.green, style=shape.labelup, text="Bull Div")
plotshape(series=bearDiv, location=location.abovebar, color=color.red, style=shape.labeldown, text="Bear Div")