
Chiến lược này là một hệ thống giao dịch theo dõi xu hướng dựa trên moving average (EMA) và độ dao động thực tế (ATR) của nhiều chỉ số. Chiến lược này nắm bắt xu hướng thị trường thông qua sự phối hợp phối hợp của ba EMA 20 chu kỳ, 50 chu kỳ và 100 chu kỳ và sử dụng ATR để quản lý rủi ro và mục tiêu lợi nhuận động. Phương pháp này đảm bảo cả tính hệ thống của giao dịch và kiểm soát động cơ rủi ro.
Lập luận cốt lõi của chiến lược được xây dựng trên mối quan hệ tương tác giữa giá và nhiều EMA. Cụ thể:
Chiến lược này được kết hợp với hệ thống đa đường trung bình và kiểm soát gió động của ATR để xây dựng một hệ thống giao dịch có tính theo dõi xu hướng và điều hành băng tần. Ưu điểm của chiến lược là có tính hệ thống mạnh mẽ, có thể kiểm soát rủi ro, nhưng trong ứng dụng thực tế, cần chú ý đến sự thích nghi của môi trường thị trường và tối ưu hóa mục tiêu theo tình huống thực tế. Với cài đặt tham số hợp lý và kiểm soát rủi ro nghiêm ngặt, chiến lược này có thể đạt được hiệu quả giao dịch ổn định trong hầu hết các môi trường thị trường.
/*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=6
strategy("EMA Swing Strategy with ATR", overlay=true)
// Inputs
emaShort = input.int(20, "Short EMA")
emaMid = input.int(50, "Mid EMA")
emaLong = input.int(100, "Long EMA")
rrRatio = input.float(1.5, "Risk-Reward Ratio")
contracts = input.int(5, "Number of Contracts")
// Calculations
ema20 = ta.ema(close, emaShort)
ema50 = ta.ema(close, emaMid)
ema100 = ta.ema(close, emaLong)
atr = ta.atr(14)
// Conditions
longCondition = ta.crossover(close, ema20) and close > ema50
shortCondition = ta.crossunder(close, ema20) and close < ema50
// Variables for trades
var float entryPrice = na
var float stopLoss = na
var float takeProfit = na
// Long Trades
if (longCondition)
entryPrice := close
stopLoss := close - atr
takeProfit := close + atr * rrRatio
strategy.entry("Long", strategy.long, contracts)
strategy.exit("Exit Long", from_entry="Long", stop=stopLoss, limit=takeProfit)
// Short Trades
if (shortCondition)
entryPrice := close
stopLoss := close + atr
takeProfit := close - atr * rrRatio
strategy.entry("Short", strategy.short, contracts)
strategy.exit("Exit Short", from_entry="Short", stop=stopLoss, limit=takeProfit)
// Plot EMAs
plot(ema20, color=color.green, title="EMA 20")
plot(ema50, color=color.red, title="EMA 50")
plot(ema100, color=color.white, title="EMA 100")
// Visualization for Entries
plotshape(series=longCondition, style=shape.labelup, color=color.green, location=location.belowbar, title="Long Entry")
plotshape(series=shortCondition, style=shape.labeldown, color=color.red, location=location.abovebar, title="Short Entry")