
Chiến lược này kết hợp hai chỉ số kỹ thuật tương đối mạnh (RSI) và Supertrend để nắm bắt xu hướng thị trường và xác định cơ hội giao dịch tiềm năng. Ý tưởng chính của chiến lược là sử dụng RSI để đánh giá tình trạng quá mua và quá bán của thị trường, đồng thời sử dụng chỉ số Supertrend để xác nhận hướng xu hướng.
Chiến lược giao dịch theo dõi xu hướng RSI + Supertrend có thể nắm bắt hiệu quả xu hướng thị trường và tạo ra tín hiệu giao dịch bằng cách kết hợp hai chỉ số kỹ thuật RSI và Supertrend. Ưu điểm của chiến lược là rõ ràng về logic, dễ thực hiện, đồng thời xem xét các yếu tố động lực và xu hướng. Tuy nhiên, chiến lược cũng có một số rủi ro, chẳng hạn như giao dịch thường xuyên và các giới hạn trong cài đặt tham số. Để nâng cao hơn nữa hiệu suất của chiến lược, bạn có thể xem xét giới thiệu các chỉ số khác, tối ưu hóa tham số, tăng cường các biện pháp quản lý rủi ro và giám sát và điều chỉnh liên tục.
/*backtest
start: 2024-05-21 00:00:00
end: 2024-05-28 00:00:00
period: 45m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("RSI + Supertrend Strategy", overlay=true)
// Input parameters
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(58, title="RSI Overbought Level")
rsiOversold = input.int(38, title="RSI Oversold Level")
supertrendLength = input.int(10, title="Supertrend Length")
supertrendMultiplier = input.int(3, title="Supertrend Multiplier")
// Calculate indicators
rsiValue = ta.rsi(close, rsiLength)
[supertrend, _] = ta.supertrend(supertrendLength, supertrendMultiplier)
// Plot Supertrend on main chart
plot(supertrend, color = supertrend < close ? color.green : color.red, linewidth = 2, title="Supertrend")
// Plot RSI
hline(rsiOverbought, "Overbought", color.red)
hline(rsiOversold, "Oversold", color.green)
plot(rsiValue, title="RSI", color=color.blue)
// Strategy
var float entryPrice = na
// Long conditions
longCondition = (rsiValue > rsiOverbought) and (supertrend < close)
// Short conditions
shortCondition = (rsiValue < rsiOversold) and (supertrend > close)
// Exit conditions
longExitCondition = (rsiValue < 50) and (supertrend > close)
shortExitCondition = (rsiValue > 45) and (supertrend < close)
// Execute strategy
if (longCondition)
strategy.entry("Long", strategy.long)
entryPrice := close
if (shortCondition)
strategy.entry("Short", strategy.short)
entryPrice := close
if (longExitCondition and strategy.position_size > 0)
strategy.close("Long")
if (shortExitCondition and strategy.position_size < 0)
strategy.close("Short")
// Date and time range for backtest
startDate = timestamp("2023-01-01 00:00")
endDate = timestamp("2024-01-01 00:00")
if (time < startDate or time > endDate)
strategy.close_all()