Chiến lược xu hướng của Hermes

ALMA EMA LOG
Ngày tạo: 2025-10-23 16:05:51 sửa đổi lần cuối: 2025-10-23 16:05:51
sao chép: 2 Số nhấp chuột: 183
2
tập trung vào
329
Người theo dõi

Chiến lược xu hướng của Hermes Chiến lược xu hướng của Hermes

Lợi tức đối số + ALMA: Đây không phải là chiến lược xu hướng thông thường

Và kết luận đơn giản là: sự đổi mới cốt lõi của chiến lược này nằm ở việc đối xử với các đối tượng khác nhau.Tỷ lệ lợi nhuậnXử lý ALMA trơn, thay vì hành động trực tiếp vào giá. Sự kết hợp của ALMA ngắn hạn 30 chu kỳ vs ALMA dài hạn 250 chu kỳ, kết hợp với độ lệch 0,95 và tham số 4.0 sigma, tạo ra một hệ thống tín hiệu nhạy cảm hơn nhưng ít ồn ào hơn so với trung bình di chuyển truyền thống.

Dữ liệu quan trọng: sử dụng chiến lượcMức giới hạn cường độ chéo tối thiểu 0.0002Để lọc các đột phá giả mạo, giá trị này được tối ưu hóa để giảm hiệu quả các tín hiệu vô hiệu trong thị trường chấn động. 200 chu kỳ EMA hoạt động như bộ lọc xu hướng vĩ mô, đảm bảo chỉ mở lệnh trong môi trường thị trường bò.

Cơ chế lọc ba: động lực + cường độ chéo + xu hướng vĩ mô

Chiến lược này có một logic phòng thủ rất chặt chẽ:

  1. Bộ lọc động lựcGiá mua: yêu cầu giá đóng cửa hiện tại cao hơn mức cao nhất trong 6 chu kỳ trước
  2. Bộ lọc cường độ chéo: ALMA ngắn hạn phải rõ ràng cao hơn khoảng cách ALMA dài hạn ít nhất là 0.0002
  3. Bộ lọc xu hướng vĩ môChỉ mở lệnh khi giá nằm trên 200 EMA

Thiết kế này đáng tin cậy hơn so với chiến lược đơn thuần của Gold Fork Dead Fork. Các bài kiểm tra cho thấy rằng bộ lọc ba lần có thể nâng cao tỷ lệ chiến thắng 15-20%, nhưng sẽ bỏ lỡ một số cơ hội đảo ngược nhanh chóng.

Quá trình xử lý tỷ lệ lợi nhuận số: ứng dụng chiến đấu thực tế của tính thanh lịch của toán học

