고시간대 가중 이동평균선 구간 돌파 양적 거래 전략

WMA HTF TP/SL Zone Trading Breakout Strategy risk management
생성 날짜: 2025-05-26 14:50:17 마지막으로 수정됨: 2025-05-26 14:50:17
복사: 0 클릭수: 249
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

고시간대 가중 이동평균선 구간 돌파 양적 거래 전략 고시간대 가중 이동평균선 구간 돌파 양적 거래 전략

개요

고시계 중도 이동 평균 간격 돌파량 거래 전략은 고시계 중도 이동 평균 간격 돌파구를 기반으로 한 거래 시스템으로, 고시계 중도 이동 평균 ((WMA) 와 비율 간격을 결합하여 거래 지역을 구성합니다. 이 전략은 가격 돌파구가 궤도에 오르거나 떨어지는 상황을 식별하여 입문 신호를 생성하고, 분기 수익 및 중지 설정을 적용하여 위험을 관리합니다. 이 전략의 핵심은 더 높은 시간 프레임에서 중도 이동 평균 라인을 사용하여 단기 시장 소음을 제거하고, 현재 시간 프레임에서 거래 지역을 구성하는 것입니다.

전략 원칙

이 전략의 기본 원칙은 높은 시간 프레임의 가중 이동 평균을 사용하여 가격 활동 영역을 구성하는 것입니다. 구체적인 구현 단계는 다음과 같습니다:

  1. 우선, 전략은 오픈 가격, 최고 가격, 최저 가격 및 종료 가격의 가중 이동 평균을 계산합니다.
  2. 이 WMA 값들을 더 높은 시간 프레임 (기본 월 라인) 에서 현재의 거래 시간 프레임으로 변환합니다.
  3. 중화 이동 평균의 중간 지점을 중심 가격으로 계산한다.
  4. 중앙 가격과 사용자 정의의 비율을 기반으로 ((0.1 또는 10%를 기본으로), 오프레일 ((저항 자리) 과 오프레일 ((지원 자리) 을 구성한다)
  5. 가격이 상향으로 오르면 다중 신호가 발생하고, 가격이 하향으로 하향으로 오르면 공백 신호가 발생한다.
  6. 이 전략은 두 개의 정지 목표를 설정했다 (% 10과 20%를 기본으로), 각 목표 청산 부분 지위 (% 50을 기본으로) 였다.
  7. 동시에 잠재적인 손실을 제한하기 위해 스톱을 설정합니다.

전략은 배경 색상 변화, 사용자 정의 그래프 및 입출력 표시와 같은 시각적 요소를 사용하여 거래자를 직관적으로 거래 간격과 현재 시장 상태를 식별 할 수 있습니다. 또한 전략은 현재 포지션의 비율 변화를 표시하고 곱하기 인자를 적용합니다. (기본적으로 20) 가격 변화를 강조하기 위해.

전략적 이점

이 전략의 코드를 더 깊이 분석하면 다음과 같은 중요한 장점을 발견할 수 있습니다.

  1. 고시각 필터더 높은 시간 프레임의 가중 이동 평균을 사용하여, 전략은 단기 시장 소음을 효과적으로 제거하고, 더 의미있는 가격 움직임을 포착하고, 거짓 신호를 줄일 수 있습니다.

  2. 동적 거래 구역이 전략은 가격 중점과 비율을 기반으로 거래 범위를 동적으로 구성하여 다양한 시장 조건과 변동성에 적응할 수 있으며 고정된 지지/저항의 한계를 피합니다.

  3. 명확한 입출장 규칙전략은 명확한 진입 신호를 제공하며, 거래 결정에서 주관성을 제거합니다.

  4. 리스크 관리 통합: 내장된 중지 및 분기 중지 메커니즘은 자본을 보호하고 이익을 잠금하는 데 도움이되며, 완전한 거래 시스템입니다.

  5. 시각적 피드백전략: 전략은 거래 구역 배경 색상, 비율 변화 태그 및 입출력 표시를 포함한 풍부한 시각적 요소를 제공하여 거래자가 시장 상황을 신속하게 평가할 수 있도록 도와줍니다.

  6. 유연한 변수 설정: 사용자는 개인 취향과 다른 시장 조건에 따라 시간 프레임, 이동 평균 주기, 비율 비율, 스톱/스트로스 레벨 및 시각적 요소를 포함하여 여러 파라미터를 조정할 수 있습니다.

  7. 다중 시간 프레임 조정이 전략은 높은 시간 프레임의 신호 품질과 현재 시간 프레임의 실행 정밀도를 결합하여 여러 시간 프레임의 조화를 구현한다.

전략적 위험

이 전략은 많은 장점이 있지만, 다음과 같은 잠재적인 위험도 있습니다.

  1. 가짜 신호를 뚫고: 가격이 한동안 범위를 돌파한 후 다시 내려가며 잘못된 거래 신호를 유발할 수 있다. 이 위험을 줄이기 위해, 가격의 돌파 이후 한동안 유지되는 것을 요구하거나, 다른 지표와 함께 확인하는 등의 확인 메커니즘을 추가하는 것을 고려할 수 있다.

  2. 높은 변동성 시장에 적합하지 않습니다.급격히 변동하는 시장에서, 가격이 빈번하게 간격 경계를 뚫고 지나치게 많은 거래와 잠재적인 손실을 초래할 수 있습니다. 이 경우 간격 비율을 증가시키거나 더 높은 시간 프레임으로 전환 할 수 있습니다.

  3. 고정된 손실 비율/정지 유연성이 부족합니다.시장의 변동성은 시간이 지남에 따라 변하며 고정된 비율의 중지/정지점이 항상 최적이 아닐 수 있습니다. 변동성 지표 (ATR과 같은) 에 따라 중지/정지 수준을 동적으로 조정하는 것을 고려할 수 있습니다.

  4. 매개변수 민감도: 전략 성능은 WMA 주기, 간격 비율 및 중지/손실 비율과 같은 파라미터 설정에 매우 민감할 수 있습니다. 충분한 역사 회귀 및 파라미터 최적화가 필요합니다.

  5. 과대 최적화 위험: 특정 역사 데이터에 대한 과도한 적합성은 미래의 성과에 악영향을 미칠 수 있습니다. 여러 시장과 시간대에 걸쳐 재검토를 실시하고, 파라미터를 상대적으로 안정적으로 유지하는 것이 좋습니다.

  6. 시장 추세 변화에 대한 적응: 이 전략은 반열을 뚫은 후 새로운 시장 추세에 따라 반열을 조정하지 않습니다. 이것은 강한 추세 시장에서 잘못된 신호를 초래할 수 있습니다. 추세 필터 또는 동적 조정 반열을 추가하는 것을 고려할 수 있습니다.

전략 최적화 방향

코드의 심층적인 분석을 바탕으로, 이 전략은 다음과 같은 방향으로 최적화될 수 있습니다:

  1. 브레이크 확인 메커니즘 추가가짜 브레이크를 줄이기 위해 추가 확인 조건을 추가할 수 있습니다. 예를 들어, 브레이크 후의 종결 가격, 거래량 확인 또는 다른 기술 지표 (RSI, MACD와 같은) 를 사용하여 교차 확인을 요청할 수 있습니다.

  2. 동적 중지 손해 설정: 고정된 퍼센티지 스톱을 시장의 변동성에 기반한 동적 스톱으로 대체하여, 예를 들어 ATR (Average True Range) 의 배수를 사용하여 스톱 레벨을 설정하여, 전략이 다른 시장 조건에 더 잘 적응하도록 한다.

  3. 트렌드 필터에 가입하세요: 장기 이동 평균 또는 ADX 지표와 같은 트렌드 인식 구성 요소를 추가하여 강한 트렌드 시장에서 거래 행동을 조정합니다. 예를 들어 상승 추세에서 더 많이하고 하향 추세에서 더 많이하지 않습니다.

  4. 입학 시점을 최적화: 현재 전략은 가격이 지점 경계를 통과했을 때 즉시 진입하는 것이 가능하며, 반회 또는 특정 형식의 확인을 기다리는 것을 고려하여 진입 시기의 질을 향상시킬 수 있습니다.

  5. 자금 관리 모듈을 추가: 더 복잡한 포지션 크기를 계산하여, 고정된 포지션을 사용하는 대신, 계좌 규모, 시장의 변동성 및 현재 거래의 위험에 따라 포지션 크기를 동적으로 조정합니다.

  6. 시장 상태 필터를 추가합니다.: 시장의 상태를 식별 (예: 트렌드, 간격의 흔들림 또는 높은 변동) 하고, 다른 시장 상태에 따라 전략 파라미터를 조정하거나 거래를 중지한다.

  7. 적응형 매개변수 구현: 간격 비율, WMA 주기 등과 같은 핵심 매개 변수가 역사적인 변동성이나 다른 시장 특성에 따라 자동으로 조정되어 전략의 적응성을 향상시킵니다.

  8. 다중 시간 프레임 신호 통합: 높은 시간 프레임의 WMA를 사용하여 범위를 구성하는 것뿐만 아니라, 더 포괄적인 시장 분석과 거래 결정을 위해 여러 시간 프레임의 가격 행동과 지표를 분석 할 수 있습니다.

요약하다

고시장 가중 이동 평균 간격 돌파량 거래 전략은 고시장 가중 이동 평균과 동적 간격을 결합하여 가격 돌파 기회를 잡기 위해 구성된 구조화된 거래 시스템입니다. 전략의 장점은 고시장 필터링 능력, 명확한 거래 규칙, 내장 된 위험 관리 장치 및 풍부한 시각적 피드백에 있습니다. 그러나, 그것은 또한 잘못된 신호, 변수 민감성 및 시장 적응성 등의 도전에 직면합니다.

이 전략의 안정성과 수익성을 더욱 강화할 수 있는 방법은 브레이크 확인 메커니즘, 다이내믹 스톱 세팅, 트렌드 필터링 및 적응 파라미터를 추가하는 것과 같은 제안된 최적화 방향을 구현하는 것입니다. 무엇보다도, 거래자는 전략의 원리를 완전히 이해하고 충분한 역사적 회귀를 통해 특정 시장과 개인 위험 선호에 따라 파라미터를 조정하여 전략의 잠재력을 최대한 발휘해야합니다.

이 격차를 기반으로 한 전략은 중장기 거래자에게 적합하며, 특히 위험을 통제하면서 중요한 가격 돌파구를 포착하려는 거래자에게 적합합니다. 지속적인 최적화와 조정으로 이 전략은 거래자의 도구 상자에 강력한 무기가 될 수 있습니다.

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

//@version=5
strategy('ZONE FLOW', overlay=true)

// Input parameters
src = close
src1 = open
src2 = low
src3 = high
Min = input(60, title='Minimum Period')
len = timeframe.isintraday and timeframe.multiplier >= 1 ? Min / timeframe.multiplier * 7 : timeframe.isintraday and timeframe.multiplier < 60 ? 60 / timeframe.multiplier * 24 * 7 : 7

c1 = ta.wma(src, len)
o1 = ta.wma(src1, len)
l1 = ta.wma(src2, len)
h1 = ta.wma(src3, len)

HTF = input.timeframe('M', title='Higher Time Frame')
ti = ta.change(time(HTF)) != 0
c = fixnan(ti ? c1 : na)
o = fixnan(ti ? o1 : na)
h = fixnan(ti ? h1 : na)
l = fixnan(ti ? l1 : na)

// Calculating mid-point
m = (h + l) / 2

// Calculating ratio lines
ratio = input.float(0.1, title='% ratio', minval=0.001, maxval=10)
r1 = m * ratio
u = m + r1
d = m - r1

// Take profit settings
takeProfitPercentage1 = input.float(10.0, title='Take Profit 1 (%)', minval=0.1, maxval=100.0) / 100
takeProfitQuantity1 = input.float(50.0, title='Take Profit 1 Quantity (%)', minval=0.1, maxval=100.0) / 100
takeProfitPercentage2 = input.float(20.0, title='Take Profit 2 (%)', minval=0.1, maxval=100.0) / 100
takeProfitQuantity2 = input.float(50.0, title='Take Profit 2 Quantity (%)', minval=0.1, maxval=100.0) / 100

// Stop loss settings
stopLossPercentage = input.float(5.0, title='Stop Loss (%)', minval=0.1, maxval=100.0) / 100

// Number of bars to extend lines
extensionBars = input.int(5, title='Number of Bars to Extend Lines', minval=1)

// Number of bars to offset the percentage label
percentOffsetBars = input.int(25, title='Number of Bars to Offset Percentage Label', minval=1)

// Input for multiplying the percentage change
multiplierFactor = input.int(20, title='Multiplier for Percentage Change', minval=1)

// Input for background colors
bgColor1 = input(color.new(color.blue, 90), title='Background Color 1')
bgColor2 = input(color.new(color.orange, 90), title='Background Color 2')

// Plot high, low, and ratio lines
ppo = plot(u, color=color.new(color.blue, 0), title='Upper Line (Resistance)', style=plot.style_stepline)
ppc = plot(d, color=color.new(color.orange, 0), title='Lower Line (Support)', style=plot.style_stepline)

plot(u, color=color.new(color.blue, 0), title='Upper Line (Resistance)', style=plot.style_circles, linewidth=2)
plot(d, color=color.new(color.orange, 0), title='Lower Line (Support)', style=plot.style_circles, linewidth=2)

// Fill the background between ratio lines with two different colors
fill(ppo, ppc, color=bgColor1)

// Calculate mid-point for background color switching
midPoint = (u + d) / 2
bgColorSwitch = close >= midPoint ? bgColor1 : bgColor2
fill(ppo, ppc, color=bgColorSwitch, transp=90)

// Initialize variables for lines and labels
var line tp1Line = na
var line tp2Line = na
var line stopLossLine = na
var line entryLine = na
var label tp1Label = na
var label tp2Label = na
var label stopLossLabel = na
var label entryLabel = na
var label percentLabel = na

// Variable to store the entry bar index
var int entryBarIndexLong = na
var int entryBarIndexShort = na

// Function to delete old labels and lines
deleteOldLinesAndLabels() =>
    if not na(tp1Line)
        line.delete(tp1Line)
    if not na(tp2Line)
        line.delete(tp2Line)
    if not na(stopLossLine)
        line.delete(stopLossLine)
    if not na(entryLine)
        line.delete(entryLine)
    if not na(tp1Label)
        label.delete(tp1Label)
    if not na(tp2Label)
        label.delete(tp2Label)
    if not na(stopLossLabel)
        label.delete(stopLossLabel)
    if not na(entryLabel)
        label.delete(entryLabel)
    if not na(percentLabel)
        label.delete(percentLabel)

// Strategy logic
longCondition = ta.crossover(close, u)
shortCondition = ta.crossunder(close, d)

if longCondition
    strategy.entry('Long', strategy.long)
    entryBarIndexLong := bar_index
    entryBarIndexLong

if shortCondition
    strategy.entry('Short', strategy.short)
    entryBarIndexShort := bar_index
    entryBarIndexShort

// Calculate take profit and stop loss levels for long positions
if strategy.position_size > 0  // Check if there's an open long position
    takeProfitLevelLong1 = strategy.position_avg_price * (1 + takeProfitPercentage1)
    takeProfitLevelLong2 = strategy.position_avg_price * (1 + takeProfitPercentage2)
    stopLossLevelLong = strategy.position_avg_price * (1 - stopLossPercentage)
    entryPrice = strategy.position_avg_price

    // Delete existing lines and labels if they exist
    deleteOldLinesAndLabels()


    // Exit a portion of the position at each take profit level
    strategy.exit('TP1', 'Long', limit=takeProfitLevelLong1, qty=strategy.position_size * takeProfitQuantity1)
    strategy.exit('TP2', 'Long', limit=takeProfitLevelLong2, qty=strategy.position_size * takeProfitQuantity2)
    strategy.exit('Stop Loss', 'Long', stop=stopLossLevelLong)

    // Display percentage change from entry price
    percentChange = (close - strategy.position_avg_price) / strategy.position_avg_price * 100
    percentMultiplied = percentChange * multiplierFactor
    percentColor = percentChange >= 0 ? color.green : color.red
    // Update label position to follow price line with larger text size
    percentLabel := label.new(x=bar_index + percentOffsetBars, y=close, text=str.tostring(percentMultiplied, format.percent) + '%', color=percentColor, textcolor=color.white, size=size.large, style=label.style_label_down)
    percentLabel

if strategy.position_size < 0  // Check if there's an open short position
    takeProfitLevelShort1 = strategy.position_avg_price * (1 - takeProfitPercentage1)
    takeProfitLevelShort2 = strategy.position_avg_price * (1 - takeProfitPercentage2)
    stopLossLevelShort = strategy.position_avg_price * (1 + stopLossPercentage)
    entryPrice = strategy.position_avg_price

    // Delete existing lines and labels if they exist
    deleteOldLinesAndLabels()


    // Exit a portion of the position at each take profit level
    strategy.exit('TP1', 'Short', limit=takeProfitLevelShort1, qty=strategy.position_size * takeProfitQuantity1)
    strategy.exit('TP2', 'Short', limit=takeProfitLevelShort2, qty=strategy.position_size * takeProfitQuantity2)
    strategy.exit('Stop Loss', 'Short', stop=stopLossLevelShort)

    // Display percentage change from entry price
    percentChange = (strategy.position_avg_price - close) / strategy.position_avg_price * 100
    percentMultiplied = percentChange * multiplierFactor
    percentColor = percentChange >= 0 ? color.green : color.red
    // Update label position to follow price line with larger text size
    percentLabel := label.new(x=bar_index + percentOffsetBars, y=close, text=str.tostring(percentMultiplied, format.percent) + '%', color=percentColor, textcolor=color.white, size=size.large, style=label.style_label_down)
    percentLabel

// Add buy and sell signals with shapes
plotshape(series=longCondition, title='Buy Signal', location=location.belowbar, color=color.new(color.green, 0), style=shape.labelup, text='.')
plotshape(series=shortCondition, title='Sell Signal', location=location.abovebar, color=color.new(color.red, 0), style=shape.labeldown, text='.')

// Remove old labels when they go out of scope
if bar_index % 50 == 0
    deleteOldLinesAndLabels()

// Define colors for candles based on background color
candleColorBull = bgColorSwitch  // Use background color for bullish candles
candleColorBear = bgColorSwitch  // Use background color for bearish candles
borderColorBull = color.black  // Border color for bullish candles
borderColorBear = color.black  // Border color for bearish candles

// Plot candles with custom colors
plotcandle(open, high, low, close, color=close >= open ? candleColorBull : candleColorBear, bordercolor=close >= open ? borderColorBull : borderColorBear, wickcolor=color.gray)