
Chiến lược này là một hệ thống giao dịch dựa trên chỉ số di chuyển trung bình 5 ngày ((EMA), chủ yếu được giao dịch bằng cách xác định hình thức lệch giữa giá và đường trung bình và kết hợp với tín hiệu phá vỡ. Chiến lược sử dụng cơ chế thực hiện ngay lập tức, không cần chờ xác nhận khép kín K, để tăng hiệu quả giao dịch. Hệ thống cũng tích hợp cơ chế quản lý dừng lỗ động với tỷ lệ lợi nhuận gấp 3 lần rủi ro.
Lập luận cốt lõi của chiến lược được xây dựng dựa trên các yếu tố quan trọng sau:
Đây là một chiến lược giao dịch tổng hợp kết hợp đường trung bình ngắn hạn, lệch khỏi hình thức và tín hiệu đột phá. Bằng cơ chế thực hiện ngay lập tức, chiến lược có hiệu quả về thời gian, trong khi sử dụng phương pháp quản lý rủi ro động để kiểm soát rủi ro. Mặc dù có một số rủi ro tiềm ẩn, chiến lược này có giá trị thực tế tốt hơn với các biện pháp quản lý rủi ro và tối ưu hóa thích hợp.
/*backtest
start: 2024-02-20 00:00:00
end: 2025-01-05 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"DOGE_USDT"}]
*/
//@version=5
strategy("5 EMA (Instant Execution)", overlay=true, margin_long=100, margin_short=100)
// Input parameters
ema_length = input.int(5)
target_multiplier = input.float(3.0)
// Calculate 5 EMA
ema_5 = ta.ema(close, ema_length)
// Detect divergence candles
divergence_buy = (high < ema_5) and (low < ema_5) // Below 5 EMA for buy
divergence_sell = (high > ema_5) and (low > ema_5) // Above 5 EMA for sell
// Store trigger levels dynamically
var float trigger_high = na
var float trigger_low = na
// Set trigger levels when divergence occurs
if divergence_buy
trigger_high := high
if divergence_sell
trigger_low := low
// Check real-time price break (no candle close waiting)
buy_signal = not na(trigger_high) and high >= trigger_high
sell_signal = not na(trigger_low) and low <= trigger_low
// Execute trades instantly
if buy_signal
strategy.entry("Long", strategy.long)
candle_size = trigger_high - low
strategy.exit("Long Exit", "Long", limit=trigger_high + (candle_size * target_multiplier), stop=low)
trigger_high := na // Reset trigger
if sell_signal
strategy.entry("Short", strategy.short)
candle_size = high - trigger_low
strategy.exit("Short Exit", "Short", limit=trigger_low - (candle_size * target_multiplier), stop=high)
trigger_low := na // Reset trigger
// Plot signals
plotshape(buy_signal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(sell_signal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
// Plot 5 EMA
plot(ema_5, color=color.blue, linewidth=2)
// Alert conditions
alertcondition(buy_signal, message="BUY triggered - High of divergence candle broken instantly")
alertcondition(sell_signal, message="SELL triggered - Low of divergence candle broken instantly")