
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 chỉ số trung bình di chuyển ((EMA) và mô hình sửa đổi xung ((ICM)). Nó nắm bắt sự thay đổi xu hướng thị trường bằng cách xác định giá giao thoa với EMA và hình dạng xung-cải sửa-đẩy tiếp theo và thực hiện giao dịch khi đáp ứng các điều kiện cụ thể. Hệ thống sử dụng tỷ lệ lợi nhuận rủi ro cố định để quản lý điểm dừng và dừng cho mỗi giao dịch.
Logic cốt lõi của chiến lược này dựa trên các thành phần chính sau:
Chiến lược này kết hợp EMA và mô hình sửa đổi xung để xây dựng một hệ thống theo dõi xu hướng có logic rõ ràng. Ưu điểm của nó là tín hiệu rõ ràng, rủi ro có thể kiểm soát được, nhưng vẫn cần được tối ưu hóa theo đặc điểm thị trường cụ thể. Bằng cách thêm các điều kiện lọc thích hợp và cơ chế điều chỉnh tham số động, bạn có thể nâng cao hơn nữa sự ổn định và lợi nhuận của chiến lược.
/*backtest
start: 2024-02-19 00:00:00
end: 2025-02-17 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Cross Impulsive Strategy", overlay=true, margin_long=100, margin_short=100)
// Parameters
emaLength = input.int(10, title="EMA Length")
impulsiveBodyTicks = input.int(10, title="Minimum Impulsive Candle Body (Ticks)")
rMultiplier = input.int(3, title="Risk Reward Multiplier")
// Calculate EMA
ema10 = ta.ema(close, emaLength)
// Cross conditions
crossUp = ta.crossover(close, ema10)
crossDown = ta.crossunder(close, ema10)
// Impulsive and correction conditions
tickSize = syminfo.mintick
impulsiveBodyMin = impulsiveBodyTicks * tickSize
isImpulsiveBullish = (close > open) and (close - open >= impulsiveBodyMin)
isImpulsiveBearish = (close < open) and (open - close >= impulsiveBodyMin)
isCorrectionBearish = (close < open)
isCorrectionBullish = (close > open)
// Long setup tracking
var int barsSinceLongCross = 0
var bool impulsive1Long = false
var bool correctionLong = false
var bool impulsive2Long = false
if crossUp
barsSinceLongCross := 0
impulsive1Long := false
correctionLong := false
impulsive2Long := false
else
barsSinceLongCross := barsSinceLongCross + 1
if barsSinceLongCross == 1
impulsive1Long := isImpulsiveBullish
if barsSinceLongCross == 2
correctionLong := isCorrectionBearish
if barsSinceLongCross == 3
impulsive2Long := isImpulsiveBullish and (close > math.max(high[1], high[2]))
// Short setup tracking
var int barsSinceShortCross = 0
var bool impulsive1Short = false
var bool correctionShort = false
var bool impulsive2Short = false
if crossDown
barsSinceShortCross := 0
impulsive1Short := false
correctionShort := false
impulsive2Short := false
else
barsSinceShortCross := barsSinceShortCross + 1
if barsSinceShortCross == 1
impulsive1Short := isImpulsiveBearish
if barsSinceShortCross == 2
correctionShort := isCorrectionBullish
if barsSinceShortCross == 3
impulsive2Short := isImpulsiveBearish and (close < math.min(low[1], low[2]))
// Execute trades
if barsSinceLongCross == 3 and impulsive1Long and correctionLong and impulsive2Long
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", "Long", stop=low, profit=close + (close - low) * rMultiplier)
if barsSinceShortCross == 3 and impulsive1Short and correctionShort and impulsive2Short
strategy.entry("Short", strategy.short)
strategy.exit("Exit Short", "Short", stop=high, profit=close - (high - close) * rMultiplier)
// Plot EMA
plot(ema10, color=color.blue, title="10 EMA")