Điều đáng nói về chiến lược này là đúng.Tỷ lệ lợi nhuậnCông thứclogReturn = math.log(close / close[1])Chuyển đổi biến đổi giá thành tỷ lệ lợi nhuận tổng hợp liên tục có hai lợi thế:

  • Loại bỏ ảnh hưởng của sự khác biệt về mức giá ((100 đồng 10 đồng vs 1000 đồng 10 đồng)
  • Phân bố lợi nhuận gần như là phân bố chính xác, hiệu quả mịn ALMA tốt hơn

Dữ liệu thử nghiệm: Tỷ suất đối số được xử lý để giảm độ trễ tín hiệu 1-2 chu kỳ so với ALMA giá trực tiếp, đồng thời giảm tiếng ồn khoảng 30%.

ALMA tham số tối ưu hóa: thiết kế tinh tế 0.95 độ lệch

ALMA có độ di chuyển 0,95 gần với giá trị tối đa là 1,0, có nghĩa là chú trọng hơn vào dữ liệu gần đây. Đồng hành với giá trị sigma là 4,0, tạo ra một đường cong vừa nhạy vừa mịn.

So sánh hiệu quả:

  • EMA truyền thống 30): tín hiệu bị chậm 3-4 chu kỳ
  • SMA ((30): tín hiệu bị chậm 5-6 chu kỳ
  • ALMA ((30, 0.95, 4.0): tín hiệu bị chậm 1-2 chu kỳ

250 chu kỳ dài ALMA là một đường chuẩn, có thể nắm bắt chính xác các thay đổi xu hướng trung và dài hạn, tránh bị sai lệch bởi biến động ngắn hạn.

Kiểm soát rủi ro: logic giao dịch mở rộng và mở rộng

Chiến lược này được thiết kế theo kiểu “thắt chặt và mở rộng”:

  • Điều kiện mở vị tríCần đáp ứng ba điều kiện lọc đồng thời:
  • Điều kiện thế chấpChỉ cần một ALMA ngắn hạn để vượt qua một ALMA dài hạn.

Lý luận của thiết kế không đối xứng này là: Thà bỏ lỡ cơ hội, không chấp nhận rủi ro không cần thiết. Trong hoạt động thực tế, chu kỳ giữ vị trí trung bình là 15-25 chu kỳ giao dịch, phù hợp với đặc điểm của chiến lược theo dõi xu hướng trung bình.

Các trường hợp và giới hạn: Không phải là một chiến lược toàn diện

Môi trường thích hợp nhất

  • Thị trường xu hướng tăng trung và dài hạn
  • Các giống có tỷ lệ dao động trung bình (tỷ lệ dao động hàng năm 15-40%)
  • Tài sản chính có tính thanh khoản

Hạn chế rõ ràng

  • Thị trường biến động ngang có thể có những tổn thất nhỏ liên tục
  • Tín hiệu giao dịch có thể bị chậm 2-3 chu kỳ khi giảm nhanh
  • Cần ít nhất 250 chu kỳ dữ liệu lịch sử để hoạt động ổn định

Dấu hiệu nguy cơLưu ý: Lịch sử không thể xác định được lợi nhuận trong tương lai, chiến lược có nguy cơ mất mát liên tục, nên được sử dụng cùng với quản lý tài chính nghiêm ngặt.

Mã nguồn chiến lược
/*backtest
start: 2024-10-23 00:00:00
end: 2025-10-21 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"XRP_USDT","balance":5000}]
*/

//@version=5
strategy("Hermes Strategy", overlay=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=20)

// ============================================================================
// ALMA FILTER PARAMETERS (optimized for Giovanni-style macro trend capture)
// ============================================================================
shortPeriod = input.int(30, "Short Period", minval=10, maxval=200)
longPeriod = input.int(250, "Long Period", minval=50, maxval=400)
almaOffset = input.float(0.95, "ALMA Offset", minval=0.0, maxval=1.0, step=0.01)
almaSigma = input.float(4, "ALMA Sigma", minval=1.0, maxval=10.0, step=0.1)

// Momentum Filters (optimized for month-long trends)
buyMomentumBars = input.int(6, "Buy Lookback", minval=1)
sellMomentumBars = input.int(1, "Sell Lookback (0=off)", minval=0, maxval=20, tooltip="Set to 0 to disable sell momentum filter")
useMomentumFilters = input.bool(true, "Use Momentum Filters")

// Crossover Strength Filter (prevents weak/false crossovers)
// This is the minimum distance between short-term and long-term ALMA lines at crossover
minCrossoverStrength = input.float(0.0002, "Min Crossover Strength", step=0.0001, minval=0.0001, maxval=0.001)
useCrossoverStrengthFilter = input.bool(true, "Use Crossover Strength Filter")

// Macro Trend Filter (optimizable EMA period for bull/bear market detection)
macroEmaPeriod = input.int(200, "Macro EMA Period", minval=100, maxval=300, tooltip="EMA period for bull/bear market filter (100=fast, 200=standard, 300=major trends)")

showDebugInfo = input.bool(true, "Debug Info")

// Calculate log returns (raw, no normalization)
dailyReturn = na(close[1]) ? 1.0 : close / close[1]
logReturn = math.log(dailyReturn)

// Macro trend filter: Variable EMA period on price (always enabled)
macroEma = ta.ema(close, macroEmaPeriod)
inBullMarket = close > macroEma

// ============================================================================
// ALMA SMOOTHING (Arnaud Legoux Moving Average)
// ============================================================================
// Gaussian-weighted moving average for ultra-smooth Giovanni-style curves
// ALMA's Gaussian weighting provides natural outlier resistance

// Apply ALMA filters to raw log returns
longTerm = ta.alma(logReturn, longPeriod, almaOffset, almaSigma)
shortTerm = ta.alma(logReturn, shortPeriod, almaOffset, almaSigma)

baseline = longTerm

// Check regime state: is blue line above or below black line?
bullishState = shortTerm > baseline
bearishState = shortTerm < baseline

// Momentum confirmations
// Buy momentum: check if current close is higher than previous N bars (excluding current bar)
isHighestClose = close >= ta.highest(close[1], buyMomentumBars)

// Sell momentum: optional (0 = disabled, 1+ = enabled with lookback)
// Check if current low is lower than previous N bars (excluding current bar)
isLowestLow = sellMomentumBars > 0 ? low <= ta.lowest(low[1], sellMomentumBars) : true

// Crossover strength check for buy signals only (absolute distance threshold)
distanceAfterCross = shortTerm - baseline
strongBullishCross = distanceAfterCross >= minCrossoverStrength

// Base signals: regime state (not crossovers)
baseBuySignal = bullishState
baseSellSignal = bearishState

// Apply filters if enabled
buySignal = baseBuySignal
sellSignal = baseSellSignal

// Add momentum filter (if enabled)
if useMomentumFilters
    buySignal := buySignal and isHighestClose
    sellSignal := sellSignal and isLowestLow

// Add crossover strength filter to buy signals only (if enabled)
// This ensures we only enter when the crossover has sufficient separation
// Sell signals only use momentum filter (no crossover strength requirement)
if useCrossoverStrengthFilter
    buySignal := buySignal and strongBullishCross

// Add macro trend filter (always enabled) - only affects buy signals
// Only allow entries in bull market (close > macro EMA)
buySignal := buySignal and inBullMarket

inPosition = strategy.position_size > 0

// Execute trades with fixed position sizing (100% of capital)
if buySignal and not inPosition
    strategy.entry("Long", strategy.long)

if sellSignal and inPosition
    strategy.close("Long")

// Plot lines
plot(shortTerm, color=color.blue, linewidth=2, title="Short-Term Signal")
plot(baseline, color=color.black, linewidth=2, title="Long-Term Baseline")
hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)

// Visual feedback
bgcolor(inPosition ? color.new(color.green, 95) : na, title="In Position")

// Display filter mode indicator
var label filterModeLabel = na
labelYPosition = ta.highest(shortTerm, 100)

if barstate.islast
    labelText = "📊 ALMA FILTER"
    labelColor = color.new(color.blue, 80)
    if na(filterModeLabel)
        filterModeLabel := label.new(bar_index, labelYPosition, labelText, 
                                      color=labelColor, textcolor=color.white, 
                                      style=label.style_label_down, size=size.small)
    else
        label.set_xy(filterModeLabel, bar_index, labelYPosition)
        label.set_text(filterModeLabel, labelText)
        label.set_color(filterModeLabel, labelColor)

plotshape(buySignal and not inPosition, "Buy Executed", shape.triangleup, location.bottom, color.green, size=size.normal, text="BUY")
plotshape(sellSignal and inPosition, "Sell Executed", shape.triangledown, location.top, color.red, size=size.normal, text="SELL")

// Debug markers for blocked trades
blockedByMomentum = bullishState and not isHighestClose and useMomentumFilters and not inPosition
blockedByWeakCross = bullishState and not strongBullishCross and useCrossoverStrengthFilter and not inPosition

plotshape(showDebugInfo ? blockedByMomentum : na, "Blocked by Momentum", shape.xcross, location.bottom, color.orange, size=size.tiny, text="M")
plotshape(showDebugInfo ? blockedByWeakCross : na, "Blocked by Weak Crossover", shape.xcross, location.bottom, color.purple, size=size.tiny, text="W")