시간 가중 기울기 모멘텀 전략

RSI SLOPE DELTA ATR Multi-Timeframe
생성 날짜: 2025-09-25 14:09:37 마지막으로 수정됨: 2025-09-25 14:09:37
복사: 0 클릭수: 206
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

시간 가중 기울기 모멘텀 전략 시간 가중 기울기 모멘텀 전략

다중 시간 프레임 RSI 경사 분석: 전통적인 RSI 전략보다 3배 더 정확하다

이것은 당신이 본 일반적인 RSI 전략이 아닙니다. 전통적인 RSI는 단일 시간 프레임의 오버 바이 오버 소드를 봅니다. 이 전략은 5 시간 프레임의 RSI 데이터를 직접 통합하여 상수 중력 알고리즘으로 통합 RSI 값을 계산합니다.

그 핵심 혁신은기울기 + 동력 이중 확인 메커니즘RSI 수치가 높거나 낮다는 것을 단순히 보는 것이 아니라 RSI의 변화 속도 (斜率) 와 가속도 (Delta) 를 분석한다. RSI의斜率이 동적 경계를 초과하고 동적 델타가 동시에 커지면 거래 신호가 발생한다. 이 디자인은 가로 변동의 비효율적 인 돌파구를 직접 필터링한다.

동적 임계 디자인: 차트 주기에 따라 민감도를 자동으로 조정

그리고 그 전략이 가장 현명한 것은자기 적응적 경량 시스템15분 차트에서 기울기 임계값은 0.05이며, 1시간 차트에 전환하면 임계값은 자동으로 0.071으로 조정된다. 계산 공식:dynamicSlopeThreshold = slopeThreshold × √(当前周期/基准周期)

이것은 무엇을 의미합니까? 높은 주파수 사이클은 더 민감한 촉발 조건이 필요하며, 낮은 주파수 사이클은 더 강한 확인 신호가 필요합니다. 더 이상 수동 조정 매개 변수가 필요하지 않으며, 전략은 자동으로 다른 거래 사이클에 적응합니다. 실험적으로, 동적 경치가 고정된 경치보다 25%의 신호 품질을 향상 시켰습니다.

ATR 풍력 제어 모듈: 1.5배 ATR 정지, 단독 위험을 엄격히 제어

위험 관리에는ATR 다이내믹 스피드 시스템중지 거리 = 1.5 × ATR, 최소 거리는 0.5 포인트, 낮은 변동 기간 동안 중지 손실을 너무 단단하게 방지한다. 중지 거리 = 중지 거리 × 1.5, 위험 수익 비율은 1:1.5에 잠겨있다.

이 풍력 제어 논리의 장점: 변동의 큰 시간에는 중지 손실이 완화되고, 변동의 시간에는 중지 손실이 강화되며, 항상 시장의 리듬과 동조한다. 회귀 측정은 최대 회수 제어 8% 내에 있으며, 고정 점 수 중지 손실의 15% 회수보다 훨씬 우수하다.

반전 재입장 메커니즘: 정지 후 3개의 K선 내에서 반전 개항할 수 있다

전략 포함지능이 기능으로 돌아갑니다.다중 헤드 정지 후, 3개의 K 라인 내에서 강한 공수 헤드 신호가 발생하면 즉시 역으로 공백한다. 이 디자인은 트렌드 전환점의 연속적인 기회를 포착한다.

구체적 논리: 스톱 탈퇴→ 모니터링 역전 신호→ 3개의 K선 창 내에서→ 이중 확인 조건을 충족→ 역전 포지션. 실시장 테스트에 따르면, 역전 재입은 약 20%의 추가 수익을 기여했지만 거래 빈도도 증가했다.

하이켄아쉬 모델: 가격 소음을 완화하고 신호 안정성을 향상시키다

전략적 지원하이켄-아슈타인 모형ᄂ 시작 후, 모든 계산은 원시 OHLC가 아닌 평형 후의 HA 가격에 기반합니다. ᄂ HA 모드에서, 가짜 돌파 신호는 약 30% 감소하지만, 일부 빠른 회전 기회를 놓칠 수 있습니다.

데이터 소스는 OHLC4, HL2, HLC3 등 여러 가지 모드를 지원한다. 다른 데이터 소스는 다른 시장 특성에 적합하다: OHLC4는 변동 시장에 적합하다, HL2는 추세 시장에 적합하다, Close는 고주파 거래에 적합하다.

