
Chiến lược này là một hệ thống giao dịch theo dõi xu hướng kết hợp các đường trung bình di chuyển đơn giản (SMA) với các chỉ số tương đối mạnh (RSI). Nó xác định hướng xu hướng thông qua sự giao thoa của các đường trung bình di chuyển ngắn hạn và dài hạn và sử dụng RSI để xác nhận động lượng để tìm kiếm các cơ hội giao dịch có xác suất cao trên thị trường. Chiến lược này cũng bao gồm mô-đun quản lý rủi ro hoàn chỉnh để kiểm soát rủi ro của mỗi giao dịch một cách hiệu quả.
Logic cốt lõi của chiến lược này dựa trên việc sử dụng kết hợp hai chỉ số kỹ thuật:
Đây là một chiến lược theo dõi xu hướng có cấu trúc, logic rõ ràng. Bằng cách kết hợp SMA và RSI, nó có thể nắm bắt xu hướng và tránh giao dịch trong khu vực mua và bán quá mức. Cơ chế quản lý rủi ro được xây dựng trong đó đảm bảo sự ổn định của chiến lược. Mặc dù có một số hạn chế vốn có, nhưng các hướng tối ưu hóa được đề xuất có thể nâng cao hơn nữa hiệu suất của chiến lược.
/*backtest
start: 2025-02-16 00:00:00
end: 2025-02-23 00:00:00
period: 6m
basePeriod: 6m
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=6
strategy("WEN - SMA with RSI Strategy", overlay=true)
// Define input parameters
// SMA Inputs
shortLength = input(8, title="Short MA Length")
longLength = input(21, title="Long MA Length")
// RSI Inputs
rsiLength = input(14, title="RSI Length")
rsiOverbought = input(70, title="RSI Overbought")
rsiOversold = input(30, title="RSI Oversold")
// Calculate indicators
// Moving Averages
shortMA = ta.sma(close, shortLength)
longMA = ta.sma(close, longLength)
// RSI
rsi = ta.rsi(close, rsiLength)
// Plot indicators
plot(shortMA, title="Short MA", color=color.blue)
plot(longMA, title="Long MA", color=color.red)
// RSI is typically plotted in a separate panel in trading platforms
// Entry conditions with RSI confirmation
smaLongCondition = ta.crossover(shortMA, longMA)
smaShortCondition = ta.crossunder(shortMA, longMA)
rsiLongCondition = rsi < rsiOverbought // Not overbought for long entry
rsiShortCondition = rsi > rsiOversold // Not oversold for short entry
// Combined entry conditions
longCondition = smaLongCondition and rsiLongCondition
shortCondition = smaShortCondition and rsiShortCondition
// Execute trades
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.close("Long")
strategy.entry("Short", strategy.short)
// Set stop loss and take profit
stopLoss = input(1, title="Stop Loss (%)") / 100
takeProfit = input(2, title="Take Profit (%)") / 100
longStopLossPrice = strategy.position_avg_price * (1 - stopLoss)
longTakeProfitPrice = strategy.position_avg_price * (1 + takeProfit)
shortStopLossPrice = strategy.position_avg_price * (1 + stopLoss)
shortTakeProfitPrice = strategy.position_avg_price * (1 - takeProfit)
strategy.exit("Take Profit / Stop Loss", from_entry="Long", stop=longStopLossPrice, limit=longTakeProfitPrice)
strategy.exit("Take Profit / Stop Loss", from_entry="Short", stop=shortStopLossPrice, limit=shortTakeProfitPrice)