Hull 이동평균 전략과 결합된 다중 기간 Bollinger 모멘텀 돌파 전략

VWMA HMA BB MTF RSI
생성 날짜: 2024-11-29 17:00:00 마지막으로 수정됨: 2024-11-29 17:00:00
복사: 0 클릭수: 507
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

Hull 이동평균 전략과 결합된 다중 기간 Bollinger 모멘텀 돌파 전략

개요

이 전략은 Bollinger Bands, Hull Moving Average 및 가중된 이동 평균을 결합하여 거래 신호를 생성하는 다중 시간 프레임 분석을 기반으로 한 거래 시스템입니다. 전략은 주로 1 시간 시간 프레임에서 작동하며 5 분, 1 시간, 3 시간 3 시간 주기 시장 데이터를 통합하여 여러 기술 지표의 조합을 통해 거래 기회를 확인합니다. 전략은 동적인 스톱 스톱 손실 메커니즘을 채택하고 계정 권익에 따라 자동으로 위치 크기를 조정하여 위험을 효과적으로 제어합니다.

전략 원칙

전략의 핵심 논리는 여러 기술 지표의 교차 확인을 기반으로 한다. 여러 시간 주기에서 동시에 가격과 다양한 종류의 평행선의 관계를 모니터링한다. 여기에는 5분 주기 중화 이동 평균 (VWMA), 1시간 주기 중화 이동 평균 (WMA) 및 3시간 주기 중 Hull 이동 평균 (HMA) 이 포함된다. 가격이 모든 시간 주기 지표의 상위에 있을 때, 시스템은 가격 돌파구가 있을 때 여러 신호를 낸다. 반대로, 가격이 모든 지표의 아래에 있을 때, 시스템은 가격 돌파구가 있을 때 빈 신호를 낸다. 전략은 또한 편차 계산 (deviation) 을 도입한다.

전략적 이점

  1. 다중 시간 주기의 분석은 가짜 돌파의 위험을 낮추고 거래 신호의 신뢰성을 높입니다.
  2. 동적 스톱 스톱 손실 설정은 다양한 시장 환경에 적응할 수 있습니다
  3. 계정 이자 기반의 포지션 관리는 자금 사용의 합리성을 보장합니다.
  4. 다양한 출전 메커니즘의 선택은 전략의 적응력을 높였습니다.
  5. 그래픽 인터페이스는 거래 신호를 명확하게 표시하여 분석 및 판단을 용이하게 합니다.
  6. 거래 결정의 정확성을 높이기 위해 여러 정교한 기술 지표를 통합합니다.

전략적 위험

  1. 다중 지표의 사용은 거래 신호의 지연을 초래할 수 있습니다.
  2. 변동성이 큰 시장에서는 빈번하게 잘못된 돌파 신호가 발생할 수 있습니다.
  3. 고정 스톱 스톱 손실 비율은 모든 시장 환경에 적합하지 않을 수 있습니다.
  4. 다중 시간 주기 데이터 처리는 전략 실행의 복잡성을 증가시킬 수 있다.
  5. 높은 변동성 시장에서 더 큰 슬라이드 리스크가 발생할 수 있습니다.

전략 최적화 방향

  1. 이익실현 및 손절매 수준을 동적으로 조정하기 위한 변동성 지표 소개
  2. 시장 환경 인식 기능을 추가하여 다른 시장 상태에서 다른 파라미터 설정을 사용합니다.
  3. 신호 필터링 메커니즘을 최적화하여 가짜 침입으로 인한 손실을 줄입니다.
  4. 거래량 분석을 추가하여 브레이크 신호의 신뢰성을 높여줍니다.
  5. 전략의 안정성을 높이기 위해 적응 가능한 변수 최적화 메커니즘 개발

요약하다

이 전략은 다중 시간 주기의 분석과 다중 기술 지표의 결합을 통해 비교적 완전한 거래 시스템을 구축한다. 전략의 장점은 신호의 신뢰성과 위험 관리의 효과에 있다. 그러나 동시에 신호의 지연과 파라미터 최적화 등의 문제가 있다. 지속적인 최적화와 개선으로 전략은 다양한 시장 환경에서 안정적인 성능을 유지할 것으로 보인다.

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

//@version=5
strategy("1H- 280, 2.7", overlay=true)


// Fetch the indicator values from different timeframes
vwma5 = request.security(syminfo.tickerid, "5", ta.wma(close, 233), lookahead = barmerge.lookahead_off)
vwma_hourly = request.security(syminfo.tickerid, "60", ta.wma(close, 89), lookahead = barmerge.lookahead_off)
hullma155_3h = request.security(syminfo.tickerid, "180", ta.hma(close, 155), lookahead = barmerge.lookahead_off)


