동적 범위 필터와 결합된 고급 정량적 추세 포착 전략

EMA MA RF VOL SMA HA
생성 날짜: 2024-12-17 14:31:11 마지막으로 수정됨: 2024-12-17 14:31:11
복사: 4 클릭수: 420
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

동적 범위 필터와 결합된 고급 정량적 추세 포착 전략

개요

이 전략은 이동 평균과 동적 범위 필터를 결합한 고급 정량 거래 시스템이다. 그것은 주로 가격 변화와 거래량 사이의 관계를 분석하여 시장 추세를 식별하며, 범위 필터를 사용하여 거짓 신호를 필터링하여 거래의 정확성을 향상시킵니다. 이 전략은 시장의 유동성 경계를 결정하기 위해 적응된 계산 방법을 사용하며, 빠른 속도와 느린 이동 평균을 결합하여 트렌드 방향을 확인합니다.

전략 원칙

이 전략의 핵심 논리는 다음과 같은 몇 가지 핵심 계산에 기반합니다.

  1. 유동성 분석: 거래량과 가격 변화의 비율을 계산하여 시장 유동성을 평가하고 동적인 유동성 경계를 설정합니다.
  2. 트렌드 확인: 50주기 및 100주기의 지수 이동 평균 ((EMA) 을 사용하여 트렌드 방향을 확인한다.
  3. 범위 필터링: 50주기의 샘플링 사이클과 3배의 범위 곱수를 사용하여 동적 거래 영역을 구성한다.
  4. 신호 생성: 가격이 범위 필터를 뚫고 EMA 지표가 동향을 표시할 때 거래 신호를 생성한다.

전략적 이점

  1. 자기 적응력: 전략은 시장 조건에 따라 동적으로 매개 변수를 조정하여 다른 시장 환경에 적응할 수 있습니다.
  2. 신호 신뢰성: 여러 기술 지표와 필터를 결합하여 가짜 신호를 효과적으로 감소시킨다.
  3. 리스크 관리: 자동으로 정지 위치를 계산하여 리스크를 효과적으로 제어할 수 있습니다.
  4. 리포트 기능이 완전하다: 전략 최적화를 위한 상세한 리포트 설정을 포함한다.

전략적 위험

  1. 변수 민감성: 전략의 여러 변수들은 정밀하게 조정되어야 하며, 지나치게 최적화될 수 있다.
  2. 슬라이드 효과: 높은 변동성 시장에서, 더 큰 슬라이드 위험에 직면할 수 있다.
  3. 시장의 적응성: 상반된 시장에서 빈번하게 잘못된 신호가 발생할 수 있다.
  4. 자금 관리: 고정 자금 분배 방식은 모든 시장 조건에 적합하지 않을 수 있습니다.

전략 최적화 방향

  1. 매개 변수 적응: 매개 변수 적응 조정 메커니즘을 도입하여 매개 변수가 시장 상태에 따라 자동으로 조정될 수 있다.
  2. 시장 상태 인식: 시장 상태 판단 모듈을 추가하여 다른 시장 조건에서 다른 거래 전략을 사용합니다.
  3. 자금 관리 최적화: 동적 포지션 관리를 도입하여 시장의 변동성에 따라 거래 규모를 조정한다.
  4. 신호 필터링 강화: 가짜 신호를 필터링하기 위해 더 많은 기술 지표를 추가할 수 있습니다.

요약하다

이 전략은 유동성 분석, 트렌드 추적 및 범위 필터를 결합하여 완전한 정량 거래 시스템을 구축합니다. 이 전략은 시장 변화에 적응하고 신뢰할 수있는 거래 신호를 제공 할 수 있다는 장점이 있지만, 변수 최적화 및 위험 관리에 주의를 기울여야합니다. 지속적인 최적화 및 개선으로 이 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 수 있습니다.

전략 소스 코드
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-15 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=6
strategy("Killer Coin V2 + Range Filter Strategy", shorttitle="KC-RF Strategy", overlay=true
         )

// === INPUT BACKTEST RANGE ===
useDate = input(true, title='---------------- Use Date ----------------', group="Backtest Settings")
FromMonth = input.int(7, title="From Month", minval=1, maxval=12, group="Backtest Settings")
FromDay = input.int(25, title="From Day", minval=1, maxval=31, group="Backtest Settings")
FromYear = input.int(2019, title="From Year", minval=2017, group="Backtest Settings")
ToMonth = input.int(1, title="To Month", minval=1, maxval=12, group="Backtest Settings")
ToDay = input.int(1, title="To Day", minval=1, maxval=31, group="Backtest Settings")
ToYear = input.int(9999, title="To Year", minval=2017, group="Backtest Settings")
start = timestamp(FromYear, FromMonth, FromDay, 00, 00)
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59)
window() => time >= start and time <= finish

