복합 트렌드 이동 평균 반전 거래 전략

MA EMA TEMA DEMA WMA SMA
생성 날짜: 2025-02-20 17:20:42 마지막으로 수정됨: 2025-02-27 17:23:21
복사: 0 클릭수: 394
avatar of ianzeng123 ianzeng123
2
집중하다
319
수행원

복합 트렌드 이동 평균 반전 거래 전략 복합 트렌드 이동 평균 반전 거래 전략

개요

이 전략은 복합 평균선에 기반한 트렌드 추적 및 역전 거래 시스템이다. 그것은 다른 주기에서 이동 평균을 조합하여 평균선에 대한 가격 반응과 결합하여 거래 기회를 식별한다. 전략의 핵심은 가격과 평균선 사이의 관계를 관찰하고 특정 하락에 대한 가격 회귀에 대한 반응을 통해 거래 시기를 판단하는 것이다.

전략 원칙

이 전략은 여러 가지 이동 평균 유형 (EMA, TEMA, DEMA, WMA, SMA) 을 조합하여 두 개의 다른 주기 (기본 20과 30) 의 가중치 또는 계산 평균을 통해 복합 평균선을 구성합니다. 가격이 평균선 위에 있을 때 상승 추세로 간주되며, 평균선 아래에 있을 때 하향 추세로 간주됩니다.

전략적 이점

  1. 시스템은 잘 적응할 수 있으며, 여러 종류의 평균선을 지원하며, 시장 특성에 따라 가장 적합한 평균선을 선택할 수 있다.
  2. 복합평균선 방식으로, 단일 주기평균선이 가져올 수 있는 거짓 신호를 효과적으로 감소시킨다.
  3. 전략은 반응 비율의 개념을 추가하여 단순한 평행선을 가로지르는 거래를 피하고 거래의 신뢰성을 높였습니다.
  4. 트렌드 방향이 명확한 경우, 리콜을 기다림으로써 더 나은 거래 가격을 얻을 수 있다.

전략적 위험

  1. 불안한 시장에서는 종종 잘못된 신호가 발생하여 거래 비용이 증가할 수 있습니다.
  2. 복합평균선의 지연성은 출전과 출전 시간을 지연시킬 수 있다.
  3. 고정 반응 비율은 다른 시장 환경에 따라 조정될 수 있습니다.
  4. 빠르게 변하는 시장에서는 큰 반전이 발생할 수 있습니다.

전략 최적화 방향

  1. 변동률 지표를 도입하여 반응 비율을 동적으로 조정하여 전략을 다른 시장 환경에 더 잘 적응시킬 수 있습니다.
  2. 거래량 요소를 추가하여 가격 반전의 유효성을 확인한다.
  3. 위험 관리에 도움이 될 수 있는 스톱 및 스톱 메커니즘을 추가하는 것을 고려하십시오.
  4. 트렌드 강도를 판단할 수 있으며, 강한 트렌드에서는 더 급진적인 파라미터 설정을 적용할 수 있다.
  5. 시장 환경에 대한 판단을 고려하고, 다른 시장 특성에 따라 다른 파라미터 조합을 사용한다.

요약하다

이것은 트렌드 추적과 역전 거래의 개념을 결합한 전략으로, 복합 평준선과 가격 반응 메커니즘을 통해 거래 기회를 포착한다. 전략의 핵심 장점은 그것의 유연성과 가짜 신호를 필터링하는 능력에 있다. 그러나 동시에 다른 시장 환경에서 변수 최적화 문제에 주의를 기울여야 한다. 합리적인 위험 제어와 지속적인 최적화 개선으로, 이 전략은 실제 거래에서 안정적인 수익을 얻을 수 있다.

전략 소스 코드
/*backtest
start: 2024-10-01 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Ultrajante MA Reaction Strategy", overlay=true, initial_capital=10000, 
     default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// ===== Custom Functions for DEMA and TEMA =====
dema(src, length) =>
    ema1 = ta.ema(src, length)
    ema2 = ta.ema(ema1, length)
    2 * ema1 - ema2

tema(src, length) =>
    ema1 = ta.ema(src, length)
    ema2 = ta.ema(ema1, length)
    ema3 = ta.ema(ema2, length)
    3 * ema1 - 3 * ema2 + ema3

// ===== Configuration Parameters =====

// MA Type Selection
maType = input.string(title="MA Type", defval="EMA", options=["SMA", "EMA", "WMA", "DEMA", "TEMA"])

// Parameters for composite periods
periodA = input.int(title="Period A", defval=20, minval=1)
periodB = input.int(title="Period B", defval=30, minval=1)
compMethod = input.string(title="Composite Method", defval="Average", options=["Average", "Weighted"])

// Reaction percentage (e.g., 0.5 means 0.5%)
reactionPerc = input.float(title="Reaction %", defval=0.5, step=0.1)

// ===== Composite Period Calculation =====
compPeriod = compMethod == "Average" ? math.round((periodA + periodB) / 2) : math.round((periodA * 0.6 + periodB * 0.4))

// ===== Moving Average Calculation based on selected type =====
ma = switch maType
    "SMA"  => ta.sma(close, compPeriod)
    "EMA"  => ta.ema(close, compPeriod)
    "WMA"  => ta.wma(close, compPeriod)
    "DEMA" => dema(close, compPeriod)
    "TEMA" => tema(close, compPeriod)
    => ta.ema(close, compPeriod)  // Default value

plot(ma, color=color.blue, title="MA")

// ===== Trend Definition =====
trendUp = close > ma
trendDown = close < ma

// ===== Reaction Threshold Calculation =====
// In uptrend: expect the price to retrace to or below a value close to the MA
upThreshold = ma * (1 - reactionPerc / 100)
// In downtrend: expect the price to retrace to or above a value close to the MA
downThreshold = ma * (1 + reactionPerc / 100)

// ===== Quick Reaction Detection =====
// For uptrend: reaction is detected if the low is less than or equal to the threshold and the close recovers and stays above the MA
upReaction = trendUp and (low <= upThreshold) and (close > ma)
// For downtrend: reaction is detected if the high is greater than or equal to the threshold and the close stays below the MA
downReaction = trendDown and (high >= downThreshold) and (close < ma)

// ===== Trade Execution =====
if upReaction
    // Close short position if exists and open long position
    strategy.close("Short", comment="Close Short due to Bullish Reaction")
    strategy.entry("Long", strategy.long, comment="Long Entry due to Bullish Reaction in Uptrend")

if downReaction
    // Close long position if exists and open short position
    strategy.close("Long", comment="Close Long due to Bearish Reaction")
    strategy.entry("Short", strategy.short, comment="Short Entry due to Bearish Reaction in Downtrend")

// ===== Visualization of Reactions on the Chart =====
plotshape(upReaction, title="Bullish Reaction", style=shape.arrowup, location=location.belowbar, color=color.green, size=size.small, text="Long")
plotshape(downReaction, title="Bearish Reaction", style=shape.arrowdown, location=location.abovebar, color=color.red, size=size.small, text="Short")