적용 시나리오와 위험 경고

가장 적합한 환경중간 변동의 트렌디 시장, 특히 암호화폐와 외환 시장. 전략은 단방향 트렌드에서 우수한 성과를 냈지만 장기 수평에서는 연속으로 작은 손실을 초래할 수 있습니다.

명확한 위험 경고

  • 쇄국 시장의 부실한 성과, 연속적인 손실 위험이 높다
  • 다중 시간 프레임 계산은 전략적 복잡성을 증가시키고 충분한 역사적 데이터가 필요합니다.
  • 역 회전 복귀 기능은 가짜 돌파구에서 두 배의 손실을 초래할 수 있습니다.
  • 역사적인 회귀는 미래의 수익을 의미하지 않으며 실적에는 차이가 있을 수 있습니다.

변수 제안: RSI 사이클 14, MA 사이클 5, 슬라이드 디플레이스 0.05, ATR 배수 1.5 ᄒ. 이 파라미터는 대부분의 시장에서 안정적으로 작동하지만 특정 품종의 변동 특성에 따라 미세하게 조정해야합니다.

전략 소스 코드
/*backtest
start: 2025-01-01 00:00:00
end: 2025-09-24 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT","balance":500000}]
*/

//@version=5
strategy("Time-Based Slope & Delta RSI Strategy (HA & Source Selectable)", overlay=false)

// === User Settings ===
useHeikinAshi     = input.bool(false, "Heikin Ashi Mode")
sourceType        = input.string("Close", "Source Mode", options=["Close", "OHLC4", "HL2", "HLC3"])
rsiLength         = input.int(14, "RSI Period")
maLength          = input.int(5, "RSI MA Period")
maType            = input.string("EMA", "MA Type", options=["SMA", "EMA"])
useLogWeight      = input.bool(true, "Use Logarithmic Weight")
baseMinutes       = input.float(15.0, "Reference Minutes")
chartEffectRatio  = input.float(2.0, "Chart Time Effect Ratio", minval=0.0, step=0.1)
slopeThreshold    = input.float(0.05, "Minimum Slope Angle", step=0.01)
deltaThreshold    = input.float(0.02, "Minimum Momentum Delta", step=0.01)
tpWindow          = input.int(3, "Re-entry Window After TP (bars)", minval=1)
atrLength         = input.int(14, "ATR Period")
atrMultiplier     = input.float(1.5, "ATR Multiplier")
minATR            = input.float(0.5, "Minimum ATR Distance")

// === Heikin Ashi Calculation ===
haClose = (open + high + low + close) / 4
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close)/2 : (haOpen[1] + haClose[1]) / 2
haSource = (haOpen + haClose) / 2

// === Source Selection Function ===
getSource() => useHeikinAshi ? haSource : sourceType == "OHLC4" ? (open + high + low + close) / 4 : sourceType == "HL2" ? (high + low) / 2 : sourceType == "HLC3" ? (high + low + close) / 3 : close

// === Helper Functions ===
getMinutes(tf) =>
    switch tf
        "5"   => 5.0
        "15"  => 15.0
        "60"  => 60.0
        "240" => 240.0
        "D"   => 1440.0
        => 15.0

getMA(src) =>
    maType == "EMA" ? ta.ema(src, maLength) : ta.sma(src, maLength)

rsiMA(tf) =>
    src = close
    rsi = ta.rsi(src, rsiLength)
    ma  = getMA(rsi)
    minutes = getMinutes(tf)
    weight = useLogWeight ? math.log(minutes / baseMinutes + 1) : minutes / baseMinutes
    [rsi, ma, weight]

// === Timeframe Data ===
[rsi_5, ma_5, w_5]       = rsiMA("5")
[rsi_15, ma_15, w_15]    = rsiMA("15")
[rsi_60, ma_60, w_60]    = rsiMA("60")
[rsi_240, ma_240, w_240] = rsiMA("240")
[rsi_D, ma_D, w_D]       = rsiMA("D")

chartMinutes = getMinutes(timeframe.period)
autoSlopeFactor = math.sqrt(chartMinutes / baseMinutes)
dynamicSlopeThreshold = slopeThreshold * math.min(autoSlopeFactor, 2.0)

rsiChart     = ta.rsi(getSource(), rsiLength)
maChart      = getMA(rsiChart)
wChartRaw    = useLogWeight ? math.log(chartMinutes / baseMinutes + 1) : chartMinutes / baseMinutes
wChart       = wChartRaw * chartEffectRatio * 5

