
Chiến lược này là một hệ thống theo dõi xu hướng kết hợp các chỉ số kỹ thuật và phương pháp học máy. Chiến lược này tích hợp các chỉ số tương đối mạnh (RSI), chỉ số xu hướng trung bình (ADX) và mô hình dự báo hồi quy tuyến tính để xác định xu hướng thị trường và cơ hội giao dịch thông qua phân tích đa chiều. Chiến lược này hoạt động trong chu kỳ 5 phút, thực hiện một hệ thống quyết định giao dịch hoàn chỉnh bằng cách kết hợp tín hiệu bán tháo RSI, xác nhận xu hướng ADX và dự báo hồi quy tuyến tính.
Chiến lược này sử dụng một cơ chế lọc ba lớp để xác định tín hiệu giao dịch:
Chiến lược này được xây dựng một hệ thống giao dịch tương đối hoàn chỉnh bằng cách kết hợp các phương pháp phân tích kỹ thuật truyền thống và dự đoán hiện đại. Điểm mạnh cốt lõi của chiến lược là cơ chế xác nhận tín hiệu đa chiều, có thể làm giảm hiệu quả ảnh hưởng của tín hiệu giả.
/*backtest
start: 2025-01-20 00:00:00
end: 2025-02-19 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=5
strategy("RSI + ADX + ML-like Strategy (5min)", overlay=true)
// ———— 1. Inputs ————
rsiLength = input(14, "RSI Length")
adxLength = input(14, "ADX Length")
mlLookback = input(20, "ML Lookback (Bars)")
// ———— 2. Calculate Indicators ————
// RSI
rsi = ta.rsi(close, rsiLength)
// ADX
[diPlus, diMinus, adx] = ta.dmi(adxLength, adxLength)
// ———— 3. Simplified ML-like Component (Linear Regression) ————
var float predictedClose = na
sumX = math.sum(bar_index, mlLookback) // FIXED: Using math.sum()
sumY = math.sum(close, mlLookback) // FIXED: Using math.sum()
sumXY = math.sum(bar_index * close, mlLookback) // FIXED: Using math.sum()
sumX2 = math.sum(bar_index * bar_index, mlLookback)
slope = (mlLookback * sumXY - sumX * sumY) / (mlLookback * sumX2 - sumX * sumX)
intercept = (sumY - slope * sumX) / mlLookback
predictedClose := slope * bar_index + intercept
// ———— 4. Strategy Logic ————
mlBullish = predictedClose > close
mlBearish = predictedClose < close
enterLong = ta.crossover(rsi, 30) and adx > 25 and mlBullish
enterShort = ta.crossunder(rsi, 70) and adx > 25 and mlBearish
// ———— 5. Execute Orders ————
strategy.entry("Long", strategy.long, when=enterLong)
strategy.entry("Short", strategy.short, when=enterShort)
// ———— 6. Plotting ————
plot(predictedClose, "Predicted Close", color=color.purple)
plotshape(enterLong, "Buy", shape.triangleup, location.belowbar, color=color.green)
plotshape(enterShort, "Sell", shape.triangledown, location.abovebar, color=color.red)