
Chiến lược này là một hệ thống giao dịch định lượng dựa trên nhiều chỉ số kỹ thuật, tích hợp ba chỉ số kỹ thuật lớn là đường trung bình di chuyển của chỉ số ((EMA), chỉ số tương đối mạnh ((RSI) và chỉ số xu hướng trung bình ((ADX)). Chiến lược sử dụng tín hiệu chéo của đường EMA nhanh như là cơ sở đầu vào chính, đồng thời kết hợp với chỉ số RSI để xác nhận quá mua và bán, và sử dụng chỉ số ADX để đánh giá cường độ của xu hướng thị trường, do đó tạo thành một hệ thống quyết định giao dịch hoàn chỉnh. Chiến lược cũng bao gồm mô-đun quản lý rủi ro, kiểm soát vị trí dừng lỗ và dừng chân cho mỗi giao dịch bằng cách thiết lập tỷ lệ lợi nhuận rủi ro.
Lập luận cốt lõi của chiến lược dựa trên một số thành phần quan trọng sau:
Đây là một chiến lược giao dịch đa chỉ số kỹ thuật được thiết kế hợp lý và logic. Bằng cách tích hợp ba chỉ số kỹ thuật cổ điển EMA, RSI và ADX, chiến lược có hiệu suất tốt trong việc theo dõi xu hướng và kiểm soát rủi ro. Mặc dù có một số nơi cần tối ưu hóa, nhưng nói chung chiến lược có giá trị thực tế tốt và không gian mở rộng.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-11 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Enhanced EMA + RSI + ADX Strategy", overlay=true)
// Input parameters
lenFast = input.int(9, title="Fast EMA Length", minval=1)
lenSlow = input.int(21, title="Slow EMA Length", minval=1)
rsiPeriod = input.int(14, title="RSI Period")
adxPeriod = input.int(14, title="ADX Period")
adxSmoothing = input.int(1, title="ADX Smoothing")
adxThreshold = input.int(20, title="ADX Threshold")
riskRewardRatio = input.float(2.0, title="Risk/Reward Ratio")
// EMA Calculations
fastEMA = ta.ema(close, lenFast)
slowEMA = ta.ema(close, lenSlow)
// RSI Calculation
rsiValue = ta.rsi(close, rsiPeriod)
// ADX Calculation
[plusDI, minusDI, adxValue] = ta.dmi(adxPeriod, adxSmoothing)
// Entry Conditions
buyCondition = ta.crossover(fastEMA, slowEMA) and rsiValue < 60 and adxValue > adxThreshold
sellCondition = ta.crossunder(fastEMA, slowEMA) and rsiValue > 40 and adxValue > adxThreshold
// Entry logic
if (buyCondition)
strategy.entry("Buy", strategy.long)
strategy.exit("Sell", from_entry="Buy", limit=close + (close - strategy.position_avg_price) * riskRewardRatio, stop=close - (close - strategy.position_avg_price))
if (sellCondition)
strategy.close("Buy")
// Plotting EMAs (thinner lines)
plot(fastEMA, color=color.new(color.green, 0), title="Fast EMA", linewidth=1)
plot(slowEMA, color=color.new(color.red, 0), title="Slow EMA", linewidth=1)
// Entry and exit markers (larger shapes)
plotshape(series=buyCondition, style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.normal, title="Buy Signal")
plotshape(series=sellCondition, style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.normal, title="Sell Signal")
// Displaying price labels for buy/sell signals
if (buyCondition)
label.new(bar_index, low, text="Buy\n" + str.tostring(close), color=color.new(color.green, 0), style=label.style_label_down, textcolor=color.white)
if (sellCondition)
label.new(bar_index, high, text="Sell\n" + str.tostring(close), color=color.new(color.red, 0), style=label.style_label_up, textcolor=color.white)
// Optional: Add alerts for entry signals
alertcondition(buyCondition, title="Buy Alert", message="Buy signal triggered")
alertcondition(sellCondition, title="Sell Alert", message="Sell signal triggered")