
Chiến lược này sử dụng sự giao thoa của hai chỉ số moving average (EMA) làm tín hiệu giao dịch chính, kết hợp với chỉ số tương đối yếu (RSI), moving average dispersion indicator (MACD) và Average True Range (ATR) làm các chỉ số phụ để tăng độ tin cậy của tín hiệu giao dịch. Khi EMA nhanh vượt qua EMA chậm và RSI thấp hơn 70, đường MACD trên đường tín hiệu và ATR tăng hơn 10% so với chu kỳ trước, tạo ra nhiều tín hiệu; ngược lại, khi EMA nhanh vượt qua EMA chậm và RSI cao hơn 30, đường MACD dưới đường tín hiệu và ATR tăng hơn 10% so với chu kỳ trước, tạo ra tín hiệu trống.
Chiến lược này tạo ra tín hiệu giao dịch đáng tin cậy hơn bằng cách kết hợp nhiều chỉ số kỹ thuật như EMA, RSI, MACD và ATR, đồng thời kiểm soát rủi ro bằng cách thiết lập điểm dừng lỗ cố định. Mặc dù chiến lược này có một số thiếu sót, nhưng có thể nâng cao hiệu suất của chiến lược bằng cách tối ưu hóa và cải tiến thêm, chẳng hạn như giới thiệu nhiều chỉ số, tối ưu hóa điểm dừng lỗ và kết hợp với phân tích cơ bản.
/*backtest
start: 2024-03-01 00:00:00
end: 2024-03-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Enhanced EMA Crossover Strategy", overlay=true)
// Indicators
ema_fast = ema(close, 8)
ema_slow = ema(close, 14)
rsi = rsi(close, 14)
// Correcting the MACD variable definitions
[macd_line, signal_line, _] = macd(close, 12, 26, 9)
atr_value = atr(14)
// Entry conditions with additional filters
long_condition = crossover(ema_fast, ema_slow) and rsi < 70 and (macd_line > signal_line) and atr_value > atr_value[1] * 1.1
short_condition = crossunder(ema_fast, ema_slow) and rsi > 30 and (macd_line < signal_line) and atr_value > atr_value[1] * 1.1
// Adding debug information
plotshape(series=long_condition, color=color.green, location=location.belowbar, style=shape.xcross, title="Long Signal")
plotshape(series=short_condition, color=color.red, location=location.abovebar, style=shape.xcross, title="Short Signal")
// Risk management based on a fixed number of points
stop_loss_points = 100
take_profit_points = 200
// Order execution
if (long_condition)
strategy.entry("Long", strategy.long, comment="Long Entry")
strategy.exit("Exit Long", "Long", stop=close - stop_loss_points, limit=close + take_profit_points)
if (short_condition)
strategy.entry("Short", strategy.short, comment="Short Entry")
strategy.exit("Exit Short", "Short", stop=close + stop_loss_points, limit=close - take_profit_points)
// Plotting EMAs for reference
plot(ema_fast, color=color.blue, title="Fast EMA")
plot(ema_slow, color=color.orange, title="Slow EMA")