// Calculate the deviation value
deviation = close * 0.032


// Initialize the signal variables
var float signalLine = na
var color lineColor = na


// Long Entry Conditions
longCondition_5min = close > vwma5
longCondition_hourly = close > vwma_hourly
longCondition_3h = close > hullma155_3h


// Short Entry Conditions
shortCondition_5min = close < vwma5
shortCondition_hourly = close < vwma_hourly
shortCondition_3h = close < hullma155_3h


// Long Entry
if longCondition_5min and longCondition_hourly and longCondition_3h
    signalLine := close + deviation
    lineColor := color.rgb(0, 255, 0, 1)


// Short Entry
if shortCondition_5min and shortCondition_hourly and shortCondition_3h
    signalLine := close - deviation
    lineColor := color.rgb(255, 0, 0, 1)


// Plotting the connecting line
plot(signalLine, title="Signal Line", color=lineColor, linewidth=1, style=plot.style_line)


// Colorize the signal line
bgcolor(signalLine > close ? color.rgb(0, 255, 0, 99) : color.rgb(255, 0, 0, 99), transp=90)



// Strategy settings
useTPSL = input(true, "Use TP/SL for closing long positions?")
useDownbreakOutbreak = input(false, "Use Downbreak and Outbreak for closing positions?")
useM7FClosing = input(false, "Use M7F Signal for closing positions?")


length1 = input.int(280, minval=1)
src = input(close, title="Source")
mult = input.float(2.7, minval=0.001, maxval=50, title="StdDev")


basis = ta.vwma(src, length1)
dev = mult * ta.stdev(src, length1)
upper = basis + dev
lower = basis - dev


offset = input.int(0, "Offset", minval = -500, maxval = 500)


length2 = input.int(55, minval=1)
src2 = input(close, title="Source")
hullma = ta.wma(2 * ta.wma(src2, length2 / 2) - ta.wma(src2, length2), math.floor(math.sqrt(length2)))


hullmacrosslower = ta.crossover(hullma, lower)
hullmacrossupper = ta.crossunder(hullma, upper)


breakout = ta.crossover(ohlc4, upper)
breakdown = ta.crossunder(ohlc4, upper)
outbreak = ta.crossover(ohlc4, lower)
downbreak = ta.crossunder(ohlc4, lower)


// Calculate position size and leverage
margin_pct = 1
leverage = 1
position_size = strategy.equity * margin_pct
qty = position_size / close / leverage


// Define take profit and stop loss levels
take_profit = 0.14
stop_loss = 0.06


// Opening a long position
if breakout
    strategy.entry("Long", strategy.long, qty, limit=close*(1+take_profit), stop=close*(1-stop_loss))


// Opening a short position
if downbreak
    strategy.entry("Short", strategy.short, qty, limit=close*(1-take_profit), stop=close*(1+stop_loss))


// Closing positions based on chosen method
if useTPSL
    // Using TP/SL for closing long positions
    if strategy.position_size > 0 and breakdown
        strategy.close("Long", comment="Breakdown")
else if useDownbreakOutbreak
    // Using Downbreak and Outbreak for closing positions
    if strategy.position_size > 0 and (breakdown or downbreak)
        strategy.close("Long", comment="Breakdown")
    if strategy.position_size < 0 and (outbreak or downbreak)
        strategy.close("Short", comment="Outbreak")
else if useM7FClosing
    // Using M7F Signal for closing positions
    if strategy.position_size > 0 and (signalLine < close)
        strategy.close("Long", comment="M7F Signal")
    if strategy.position_size < 0 and (signalLine > close)
        strategy.close("Short", comment="M7F Signal")


// Plotting entry signals
plotshape(hullmacrosslower, title="High Bear Volatility", style=shape.arrowup, text="^^^^^", color=color.rgb(75, 202, 79), location=location.belowbar)
plotshape(hullmacrossupper, title="High Bull Volatility", style=shape.arrowdown, text="-----", color=color.rgb(215, 72, 72), location=location.abovebar)
plotshape(breakout ? 1 : na, title="Breakout", style=shape.arrowup, text="", color=color.rgb(75, 202, 79), location=location.belowbar, size=size.tiny)
plotshape(breakdown ? 1 : na, title="Breakdown", style=shape.arrowdown, text="", color=color.rgb(201, 71, 71), location=location.abovebar, size=size.tiny)
plotshape(outbreak ? 1 : na, title="Outbreak", style=shape.arrowup, text="", color=color.rgb(0, 110, 255), location=location.belowbar, size=size.tiny)
plotshape(downbreak ? 1 : na, title="Downbreak", style=shape.arrowdown, text="", color=color.rgb(255, 111, 0), location=location.abovebar, size=size.tiny)