
Chiến lược này là một hệ thống giao dịch tổng hợp kết hợp các chỉ số động lượng và các chỉ số dòng tiền, xử lý trơn tru các chỉ số động lượng bằng chỉ số di chuyển ba chiều ((EMA) để giảm tiếng ồn thị trường một cách hiệu quả. Chiến lược sử dụng tỷ lệ thay đổi ((ROC) để tính toán động lượng nguyên thủy và kết hợp với chỉ số dòng tiền ((MFI) để xác nhận tín hiệu giao dịch, có thể áp dụng cho giao dịch trong các chu kỳ thời gian khác nhau.
Nguyên tắc cốt lõi của chiến lược dựa trên hai chỉ số kỹ thuật chính: chỉ số động lượng và chỉ số dòng tiền ((MFI)). Đầu tiên, ROC được sử dụng để tính toán động lượng nguyên thủy, sau đó có được một đường tín hiệu động lượng ổn định hơn thông qua xử lý mịn EMA ba lần. Việc tạo ra tín hiệu giao dịch cần đáp ứng cả động lượng và MFI.
Đây là một chiến lược giao dịch tổng hợp được thiết kế hợp lý, logic rõ ràng. Bằng cách kết hợp các chỉ số động lực và dòng tiền, và xử lý trơn tru EMA ba, hiệu quả cân bằng tính kịp thời và độ tin cậy của tín hiệu. Chiến lược có tính thực tế và khả năng mở rộng mạnh mẽ, phù hợp để tối ưu hóa và ứng dụng thực tế hơn nữa.
/*backtest
start: 2024-02-22 00:00:00
end: 2025-02-19 08:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=5
strategy("Momentum & Money Flow Strategy with Triple EMA Smoothing", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// Input parameters
momentumPeriod = input.int(7, title="Momentum Period", minval=1)
smoothingPeriod = input.int(3, title="Momentum Smoothing Period", minval=1)
mfiPeriod = input.int(14, title="MFI Period", minval=1)
mfiMiddleLevel = input.int(50, title="MFI Middle Level", minval=1, maxval=100)
mfiOverbought = input.int(80, title="MFI Overbought Level", minval=1, maxval=100)
mfiOversold = input.int(20, title="MFI Oversold Level", minval=1, maxval=100)
// Calculate raw momentum oscillator using rate-of-change (ROC)
rawMomentum = ta.roc(close, momentumPeriod)
// Apply triple EMA smoothing for a much smoother momentum line
smoothedMomentum = ta.ema(ta.ema(ta.ema(rawMomentum, smoothingPeriod), smoothingPeriod), smoothingPeriod)
// Calculate Money Flow Index (MFI) using the typical price (hlc3)
typicalPrice = hlc3
mfiValue = ta.mfi(typicalPrice, mfiPeriod)
// Define conditions for filtering signals based on smoothed momentum and MFI
longCondition = (smoothedMomentum > 0) and (mfiValue > mfiMiddleLevel)
shortCondition = (smoothedMomentum < 0) and (mfiValue < mfiMiddleLevel)
// Define exit conditions for capturing turning points
exitLongCondition = (smoothedMomentum < 0) and (mfiValue < mfiOversold)
exitShortCondition = (smoothedMomentum > 0) and (mfiValue > mfiOverbought)
// Execute entries based on defined conditions
if (longCondition and strategy.position_size <= 0)
strategy.entry("Long", strategy.long)
if (shortCondition and strategy.position_size >= 0)
strategy.entry("Short", strategy.short)
// Exit positions based on turning point conditions
if (strategy.position_size > 0 and exitLongCondition)
strategy.close("Long")
if (strategy.position_size < 0 and exitShortCondition)
strategy.close("Short")
// Plot the triple EMA smoothed momentum oscillator and MFI for visual reference
plot(smoothedMomentum, title="Smoothed Momentum (Triple EMA ROC)", color=color.blue)
hline(0, color=color.gray)
plot(mfiValue, title="Money Flow Index (MFI)", color=color.orange)
hline(mfiMiddleLevel, color=color.green, linestyle=hline.style_dotted, title="MFI Middle Level")