하이켄 애쉬(Heiken Asch) 추세 추종 전략: 다중 레벨 손절매 메커니즘을 갖춘 다중 기간 추세 식별 시스템

supertrend ADX ATR HEIKEN ASHI DMI
생성 날짜: 2025-04-14 11:31:37 마지막으로 수정됨: 2025-04-14 11:31:37
복사: 1 클릭수: 502
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

하이켄 애쉬(Heiken Asch) 추세 추종 전략: 다중 레벨 손절매 메커니즘을 갖춘 다중 기간 추세 식별 시스템 하이켄 애쉬(Heiken Asch) 추세 추종 전략: 다중 레벨 손절매 메커니즘을 갖춘 다중 기간 추세 식별 시스템

개요

헤이켄 아쉬 트렌드 추적 전략은 헤이켄 아쉬 그래프, 슈퍼 트렌드 지표 및 평균 방향 지수 ((ADX) 필터의 장점을 결합한 종합적인 거래 시스템으로, 강력한 트렌드 움직임을 식별하고 효과적인 자금 관리를 수행하기 위해 고안되었습니다. 이 전략은 기존의 트렌드에서 동력을 포착하는 데 초점을 맞추고 있으며, 고급 3 계층의 손실 제도를 사용하여 자금을 보호하고 이익을 잠금합니다. 이 전략은 여러 가지 거래 품종에 적합하며, 특히 변동성이 큰 시장에서 잘 나타납니다.

전략 원칙

하이켄 아쉬 트렌드 추적 전략은 세 가지 핵심 기술 지표의 상호 작용에 기반합니다.

  1. 해켄 아히 지도 분석이 전략은 특히 위아래 그림자 거의 없는 “개체”인 하이켄 아치을 주목한다. 이 그림자는 가격의 한 방향으로 결정적으로 이동하는 것을 의미하며, 강한 동력과 추세가 계속되는 것을 암시하는 거의 회전이 없다. 아래 그림자 없는 녹색 그림자는 다중 신호로 간주되며, 위 그림자 없는 빨간 그림자는 공백 신호로 간주된다.

  2. 슈퍼 트렌드 지표 필터링: 시스템은 슈퍼 트렌드 지표를 사용하여 잠재적인 트렌드 방향을 확인합니다. 입력 신호는 슈퍼 트렌드 방향과 일치해야합니다. 이것은 신호의 신뢰성을 높이고 잘못된 거래를 줄입니다.

  3. ADX 필터 (선택): 평균 방향 지수는 트렌드의 강도를 평가하는 데 사용되며, 거래는 ADX가 지정된 스레치를 초과했을 때만 트리거됩니다. (기본:25) 이는 흔들림이나 가로 시장의 잡음 신호를 필터링하는 데 도움이됩니다.

거래 시스템은 명확한 출입 및 출입 규칙을 가지고 있습니다.

  • 출입 신호다음 조건이 충족될 때 형성된다: ((1) 하도선 없는 녹색 하이켄 아치 ((多做) 또는 상도선 없는 빨간 하이켄 아치 ((空做)); ((2) 슈퍼 트렌드 방향 확인; ((3) ADX值 ((如果啟動) ᅳ)
  • 출구 신호상반된 방향의 무도선 선이 나타났을 때, 또는 어떤 스피드 메커니즘이 작동했을 때 거래가 종료됩니다.

이 전략의 가장 큰 특징은 3단계로 구성된 혁신적인 상쇄 시스템입니다.

  1. ATR 추적 손실: 시장의 변동성 (ATR 값) 에 따라 동적으로 스톱로스를 조정하고, 추세가 연장됨에 따라 수익을 고정한다.
  2. 변동 지점 상쇄: 시장의 자연 구조를 이용해서 ((회찰 기간의 최근 고점/저점) 시장 자체의 리듬을 존중하는 스톱 로스를 설정한다.
  3. 손해보험: 입시 가격의 비율을 기반으로 설정된 안전망으로, 특히 진입점으로부터 너무 멀리 떨어져 있을 수 있는 스윙 포인트 스톱 로즈 위치에서 즉각적인 자본 보호를 제공합니다.

전략적 이점

  1. 다층적 위험 관리삼층적 손해배상 시스템은 다양한 시장 조건과 위험 시나리오에 적응하여 자금의 전면적인 보호를 제공합니다. 이는 이 전략의 가장 큰 장점입니다.

  2. 매우 적응력이 좋다: 모든 구성 요소는 ((슈퍼 트렌드, ADX) 가 시장 조건에 따라 활성화/부활될 수 있으며, 파라미터가 조정될 수 있어 전략이 높은 유연성을 갖는다.

  3. 강력한 트렌드 포착 능력이 전략은 하이켄 아쉬의 명확한 시각적 신호, 슈퍼 트렌드 확인 및 ADX의 트렌드 강도 평가와 결합하여 강력한 트렌드 움직임을 효과적으로 식별할 수 있습니다.

  4. 명확한 시각적 피드백전략은 위치 상태, 입시 가격 및 현재 중단 수준을 차트에 표시하여 거래자가 전략의 수행을 직관적으로 이해하고 추적 할 수 있습니다.

  5. 내장된 자금 관리이 전략은 지분 비율에 기반한 포지션 관리 방법을 사용한다. (비용: 3%) 이 계정 규모의 변화와 함께 리스크 을 일관되게 보장한다.

  6. 완전한 거래 시스템: 추가적인 결정이나 지표가 필요 없이 입문 신호에서 출구 규칙까지의 전체 거래 과정을 제공합니다.

전략적 위험

  1. 과대 최적화 위험: 전략에는 여러 가지 조정 가능한 매개 변수가 포함되어 있으며, 이는 곡선 적합 문제를 일으킬 수 있습니다. 즉, 전략은 역사적 데이터에서 잘 작동하지만 실시간 거래에서는 효과가 없습니다. 해결책은 충분한 역사적 데이터를 사용하여 재검토하고 다양한 시장 조건에서 전략의 강도를 테스트하는 것입니다.

  2. 추세 반전 위험여러 계층의 스톱 메커니즘을 가지고 있음에도 불구하고, 이 전략은 강력한 추세가 급격히 뒤집어지면 큰 반향에 직면할 수 있습니다. 시장의 급격한 변동으로 인해 스톱 스톱이 적시에 발동되지 않아 예상보다 더 많은 손실이 발생할 수 있습니다.

  3. 매개변수 민감도다른 변수 설정은 매우 다른 결과를 초래할 수 있습니다. 특히 슈퍼 트렌드 인자 및 ADX 마이너스. 이것은 거래자가 각 변수의 영향을 깊이 이해하고 특정 시장 환경에 적합한 균형점을 찾는 것을 요구합니다.

  4. 낮은 변동성 환경에서의 실적 저하: 낮은 변동성 또는 가로 시장에서 이 전략은 여러 번의 잘못된 신호를 발생시킬 수 있으며, 이로 인해 “” 거래가 발생할 수 있습니다. 해결책은 이러한 환경에서 거래를 중지하거나, 추가적인 시장 환경 필터를 추가하는 것입니다.

  5. 자금 관리 위험: 고정 비율의 포지션 관리는 모든 시장 환경에 적합하지 않을 수 있으며, 고도로 변동하는 시장에서 위험을 제어하기 위해 포지션 크기를 줄여야 할 수 있습니다.

전략 최적화 방향

  1. 변동성 적응 장치를 강화하는 것: 현재 전략은 역사적인 변동률 ((HV) 또는 암시적인 변동률 ((IV) 지표와 같은 변동성 필터를 도입하여 다른 시장 환경에서 매개 변수를 자동으로 조정할 수 있습니다. 이것은 전략이 높은 변동성과 낮은 변동성 동안 안정적인 성능을 유지할 수있게합니다.

  2. 통합 시간 필터: 시간 기반 필터를 추가하는 것을 고려하고, 알려진 낮은 변동성이나 시장 추세가 약한 시간대에 거래하는 것을 피하십시오. 이것은 특정 품종을 거래하는 데 특히 유용합니다. 왜냐하면 다른 품종은 하루의 다른 시간대에 다른 행동 특성을 나타냅니다.

  3. 기계학습 최적화를 도입합니다.: 기계 학습 기술을 사용하여 정적 변수 설정에 의존하지 않고 자동으로 최적의 변수 조합을 식별 할 수 있습니다. 이것은 역사적 데이터의 패턴을 분석하여 특정 시장 조건에서 어떤 변수 설정이 미래에 가장 잘 작동 할 수 있는지 예측 할 수 있습니다.

  4. 관련 시장 필터를 추가하세요: 관련 시장이나 지수의 행동을 관찰하여 진입 신호를 강화합니다. 예를 들어 특정 품종을 거래할 때 전체 시장의 추세 또는 관련 시장의 강점을 고려합니다.

  5. 손해 방지 제도를 최적화: 현재 3층의 스톱 시스템을 더욱 최적화 할 수 있습니다. 예를 들어, 변동성 동적에 따라 보험 스톱 퍼센티지를 조정하거나, 단순한 회귀 기간의 높고 낮기보다는 흔들리는 스톱을 정확하게 설정하기 위해 지원/저항 수준을 사용합니다.

  6. 통합 거래량 분석: 신호 확인 과정에서 거래량 필터를 추가하여 가격 움직임이 충분한 거래량으로 뒷받침되는지 확인하여 신호의 신뢰성을 높인다.

요약하다

헤이켄 아쉬 트렌드 추적 전략은 헤이켄 아쉬 그래프, 슈퍼 트렌드 지표 및 ADX 필터의 독특한 조합을 통해 강력한 트렌드 속의 동력 기회를 잡는 데 초점을 맞춘 복잡하고 포괄적인 거래 시스템입니다. 3 층의 스톱 시스템은 포괄적인 위험 관리를 제공하며, 사용자 정의 가능한 파라미터 설정은 다양한 시장 조건에 적응 할 수 있도록합니다.

이 전략의 주요 장점은 명확한 시각적 신호, 강력한 트렌드 인식 능력 및 포괄적 인 자금 보호 장치입니다. 그러나 거래자는 변수 최적화의 도전과 낮은 변동성 환경에서 잠재적인 한계를 인식해야합니다.

제안된 최적화 방향을 실행함으로써, 변동성 적응 메커니즘을 추가하고, 시간 필터와 거래량 분석을 통합함으로써, 이 전략은 더욱 안정성과 적응성을 강화할 수 있다. 궁극적으로, 하이켄 아쉬 트렌드 추적 전략은 기술 분석의 명확한 신호와 체계화된 위험 관리의 원칙을 결합한 균형 잡힌 방법을 나타내고, 트렌드 추적 거래자에게 가치 있는 도구를 제공한다.

전략 소스 코드
/*backtest
start: 2025-01-01 00:00:00
end: 2025-04-12 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
*/

//@version=5
strategy("Heiken Ashi Supertrend ADX - Strategy", overlay=true, initial_capital=1000, commission_type=strategy.commission.percent, commission_value=0, calc_on_every_tick=true, process_orders_on_close=false, default_qty_type=strategy.percent_of_equity, default_qty_value=3)


// Supertrend Settings
useSupertrend = input.bool(true, "Use Supertrend for Entries", group="Supertrend Settings")
atrPeriod = input.int(10, "ATR Period", minval=1, group="Supertrend Settings")
factor = input.float(3.0, "Supertrend Factor", minval=0.5, step=0.1, group="Supertrend Settings")

// ADX Filter Settings
useAdxFilter = input.bool(false, "Use ADX Filter", group="ADX Filter")
adxPeriod = input.int(14, "ADX Period", minval=1, group="ADX Filter")
adxThreshold = input.float(25, "ADX Threshold", minval=0, group="ADX Filter")

// Stop Loss Options
useSwingStop = input.bool(false, "Use Swing Point Stop", group="Stop Loss Options")
swingLookback = input.int(3, "Swing Lookback Periods", minval=1, maxval=20, group="Stop Loss Options")

useSafetyNetStop = input.bool(true, "Use Insurance Stop", group="Stop Loss Options")
safetyNetPercent = input.float(5.0, "Insurance Stop Loss Percent", minval=0.1, step=0.1, group="Stop Loss Options")

// Trailing Stop Loss Settings
useTrailingStop = input.bool(true, "Use ATR Trailing Stop", group="Stop Loss Options")
trailAtrMultiplier = input.float(2.0, "Trailing Stop ATR Multiplier", minval=0.1, step=0.1, group="Stop Loss Options")

// Get HA data for signals
ha_security = ticker.heikinashi(syminfo.tickerid)
[o, h, l, c] = request.security(ha_security, timeframe.period, [open, high, low, close])

// Get real price data
real_open = open
real_high = high
real_low = low
real_close = close

// Calculate Supertrend using built-in function with real price data
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
supertrend := barstate.isfirst ? na : supertrend

// Determine if we're in an uptrend or downtrend based on Supertrend
isUptrend = direction < 0   // In TradingView, negative direction means uptrend
isDowntrend = direction > 0 // In TradingView, positive direction means downtrend

// Calculate ATR for visualization
atrValue = ta.atr(atrPeriod)

// Calculate ADX and Trade Logic
[diplus, diminus, adx] = ta.dmi(adxPeriod, adxPeriod)
int trade = 0
if trade == 0 and diplus > diminus
    trade := 1
else if trade == 0 and diminus > diplus
    trade := -1
else if trade == 1 and diminus > diplus
    trade := -1
else if trade == -1 and diplus > diminus
    trade := 1
else
    trade := trade[1]

// Combine with ADX Threshold
isAdxBullish = diplus > diminus and adx > adxThreshold
isAdxBearish = diminus > diplus and adx > adxThreshold

// Debug ADX Values (only if needed for development)
// plot(adx, "ADX", color=color.orange, linewidth=1)
// plot(diplus, "DI+", color=color.green, linewidth=1)
// plot(diminus, "DI-", color=color.red, linewidth=1)
// hline(adxThreshold, "ADX Threshold", color=color.gray, linestyle=hline.style_dashed)

// Check for wicks on the current candle
threshold = syminfo.mintick * 0.1
noBottomWick = math.abs(math.min(o, c) - l) <= threshold
noTopWick = math.abs(h - math.max(o, c)) <= threshold

// Identify candle color and signal conditions
isGreenCandle = c > o
isRedCandle = c < o

// KEY INTEGRATION: Color the real bars based on HA trend
bullishColor = color.green   // Green for long/bullish
bearishColor = color.purple  // Purple for short/bearish
barcolor(isGreenCandle ? bullishColor : bearishColor)

// Signal conditions for both entry and exit
longCondition = (isGreenCandle and noBottomWick and barstate.isconfirmed) and (not useSupertrend or isUptrend) and (not useAdxFilter or isAdxBullish)

shortCondition = (isRedCandle and noTopWick and barstate.isconfirmed) and (not useSupertrend or isDowntrend) and (not useAdxFilter or isAdxBearish)

exitLongCondition = isRedCandle and noTopWick and barstate.isconfirmed
exitShortCondition = isGreenCandle and noBottomWick and barstate.isconfirmed

// Calculate swing points based on real candles (not HA)
swingLow = ta.lowest(real_low, swingLookback)
swingHigh = ta.highest(real_high, swingLookback)

// Position tracking
var int position = 0  // 0 = no position, 1 = long, -1 = short
var float entryPrice = na
var float trailStopLevel = na  // For ATR trailing stop
var float swingStopLevel = na  // For swing point stop
var float safetyNetStopLevel = na  // For safety net stop
var float highestSinceEntry = na  // For tracking highest price since entry (for long positions)
var float lowestSinceEntry = na   // For tracking lowest price since entry (for short positions)

// Alert variables
var bool longAlert = false
var bool shortAlert = false
var bool exitLongAlert = false
var bool exitShortAlert = false

// Reset alerts each bar
longAlert := false
shortAlert := false
exitLongAlert := false
exitShortAlert := false

// Handle entries and exits
if longCondition and (position <= 0)
    if position < 0
        exitShortAlert := true
        strategy.close("Short", comment="Exit Short")
        position := 0
    longAlert := true
    strategy.entry("Long", strategy.long, comment="Enter Long")
    position := 1
    entryPrice := real_close
    highestSinceEntry := real_close
    lowestSinceEntry := na
    // Initialize trailing stops
    if useTrailingStop
        trailStopLevel := real_close - (atrValue * trailAtrMultiplier)
    // Initialize swing point stop
    if useSwingStop
        swingStopLevel := swingLow
    // Initialize safety net stop
    if useSafetyNetStop
        safetyNetStopLevel := real_close * (1 - safetyNetPercent / 100)
        
if shortCondition and (position >= 0)
    if position > 0
        exitLongAlert := true
        strategy.close("Long", comment="Exit Long")
        position := 0
    shortAlert := true
    strategy.entry("Short", strategy.short, comment="Enter Short")
    position := -1
    entryPrice := real_close
    highestSinceEntry := na
    lowestSinceEntry := real_close
    // Initialize trailing stops
    if useTrailingStop
        trailStopLevel := real_close + (atrValue * trailAtrMultiplier)
    // Initialize swing point stop
    if useSwingStop
        swingStopLevel := swingHigh
    // Initialize safety net stop
    if useSafetyNetStop
        safetyNetStopLevel := real_close * (1 + safetyNetPercent / 100)

if position > 0 and exitLongCondition
    exitLongAlert := true
    strategy.close("Long", comment="Exit Long Signal")
    position := 0
    trailStopLevel := na
    swingStopLevel := na
    safetyNetStopLevel := na
    highestSinceEntry := na

if position < 0 and exitShortCondition
    exitShortAlert := true
    strategy.close("Short", comment="Exit Short Signal")
    position := 0
    trailStopLevel := na
    swingStopLevel := na
    safetyNetStopLevel := na
    lowestSinceEntry := na

// Check for swing point stop hit
if useSwingStop and position != 0 and not na(swingStopLevel)
    // For long positions, check if price drops below the swing low
    if position > 0 and real_low <= swingStopLevel
        strategy.close("Long", comment="Swing Point Stop Hit")
        position := 0
        trailStopLevel := na
        swingStopLevel := na
        safetyNetStopLevel := na
        highestSinceEntry := na
        
    // For short positions, check if price rises above the swing high
    else if position < 0 and real_high >= swingStopLevel
        strategy.close("Short", comment="Swing Point Stop Hit")
        position := 0
        trailStopLevel := na
        swingStopLevel := na
        safetyNetStopLevel := na
        lowestSinceEntry := na

// Check for safety net stop loss hit
if useSafetyNetStop and position != 0 and not na(safetyNetStopLevel)
    // For long positions, check if price drops below the safety net level
    if position > 0 and real_low <= safetyNetStopLevel
        strategy.close("Long", comment="Safety Net Stop Hit")
        position := 0
        trailStopLevel := na
        swingStopLevel := na
        safetyNetStopLevel := na
        highestSinceEntry := na
        
    // For short positions, check if price rises above the safety net level
    else if position < 0 and real_high >= safetyNetStopLevel
        strategy.close("Short", comment="Safety Net Stop Hit")
        position := 0
        trailStopLevel := na
        swingStopLevel := na
        safetyNetStopLevel := na
        lowestSinceEntry := na

// Track highest/lowest prices for trailing stop calculation
if position > 0 and not na(highestSinceEntry)
    highestSinceEntry := math.max(highestSinceEntry, real_high)
    
if position < 0 and not na(lowestSinceEntry)
    lowestSinceEntry := math.min(lowestSinceEntry, real_low)

// Update and check trailing stop (ATR-based)
if useTrailingStop and position != 0 and not na(trailStopLevel)
    // Update trailing stop level for long positions
    if position > 0
        // Calculate new potential trailing stop level
        trailStopNew = real_close - (atrValue * trailAtrMultiplier)
        // Only move the stop up, never down
        if trailStopNew > trailStopLevel
            trailStopLevel := trailStopNew
        // Check if price hit stop
        if real_low <= trailStopLevel
            strategy.close("Long", comment="ATR Trailing Stop Hit")
            position := 0
            trailStopLevel := na
            swingStopLevel := na
            safetyNetStopLevel := na
            highestSinceEntry := na
            
    // Update trailing stop level for short positions
    else if position < 0
        // Calculate new potential trailing stop level
        trailStopNew = real_close + (atrValue * trailAtrMultiplier)
        // Only move the stop down, never up
        if trailStopNew < trailStopLevel
            trailStopLevel := trailStopNew
        // Check if price hit stop
        if real_high >= trailStopLevel
            strategy.close("Short", comment="ATR Trailing Stop Hit")
            position := 0
            trailStopLevel := na
            swingStopLevel := na
            safetyNetStopLevel := na
            lowestSinceEntry := na

// Plot stop loss levels
plot(useTrailingStop and position != 0 ? trailStopLevel : na, "ATR Trailing Stop", color=color.yellow, style=plot.style_linebr, linewidth=1)
plot(useSwingStop and position != 0 ? swingStopLevel : na, "Swing Point Stop", color=color.red, style=plot.style_circles, linewidth=2)
plot(useSafetyNetStop and position != 0 ? safetyNetStopLevel : na, "Insurance Stop", color=color.yellow, style=plot.style_circles, linewidth=1)

// Visual signals for chart (just entry/exit markers, no ADX labels)
plotshape(longAlert, title="Long Entry", location=location.abovebar, color=bullishColor, style=shape.triangleup, size=size.small)
plotshape(shortAlert, title="Short Entry", location=location.belowbar, color=bearishColor, style=shape.triangledown, size=size.small)
plotshape(exitLongAlert, title="Long Exit Signal", location=location.abovebar, color=bullishColor, style=shape.xcross, size=size.small)
plotshape(exitShortAlert, title="Short Exit Signal", location=location.belowbar, color=bearishColor, style=shape.xcross, size=size.small)

// Supertrend visualization
bodyMiddlePlot = plot((real_open + real_close) / 2, "Body Middle", display=display.none)
upTrend = plot(useSupertrend and isUptrend ? supertrend : na, "Up Trend", color=bullishColor, style=plot.style_linebr, linewidth=1)
downTrend = plot(useSupertrend and isDowntrend ? supertrend : na, "Down Trend", color=bearishColor, style=plot.style_linebr, linewidth=1)
fill(upTrend, bodyMiddlePlot, color=useSupertrend ? color.new(bullishColor, 85) : na, title="Uptrend Background")
fill(downTrend, bodyMiddlePlot, color=useSupertrend ? color.new(bearishColor, 85) : na, title="Downtrend Background")

// Position background
bgcolor(position == 1 ? color.new(bullishColor, 85) : position == -1 ? color.new(bearishColor, 85) : na, title="Position Background")

// Position label
var label positionLabel = na
label.delete(positionLabel)
if barstate.islast
    positionText = position == 1 ? "LONG" : position == -1 ? "SHORT" : "FLAT"
    entryInfo = not na(entryPrice) ? "\nEntry: " + str.tostring(entryPrice, "#.00000") : ""
    atrStopInfo = useTrailingStop and not na(trailStopLevel) ? "\nATR Stop: " + str.tostring(trailStopLevel, "#.00000") + " (" + str.tostring(trailAtrMultiplier, "#.0") + "x ATR)" : ""
    swingStopInfo = useSwingStop and not na(swingStopLevel) ? "\nSwing Stop: " + str.tostring(swingStopLevel, "#.00000") + " (" + str.tostring(swingLookback) + " bars)" : ""
    safetyNetInfo = useSafetyNetStop and not na(safetyNetStopLevel) ? "\nInsurance Stop: " + str.tostring(safetyNetStopLevel, "#.00000") + " (" + str.tostring(safetyNetPercent, "#.0") + "%)" : ""
    supertrendInfo = useSupertrend ? "\nSupertrend: " + (isUptrend ? "UPTREND" : "DOWNTREND") : ""
    positionColor = position == 1 ? bullishColor : position == -1 ? bearishColor : color.gray
    positionLabel := label.new(bar_index, high, positionText + entryInfo + atrStopInfo + swingStopInfo + safetyNetInfo + supertrendInfo, color=positionColor, style=label.style_label_down, textcolor=color.white)