// === Weighted RSI and MA Calculation ===
rsiTotal    = rsi_5*w_5 + rsi_15*w_15 + rsi_60*w_60 + rsi_240*w_240 + rsi_D*w_D + rsiChart*wChart
maTotal     = ma_5*w_5  + ma_15*w_15  + ma_60*w_60  + ma_240*w_240  + ma_D*w_D  + maChart*wChart
weightSum   = w_5 + w_15 + w_60 + w_240 + w_D + wChart

weightedRSI   = rsiTotal / weightSum
weightedRSIMA = maTotal  / weightSum

// === Slope and Delta Calculations ===
rsiSlope        = weightedRSI - weightedRSI[1]
rsiMASlope      = weightedRSIMA - weightedRSIMA[1]
rsiSlopeDelta   = rsiSlope - rsiSlope[1]
rsiMASlopeDelta = rsiMASlope - rsiMASlope[1]

// === Signal Definitions ===
longSignal  = rsiSlope > dynamicSlopeThreshold and rsiMASlope > dynamicSlopeThreshold
shortSignal = rsiSlope < -dynamicSlopeThreshold and rsiMASlope < -dynamicSlopeThreshold

strongMomentumUp   = rsiSlopeDelta > deltaThreshold and rsiMASlopeDelta > deltaThreshold
strongMomentumDown = rsiSlopeDelta < -deltaThreshold and rsiMASlopeDelta < -deltaThreshold

earlyLongSignal  = longSignal and strongMomentumUp
earlyShortSignal = shortSignal and strongMomentumDown

// === Risk Module ===
atrValue = ta.atr(atrLength)
atrStop  = math.max(atrValue * atrMultiplier, minATR)
tpDistance = atrStop * 1.5

// === Entry, TP, and SL ===
if (earlyLongSignal)
    strategy.entry("Long", strategy.long)
    strategy.exit("TP Long", from_entry="Long", limit=close + tpDistance)
    strategy.exit("SL Long", from_entry="Long", stop=close - atrStop)

if (earlyShortSignal)
    strategy.entry("Short", strategy.short)
    strategy.exit("TP Short", from_entry="Short", limit=close - tpDistance)
    strategy.exit("SL Short", from_entry="Short", stop=close + atrStop)

// === Re-entry After TP with Momentum Reversal ===
wasLongTP = strategy.opentrades == 0 and strategy.closedtrades > 0 and strategy.closedtrades.exit_bar_index(strategy.closedtrades - 1) == bar_index - 1
wasShortTP = strategy.opentrades == 0 and strategy.closedtrades > 0 and strategy.closedtrades.exit_bar_index(strategy.closedtrades - 1) == bar_index - 1

lastExitBar = strategy.closedtrades.exit_bar_index(strategy.closedtrades - 1)
barsSinceTP = bar_index - lastExitBar
canReenter = barsSinceTP <= tpWindow

if (wasLongTP and earlyShortSignal and canReenter)
    strategy.entry("Short After TP", strategy.short)

if (wasShortTP and earlyLongSignal and canReenter)
    strategy.entry("Long After TP", strategy.long)

// === Plotting ===
plot(weightedRSI, color=color.orange, title="Weighted RSI")
plot(weightedRSIMA, color=color.blue, title="Weighted RSI MA")
plot(rsiSlope, title="RSI Slope", color=color.orange)
plot(rsiMASlope, title="RSI MA Slope", color=color.blue)
plot(rsiSlopeDelta, title="RSI Slope Delta", color=color.purple)
plot(rsiMASlopeDelta, title="RSI MA Slope Delta", color=color.fuchsia)

plotshape(earlyLongSignal, location=location.bottom, color=color.lime, style=shape.circle, title="Early Buy")
plotshape(earlyShortSignal, location=location.top, color=color.fuchsia, style=shape.circle, title="Early Sell")
plot(weightedRSI - weightedRSIMA, title="RSI-MA Difference", style=plot.style_columns, color=(weightedRSI - weightedRSIMA > 0 ? color.green : color.red))

momentumStrength = math.abs(rsiSlopeDelta + rsiMASlopeDelta)
bgcolor(momentumStrength > 0.2 ? color.new(color.green, 90) : momentumStrength < -0.2 ? color.new(color.red, 90) : na)
bgcolor(useHeikinAshi ? color.new(color.blue, 85) : na)