
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 hai chỉ số di chuyển trung bình (EMA) và chỉ số tương đối yếu (RSI). Chiến lược này hoạt động trên khung thời gian 5 phút để nắm bắt xu hướng thị trường bằng cách giao thoa EMA ngắn hạn và dài hạn và kết hợp với chỉ số RSI, đồng thời điều khiển rủi ro dừng lỗ với tỷ lệ phần trăm cố định.
Chiến lược này dựa trên các thành phần cốt lõi sau:
Đây là một hệ thống giao dịch hoàn chỉnh kết hợp các chỉ số kỹ thuật và quản lý rủi ro. Chiến lược xác định hiệu quả các xu hướng thông qua sự kết hợp của EMA và RSI và kiểm soát rủi ro bằng cách sử dụng các điểm dừng cố định. Mặc dù có một số hạn chế, nhưng hướng tối ưu hóa được đề xuất có thể nâng cao hơn nữa sự ổn định và khả năng lợi nhuận của chiến lược.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("5-Minute EMA + RSI Strategy", overlay=true, shorttitle="EMA RSI")
// Inputs
ema_short_length = input.int(9, title="Short EMA Length", minval=1)
ema_long_length = input.int(21, title="Long EMA Length", minval=1)
rsi_length = input.int(14, title="RSI Length")
rsi_overbought = input.int(70, title="RSI Overbought Level")
rsi_oversold = input.int(30, title="RSI Oversold Level")
// Calculate EMAs
ema_short = ta.ema(close, ema_short_length)
ema_long = ta.ema(close, ema_long_length)
// Calculate RSI
rsi = ta.rsi(close, rsi_length)
// Plot EMAs
plot(ema_short, title="Short EMA", color=color.blue, linewidth=2)
plot(ema_long, title="Long EMA", color=color.red, linewidth=2)
// Conditions for Entries
long_condition = ta.crossover(ema_short, ema_long) and rsi > 50
short_condition = ta.crossunder(ema_short, ema_long) and rsi < 50
// Execute Trades
if (long_condition)
strategy.entry("Buy", strategy.long)
if (short_condition)
strategy.entry("Sell", strategy.short)
// Risk Management: Take Profit & Stop Loss
take_profit_perc = input.float(1.5, title="Take Profit %", step=0.1) // 1.5% target
stop_loss_perc = input.float(0.5, title="Stop Loss %", step=0.1) // 0.5% stop
strategy.exit("Take Profit/Stop Loss", "Buy",
profit=take_profit_perc, loss=stop_loss_perc)
strategy.exit("Take Profit/Stop Loss", "Sell",
profit=take_profit_perc, loss=stop_loss_perc)
// Add Visual Alerts
plotshape(long_condition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(short_condition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)