다중 시간 프레임 적응형 동적 KDJ 지표 전략

MTF-ADK ATR EMA KDJ TSL
생성 날짜: 2025-04-03 14:27:21 마지막으로 수정됨: 2025-04-03 15:13:59
복사: 0 클릭수: 429
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

다중 시간 프레임 적응형 동적 KDJ 지표 전략 다중 시간 프레임 적응형 동적 KDJ 지표 전략

개요

이것은 혁신적인 다중 시간 프레임 자기 적응 KDJ 흔들림 지표 전략입니다. 이는 지표 매개 변수를 동적으로 조정하고 여러 시간 프레임에 걸쳐 시장 추세를 분석하여 더 정확하고 유연한 거래 신호를 제공하기 위해 고안되었습니다. 이 전략은 변동성 기반의 길이 계산, 여러 시간 프레임에 걸쳐 무게 분배 및 자기 적응 트렌드 판단을 결합하여 거래자에게 복잡하고 강력한 분석 도구를 제공합니다.

전략 원칙

이 전략의 핵심에는 다음과 같은 핵심 기술들이 포함되어 있습니다.

  1. 다중 시간 프레임 분석: 동시에 1분, 5분, 15분 세 시간 프레임을 사용
  2. 적응 스윙 길이 계산: 시장 변동률에 따라 동적으로 조정된 지표 파라미터
  3. 동적 무게 분배: 다른 시간 프레임에 다른 무게 계수를 배분
  4. 트렌드 판단 메커니즘: 매끄러운 AvgTotal의 평균을 계산하여 시장의 트렌드 방향을 결정합니다.
  5. 스마트 신호 생성: 주요 신호와 예상 신호를 결합하여 신호 정확도를 높인다.

전략적 이점

  1. 높은 유연성: 사용자 정의 시간 프레임 및 무게 설정
  2. 동적 적응성: 시장의 변동에 따라 지표 변수를 조정
  3. 다차원 분석: 여러 시간 프레임의 정보를 통합
  4. 낮은 지연 신호: 주요 신호와 예상 신호를 포함
  5. 내장 트렌드 필터: 불리한 시장 조건에서 잘못된 신호를 줄이는 방법

전략적 위험

  1. 매개 변수 오버피칭 위험
  2. 다중 시간 프레임은 신호의 복잡성을 증가시킬 수 있습니다.
  3. 극한 시장 조건에서 신호 신뢰성이 떨어질 수 있다.
  4. 추가 확인이 필요한 지표 확인 신호

전략 최적화 방향

  1. 기계 학습 알고리즘을 도입하여 동적으로 무게를 조정합니다
  2. 추가 필터링 조건
  3. 손해 방지 제도를 최적화
  4. 종자 간 적응력을 개발하는 것

요약하다

이 다중 시간 프레임은 혁신적인 디자인으로 KDJ의 흔들림 지표 전략에 적응하여 거래자에게 유연하고 역동적이며 다차원적인 시장 분석 도구를 제공하며, 기술적인 우수성과 잠재적인 성능 향상을 위한 공간을 제공합니다.

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

// This Pine Script™ is subject to the Mozilla Public License 2.0 (https://mozilla.org/MPL/2.0/)
// © Lausekopf

//@version=5
strategy("Adaptive KDJ (MTF)", overlay=false)

// Dropdown for the swing length calculation method
method = input.int(1, title="Calculation Method", options=[1, 2, 3], tooltip="1: Volatility Based\n2: Inverse Volatility\n3: Fixed Length")

// Fixed length for method 3
fixedLength = input.int(9, title="Fixed KDJ Length", minval=3, maxval=15)

// Timeframes
tf1 = input.timeframe("1", title="Timeframe 1")
tf2 = input.timeframe("5", title="Timeframe 2")
tf3 = input.timeframe("15", title="Timeframe 3")

// Timeframe weighting
weightOption = input.int(1, title="Timeframe Weighting", options=[1, 2, 3, 4, 5])
weightTF1 = weightOption == 1 ? 0.5 : weightOption == 2 ? 0.4 : weightOption == 3 ? 0.33 : weightOption == 4 ? 0.2 : 0.1
weightTF2 = 0.33
weightTF3 = 1.0 - (weightTF1 + weightTF2)

// EMA smoothing length
smoothingLength = input.int(5, title="EMA Smoothing Length", minval=1, maxval=50)

// Trend calculation period
trendLength = input.int(40, title="Trend Calculation Period", minval=5, maxval=50)

// KDJ function
f_kdj(len, srcHigh, srcLow, srcClose) =>
    roundedLen = int(math.round(len))
    high_max = ta.highest(srcHigh, roundedLen)
    low_min = ta.lowest(srcLow, roundedLen)
    rsv = 100 * (srcClose - low_min) / (high_max - low_min)
    k = ta.sma(rsv, 3)
    d = ta.sma(k, 3)
    j = 3 * k - 2 * d
    [k, d, j]

