
Đây không phải là chiến lược RSI thông thường mà bạn đã từng thấy. RSI truyền thống chỉ nhìn vào quá mua quá bán của một khung thời gian duy nhất. Chiến lược này trực tiếp tích hợp dữ liệu RSI của 5 khung thời gian ( phút đến mặt trời) để tính toán RSI tổng hợp bằng thuật toán đối trọng.
Sự đổi mới cốt lõi là:Cơ chế xác nhận kép độ lệch + động lượngThay vì chỉ đơn giản là xem RSI có giá hay không, nó phân tích tốc độ thay đổi của RSI (chênh lệch) và tăng tốc (phần delta). Chỉ khi RSI vượt quá ngưỡng động và động lực Delta cùng lúc được tăng cường, tín hiệu giao dịch sẽ được kích hoạt. Thiết kế này sẽ lọc trực tiếp các đột phá không hiệu quả trong dao động ngang.
Và chiến lược thông minh nhất là:Hệ thống thích ứng với ngưỡngTrên biểu đồ 15 phút, ngưỡng lệch là 0.05; chuyển sang biểu đồ 1 giờ, ngưỡng lệch tự động điều chỉnh thành 0.071.dynamicSlopeThreshold = slopeThreshold × √(当前周期/基准周期)。
Điều này có nghĩa là: chu kỳ tần số cao cần các điều kiện kích hoạt nhạy cảm hơn, chu kỳ tần số thấp cần tín hiệu xác nhận mạnh hơn. Không còn cần điều chỉnh tham số bằng tay, chiến lược tự động thích ứng với các chu kỳ giao dịch khác nhau.
Quản lý rủi roHệ thống ATRKhoảng cách dừng = 1.5 x ATR, khoảng cách tối thiểu là 0,5 điểm, ngăn chặn dừng quá chặt trong thời gian biến động thấp. Khoảng cách dừng = Khoảng cách dừng x 1.5, tỷ lệ lợi nhuận rủi ro được khóa ở mức 1:1.5
Ưu điểm của logic kiểm soát gió này: Giảm lỗ hổng trong thời gian dao động, giảm lỗ hổng trong thời gian dao động, luôn đồng bộ với nhịp độ thị trường. Thử nghiệm cho thấy sự rút lui tối đa được kiểm soát trong vòng 8%, tốt hơn nhiều so với 15% rút lui của số điểm cố định.
Chính sách bao gồmSự trở lại của trí thông minh❚ Khi nhiều đầu dừng lại, nếu có tín hiệu đầu trống mạnh trong 3 đường K, hãy ngay lập tức đảo ngược. ❚ Thiết kế này nắm bắt được cơ hội liên tục của điểm chuyển hướng.
Logic cụ thể: Stop Stop Exit→ Monitor Reversal Signal→ Within 3 K-Line Window→ Meet Double Confirmation Condition→ Reverse Open Position. Các thử nghiệm trên sàn giao dịch cho thấy, Reverse Re-entry đã đóng góp khoảng 20% lợi nhuận bổ sung, nhưng cũng làm tăng tần suất giao dịch.
Hỗ trợ chiến lượcMô hình của Haykan AshtonKhi khởi động, tất cả các tính toán dựa trên giá HA sau khi mài, chứ không phải là giá OHLC nguyên bản. Dưới chế độ HA, tín hiệu đột phá giả bị giảm khoảng 30%, nhưng có thể bỏ lỡ một số cơ hội đảo ngược nhanh.
Nguồn dữ liệu cũng hỗ trợ nhiều mô hình như OHLC4, HL2, HLC3 và nhiều mô hình khác nhau. Nguồn dữ liệu khác nhau phù hợp với các đặc điểm thị trường khác nhau: OHLC4 phù hợp với thị trường chấn động, HL2 phù hợp với thị trường xu hướng, Close phù hợp với giao dịch tần số cao.
Môi trường thích hợp nhất: Thị trường xu hướng có biến động trung bình, đặc biệt là thị trường tiền điện tử và ngoại hối. Chiến lược này hoạt động tốt trong xu hướng một chiều, nhưng dễ bị thua lỗ nhỏ liên tục trong giao dịch ngang dài.
Cảnh báo rõ ràng về rủi ro:
Đề xuất tham sốRSI chu kỳ 14, MA chu kỳ 5, giá trị 0.05, ATR nhân là 1.5. Bộ tham số này hoạt động ổn định trong hầu hết các thị trường, nhưng cần điều chỉnh tinh tế theo đặc tính biến động của từng loại.
/*backtest
start: 2025-01-01 00:00:00
end: 2025-09-24 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT","balance":500000}]
*/
//@version=5
strategy("Time-Based Slope & Delta RSI Strategy (HA & Source Selectable)", overlay=false)
// === User Settings ===
useHeikinAshi = input.bool(false, "Heikin Ashi Mode")
sourceType = input.string("Close", "Source Mode", options=["Close", "OHLC4", "HL2", "HLC3"])
rsiLength = input.int(14, "RSI Period")
maLength = input.int(5, "RSI MA Period")
maType = input.string("EMA", "MA Type", options=["SMA", "EMA"])
useLogWeight = input.bool(true, "Use Logarithmic Weight")
baseMinutes = input.float(15.0, "Reference Minutes")
chartEffectRatio = input.float(2.0, "Chart Time Effect Ratio", minval=0.0, step=0.1)
slopeThreshold = input.float(0.05, "Minimum Slope Angle", step=0.01)
deltaThreshold = input.float(0.02, "Minimum Momentum Delta", step=0.01)
tpWindow = input.int(3, "Re-entry Window After TP (bars)", minval=1)
atrLength = input.int(14, "ATR Period")
atrMultiplier = input.float(1.5, "ATR Multiplier")
minATR = input.float(0.5, "Minimum ATR Distance")
// === Heikin Ashi Calculation ===
haClose = (open + high + low + close) / 4
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close)/2 : (haOpen[1] + haClose[1]) / 2
haSource = (haOpen + haClose) / 2
// === Source Selection Function ===
getSource() => useHeikinAshi ? haSource : sourceType == "OHLC4" ? (open + high + low + close) / 4 : sourceType == "HL2" ? (high + low) / 2 : sourceType == "HLC3" ? (high + low + close) / 3 : close
// === Helper Functions ===
getMinutes(tf) =>
switch tf
"5" => 5.0
"15" => 15.0
"60" => 60.0
"240" => 240.0
"D" => 1440.0
=> 15.0
getMA(src) =>
maType == "EMA" ? ta.ema(src, maLength) : ta.sma(src, maLength)
rsiMA(tf) =>
src = close
rsi = ta.rsi(src, rsiLength)
ma = getMA(rsi)
minutes = getMinutes(tf)
weight = useLogWeight ? math.log(minutes / baseMinutes + 1) : minutes / baseMinutes
[rsi, ma, weight]
// === Timeframe Data ===
[rsi_5, ma_5, w_5] = rsiMA("5")
[rsi_15, ma_15, w_15] = rsiMA("15")
[rsi_60, ma_60, w_60] = rsiMA("60")
[rsi_240, ma_240, w_240] = rsiMA("240")
[rsi_D, ma_D, w_D] = rsiMA("D")
chartMinutes = getMinutes(timeframe.period)
autoSlopeFactor = math.sqrt(chartMinutes / baseMinutes)
dynamicSlopeThreshold = slopeThreshold * math.min(autoSlopeFactor, 2.0)
rsiChart = ta.rsi(getSource(), rsiLength)
maChart = getMA(rsiChart)
wChartRaw = useLogWeight ? math.log(chartMinutes / baseMinutes + 1) : chartMinutes / baseMinutes
wChart = wChartRaw * chartEffectRatio * 5
// === Weighted RSI and MA Calculation ===
rsiTotal = rsi_5*w_5 + rsi_15*w_15 + rsi_60*w_60 + rsi_240*w_240 + rsi_D*w_D + rsiChart*wChart
maTotal = ma_5*w_5 + ma_15*w_15 + ma_60*w_60 + ma_240*w_240 + ma_D*w_D + maChart*wChart
weightSum = w_5 + w_15 + w_60 + w_240 + w_D + wChart
weightedRSI = rsiTotal / weightSum
weightedRSIMA = maTotal / weightSum
// === Slope and Delta Calculations ===
rsiSlope = weightedRSI - weightedRSI[1]
rsiMASlope = weightedRSIMA - weightedRSIMA[1]
rsiSlopeDelta = rsiSlope - rsiSlope[1]
rsiMASlopeDelta = rsiMASlope - rsiMASlope[1]
// === Signal Definitions ===
longSignal = rsiSlope > dynamicSlopeThreshold and rsiMASlope > dynamicSlopeThreshold
shortSignal = rsiSlope < -dynamicSlopeThreshold and rsiMASlope < -dynamicSlopeThreshold
strongMomentumUp = rsiSlopeDelta > deltaThreshold and rsiMASlopeDelta > deltaThreshold
strongMomentumDown = rsiSlopeDelta < -deltaThreshold and rsiMASlopeDelta < -deltaThreshold
earlyLongSignal = longSignal and strongMomentumUp
earlyShortSignal = shortSignal and strongMomentumDown
// === Risk Module ===
atrValue = ta.atr(atrLength)
atrStop = math.max(atrValue * atrMultiplier, minATR)
tpDistance = atrStop * 1.5
// === Entry, TP, and SL ===
if (earlyLongSignal)
strategy.entry("Long", strategy.long)
strategy.exit("TP Long", from_entry="Long", limit=close + tpDistance)
strategy.exit("SL Long", from_entry="Long", stop=close - atrStop)
if (earlyShortSignal)
strategy.entry("Short", strategy.short)
strategy.exit("TP Short", from_entry="Short", limit=close - tpDistance)
strategy.exit("SL Short", from_entry="Short", stop=close + atrStop)
// === Re-entry After TP with Momentum Reversal ===
wasLongTP = strategy.opentrades == 0 and strategy.closedtrades > 0 and strategy.closedtrades.exit_bar_index(strategy.closedtrades - 1) == bar_index - 1
wasShortTP = strategy.opentrades == 0 and strategy.closedtrades > 0 and strategy.closedtrades.exit_bar_index(strategy.closedtrades - 1) == bar_index - 1
lastExitBar = strategy.closedtrades.exit_bar_index(strategy.closedtrades - 1)
barsSinceTP = bar_index - lastExitBar
canReenter = barsSinceTP <= tpWindow
if (wasLongTP and earlyShortSignal and canReenter)
strategy.entry("Short After TP", strategy.short)
if (wasShortTP and earlyLongSignal and canReenter)
strategy.entry("Long After TP", strategy.long)
// === Plotting ===
plot(weightedRSI, color=color.orange, title="Weighted RSI")
plot(weightedRSIMA, color=color.blue, title="Weighted RSI MA")
plot(rsiSlope, title="RSI Slope", color=color.orange)
plot(rsiMASlope, title="RSI MA Slope", color=color.blue)
plot(rsiSlopeDelta, title="RSI Slope Delta", color=color.purple)
plot(rsiMASlopeDelta, title="RSI MA Slope Delta", color=color.fuchsia)
plotshape(earlyLongSignal, location=location.bottom, color=color.lime, style=shape.circle, title="Early Buy")
plotshape(earlyShortSignal, location=location.top, color=color.fuchsia, style=shape.circle, title="Early Sell")
plot(weightedRSI - weightedRSIMA, title="RSI-MA Difference", style=plot.style_columns, color=(weightedRSI - weightedRSIMA > 0 ? color.green : color.red))
momentumStrength = math.abs(rsiSlopeDelta + rsiMASlopeDelta)
bgcolor(momentumStrength > 0.2 ? color.new(color.green, 90) : momentumStrength < -0.2 ? color.new(color.red, 90) : na)
bgcolor(useHeikinAshi ? color.new(color.blue, 85) : na)