
Chiến lược này là một hệ thống giao dịch kết hợp các chỉ số xu hướng Supertrend và RSI (chỉ số tương đối yếu). Chiến lược này giao dịch khi xu hướng thị trường rõ ràng và có động lực tốt bằng cách kết hợp theo dõi xu hướng với các chỉ số động lực. Hệ thống sử dụng ATR (trung lượng sóng trung bình thực tế) để tính toán mức hỗ trợ và kháng cự động và kết hợp với tín hiệu bán tháo RSI để xác định thời điểm vào thị trường.
Logic cốt lõi của chiến lược này dựa trên các yếu tố chính sau:
Chiến lược này kết hợp các chỉ số Supertrend và RSI để xây dựng một hệ thống giao dịch theo dõi xu hướng hoàn chỉnh. Chiến lược hoạt động tốt hơn trong thị trường có xu hướng rõ ràng, kiểm soát rủi ro bằng cách dừng động và thiết lập dừng hợp lý. Mặc dù có một số hạn chế, nhưng bằng hướng tối ưu hóa được đề xuất, bạn có thể nâng cao hơn nữa sự ổn định và thích ứng của chiến lược. Chiến lược phù hợp để theo dõi xu hướng trung bình và dài hạn và kiểm soát rủi ro tốt hơn trong khi vẫn duy trì khả năng sinh lợi nhất định.
/*backtest
start: 2024-04-11 00:00:00
end: 2025-02-19 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("Supertrend + RSI Strategy", overlay=true)
// Input Parameters
atrLength = input.int(10, title="ATR Length", minval=1)
factor = input.float(3.0, title="Supertrend Factor", step=0.1)
rsiLength = input.int(14, title="RSI Length", minval=1)
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
// Supertrend Calculation
atr = ta.atr(atrLength)
upperBand = ta.sma(close, atrLength) + (factor * atr)
lowerBand = ta.sma(close, atrLength) - (factor * atr)
supertrend = 0.0
supertrend := close > nz(supertrend[1], close) ? lowerBand : upperBand
supertrendSignal = close > supertrend ? "Buy" : "Sell"
// RSI Calculation
rsi = ta.rsi(close, rsiLength)
// Trading Logic
longCondition = (supertrendSignal == "Buy") and (rsi > rsiOversold)
shortCondition = (supertrendSignal == "Sell") and (rsi < rsiOverbought)
// Entry and Exit Conditions
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.entry("Short", strategy.short)
// Plot Supertrend
plot(supertrend, title="Supertrend", color=color.new(color.blue, 0), linewidth=2, style=plot.style_line)
// Plot RSI Levels
hline(rsiOverbought, "Overbought", color=color.red)
hline(rsiOversold, "Oversold", color=color.green)
plot(rsi, title="RSI", color=color.orange, style=plot.style_stepline)
// Alerts
alertcondition(longCondition, title="Buy Alert", message="Supertrend + RSI Buy Signal")
alertcondition(shortCondition, title="Sell Alert", message="Supertrend + RSI Sell Signal")