// Swing length function
f_swingLength(tf) =>
    atrLen = 14
    volatility = request.security(syminfo.tickerid, tf, ta.atr(atrLen) / close)
    var float length = na
    if method == 1
        length := volatility > 0.03 ? 3 : volatility > 0.002 ? 14 : 15
    if method == 2
        length := 18
    if method == 3
        length := fixedLength
    length

// Calculate swing lengths for each timeframe
swingLength1 = f_swingLength(tf1)
swingLength2 = f_swingLength(tf2)
swingLength3 = f_swingLength(tf3)

// Calculate KDJ values
[k1, d1, j1] = f_kdj(swingLength1, request.security(syminfo.tickerid, tf1, high), request.security(syminfo.tickerid, tf1, low), request.security(syminfo.tickerid, tf1, close))
[k2, d2, j2] = f_kdj(swingLength2, request.security(syminfo.tickerid, tf2, high), request.security(syminfo.tickerid, tf2, low), request.security(syminfo.tickerid, tf2, close))
[k3, d3, j3] = f_kdj(swingLength3, request.security(syminfo.tickerid, tf3, high), request.security(syminfo.tickerid, tf3, low), request.security(syminfo.tickerid, tf3, close))

// Weighted averages
avgK = (k1 * weightTF1 + k2 * weightTF2 + k3 * weightTF3)
avgD = (d1 * weightTF1 + d2 * weightTF2 + d3 * weightTF3)
avgJ = (j1 * weightTF1 + j2 * weightTF2 + j3 * weightTF3)
smoothAvgK = ta.ema(avgK, smoothingLength)
smoothAvgD = ta.ema(avgD, smoothingLength)
smoothAvgJ = ta.ema(avgJ, smoothingLength)
smoothAvgTotal = ta.ema((avgK + avgD + avgJ) / 3, smoothingLength)

// Trend determination
trendAvg = ta.sma(smoothAvgTotal, trendLength)
isUptrend = trendAvg > 60
isDowntrend = trendAvg < 40

// Dynamic signal thresholds
buyLevel = isUptrend ? 40 : isDowntrend ? 15 : 25
sellLevel = isUptrend ? 85 : isDowntrend ? 60 : 75

// Buy/Sell signals
buySignal = smoothAvgJ < buyLevel and ta.crossover(smoothAvgK, smoothAvgD)
sellSignal = smoothAvgJ > sellLevel and ta.crossunder(smoothAvgK, smoothAvgD)

// Anticipated signals
anticipateBuy = (smoothAvgK - smoothAvgK[1]) > 0 and (smoothAvgD - smoothAvgD[1]) < 0 and math.abs(smoothAvgK - smoothAvgD) < 5
anticipateSell = (smoothAvgK - smoothAvgK[1]) < 0 and (smoothAvgD - smoothAvgD[1]) > 0 and math.abs(smoothAvgK - smoothAvgD) < 5

// Entry conditions
longEntryCondition = (buySignal or anticipateBuy) and smoothAvgTotal < 22
shortEntryCondition = (sellSignal or anticipateSell) and smoothAvgTotal > 78

// Entry orders
strategy.entry("Long", strategy.long, when=longEntryCondition)
strategy.entry("Short", strategy.short, when=shortEntryCondition)

// Trailing Stop-Loss
atrMultiplierTSL = 2.5
atrValueTSL = ta.atr(12) * atrMultiplierTSL
strategy.exit("TSL Long", from_entry="Long", trail_points=atrValueTSL / syminfo.mintick, stop=open * 0.9972)
strategy.exit("TSL Short", from_entry="Short", trail_points=atrValueTSL / syminfo.mintick, stop=open * 1.0028)

// Plot signals
plotshape(series=buySignal, location=location.bottom, style=shape.triangleup, color=color.green, size=size.small)
plotshape(series=sellSignal, location=location.top, style=shape.triangledown, color=color.red, size=size.small)
plotshape(series=anticipateBuy, location=location.bottom, style=shape.triangleup, color=color.blue, size=size.tiny, offset=-1)
plotshape(series=anticipateSell, location=location.top, style=shape.triangledown, color=color.orange, size=size.tiny, offset=-1)

// Plot KDJ lines
plot(smoothAvgK, color=color.blue, linewidth=1)
plot(smoothAvgD, color=color.orange, linewidth=1)
plot(smoothAvgJ, color=color.purple, linewidth=1)
plot(smoothAvgTotal, color=color.white, linewidth=1)

// Alert for impending signals
alertcondition(anticipateBuy or anticipateSell, title='Impending KDJ Crossover', message='Possible KDJ crossover detected!')
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Lausekopf