// === KILLER COIN V2 INPUTS ===
outlierThreshold = input.int(10, "Outlier Threshold Length", group="Killer Coin Settings")
fastMovingAverageLength = input.int(50, "Fast MA length", group="Killer Coin Settings")
slowMovingAverageLength = input.int(100, "Slow MA length", group="Killer Coin Settings")

// === RANGE FILTER INPUTS ===
sources = input(close, "Source", group="Range Filter Settings")
isHA = input(false, "Use HA Candles", group="Range Filter Settings")
per = input.int(50, "Sampling Period", minval=1, group="Range Filter Settings")
mult = input.float(3.0, "Range Multiplier", minval=0.1, group="Range Filter Settings")

// === KILLER COIN V2 CALCULATIONS ===
priceMovementLiquidity = volume / math.abs(close - open)
liquidityBoundary = ta.ema(priceMovementLiquidity, outlierThreshold) + ta.stdev(priceMovementLiquidity, outlierThreshold)
var liquidityValues = array.new_float(5)

if ta.crossover(priceMovementLiquidity, liquidityBoundary)
    array.insert(liquidityValues, 0, close)

fastEMA = ta.ema(array.get(liquidityValues, 0), fastMovingAverageLength)
slowEMA = ta.ema(array.get(liquidityValues, 0), slowMovingAverageLength)

// === RANGE FILTER CALCULATIONS ===
src = isHA ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, sources) : sources

// Smooth Average Range
smoothrng(x, t, m) =>
    wper = (t*2) - 1
    avrng = ta.ema(math.abs(x - x[1]), t)
    smoothrng = ta.ema(avrng, wper)*m
    smoothrng

smrng = smoothrng(src, per, mult)

// Range Filter
rngfilt(x, r) =>
    rngfilt = x
    rngfilt := x > nz(rngfilt[1]) ? ((x - r) < nz(rngfilt[1]) ? nz(rngfilt[1]) : (x - r)) : ((x + r) > nz(rngfilt[1]) ? nz(rngfilt[1]) : (x + r))
    rngfilt

filt = rngfilt(src, smrng)

// Filter Direction
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])

// Target Bands
hband = filt + smrng
lband = filt - smrng

// === PLOTTING ===
// Killer Coin V2 Plots
bullColor = color.new(#00ffbb, 50)
bearColor = color.new(#800080, 50)
fastPlot = plot(fastEMA, "Fast EMA", color = fastEMA > slowEMA ? bullColor : bearColor)
slowPlot = plot(slowEMA, "Slow EMA", color = fastEMA > slowEMA ? bullColor : bearColor)
fill(fastPlot, slowPlot, color = fastEMA > slowEMA ? bullColor : bearColor)

// Range Filter Plots
filtcolor = upward > 0 ? color.new(color.lime, 0) : downward > 0 ? color.new(color.red, 0) : color.new(color.orange, 0)
filtplot = plot(filt, "Range Filter", color=filtcolor, linewidth=3)
hbandplot = plot(hband, "High Target", color=color.new(color.aqua, 90))
lbandplot = plot(lband, "Low Target", color=color.new(color.fuchsia, 90))
fill(hbandplot, filtplot, color=color.new(color.aqua, 90))
fill(lbandplot, filtplot, color=color.new(color.fuchsia, 90))

// === STRATEGY CONDITIONS ===
// Range Filter Conditions
longCond = ((src > filt) and (src > src[1]) and (upward > 0)) or ((src > filt) and (src < src[1]) and (upward > 0))
shortCond = ((src < filt) and (src < src[1]) and (downward > 0)) or ((src < filt) and (src > src[1]) and (downward > 0))

CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1

// Combined Conditions
finalLongSignal = longCondition and fastEMA > slowEMA and window()
finalShortSignal = shortCondition and fastEMA < slowEMA and window()

// === PLOTTING SIGNALS ===
plotshape(finalLongSignal, "Buy Signal", text="BUY", textcolor=color.white, 
         style=shape.labelup, size=size.normal, location=location.belowbar, 
         color=color.new(color.green, 0))
         
plotshape(finalShortSignal, "Sell Signal", text="SELL", textcolor=color.white, 
         style=shape.labeldown, size=size.normal, location=location.abovebar, 
         color=color.new(color.red, 0))

// === STRATEGY ENTRIES ===
if finalLongSignal
    strategy.entry("Long", strategy.long, stop=hband)
    
if finalShortSignal
    strategy.entry("Short", strategy.short, stop=lband)

// === ALERTS ===
alertcondition(finalLongSignal, "Strong Buy Signal", "🚨 Buy - Both Indicators Aligned!")
alertcondition(finalShortSignal, "Strong Sell Signal", "🚨 Sell - Both Indicators Aligned!")