MACD 크로스오버 전략

저자:차오장, 날짜: 2024-04-18 17:56:23
태그:EMAMA

img

전반적인 설명

이 전략은 거래 신호를 생성하기 위해 서로 다른 기간을 가진 두 개의 기하급수적 이동 평균 (EMA) 의 크로스오버를 사용합니다. 빠른 EMA가 느린 EMA를 넘을 때 구매 신호를 생성하고 빠른 EMA가 느린 EMA를 넘을 때 판매 신호를 생성합니다. 이 전략은 금이 2 시간 시간 프레임에서 가장 효과적이며 비트코인이 일일 차트에서 가장 효과적 인 것과 같은 다양한 금융 도구 및 시간 프레임에 적용 될 수 있습니다.

전략 원칙

  1. 빠른 EMA (저수 기간은 12) 와 느린 EMA (저수 기간은 26) 를 계산합니다.
  2. 올림 구역 (빠른 EMA가 느린 EMA보다 높고 가격이 느린 EMA보다 높다) 및 하락 구역 (빠른 EMA가 느린 EMA보다 높고 가격이 빠른 EMA보다 낮다) 을 정의합니다.
  3. 하락구역에서 상승구역으로 전환할 때 구매하고 상승구역에서 하락구역으로 전환할 때 판매합니다.
  4. 차트 상의 상승 및 하락 영역을 녹색과 빨간색으로 표시하고, 구매 및 판매 신호를 표시하기 위해 화살표를 사용하십시오.

전략적 장점

  1. 간단하고 이해하기 쉬운, 초보자 학습에 적합합니다.
  2. 광범위하게 적용되며 다양한 금융 도구와 시간 프레임에 사용할 수 있습니다.
  3. 중장기 동향을 파악할 수 있는 강력한 트렌드 추적 능력
  4. 조절 가능한 매개 변수, 유연성을 높여줍니다.

전략 위험

  1. 불변 시장에서 잘못된 신호를 만들어 손실을 초래할 수 있습니다.
  2. 트렌드 전환에 반응하는 게 느려서, 약간의 미끄러짐을 초래합니다.
  3. 부적절한 매개 변수 선택은 전략의 성과에 영향을 줄 것입니다.

전략 최적화 방향

  1. 트렌드 필터를 추가하여 ADX가 특정 값을 넘었을 때만 거래하는 것과 같이 불안한 시장에서 손실을 줄이십시오.
  2. 입점 및 출점 시기를 최적화하여 ATR을 사용하여 스톱 로스 및 토익을 결정하여 단일 거래 손실을 줄이십시오.
  3. 가장 좋은 조합을 찾기 위해 매개 변수를 최적화하여 안정성과 수익성을 향상시킵니다.
  4. 신호 정확성을 향상시키기 위해 MACD, RSI 등과 같은 보조 판단을위한 다른 지표와 결합하십시오.

요약

MACD 크로스오버 전략은 트렌드 추종을 기반으로 한 간단한 전략이다. 이 전략의 장점은 단순함과 실용성, 광범위한 적용 가능성, 단점은 트렌드 역전과 매개 변수 선택에 어려움을 겪는 것이다. 트렌드 필터링, 엔트리 및 출구 지점 최적화, 매개 변수 최적화 및 다른 지표를 결합함으로써 이 전략의 성능을 향상시킬 수 있으며, 이는 추가 연구와 테스트에 가치가 있다.


/*backtest
start: 2023-04-12 00:00:00
end: 2024-04-17 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy('Advance EMA Crossover Strategy', overlay=true, precision=6)
//****************************************************************************//
// CDC Action Zone is based on a simple EMA crossover 
// between [default] EMA12 and EMA26
// The zones are defined by the relative position of 
// price in relation to the two EMA lines
// Different zones can be use to activate / deactivate 
// other trading strategies
// The strategy can also be used on its own with 
// acceptable results, buy on the first green candle
// and sell on the first red candle
//****************************************************************************//
// Define User Input Variables

xsrc = input(title='Source Data', defval=close)
xprd1 = input(title='Fast EMA period', defval=12)
xprd2 = input(title='Slow EMA period', defval=26)
xsmooth = input(title='Smoothing period (1 = no smoothing)', defval=1)
fillSW = input(title='Paint Bar Colors', defval=true)
fastSW = input(title='Show fast moving average line', defval=true)
slowSW = input(title='Show slow moving average line', defval=true)
plotSigsw = input(title='Plot Buy/Sell Signals?', defval=true)

//****************************************************************************//
//Calculate Indicators

xPrice = ta.ema(xsrc, xsmooth)

FastMA = ta.ema(xPrice, xprd1)
SlowMA = ta.ema(xPrice, xprd2)

//****************************************************************************//
// Define Color Zones and Conditions

BullZone = FastMA > SlowMA and xPrice > FastMA  // Bullish Zone
BearZone = FastMA < SlowMA and xPrice < FastMA  // Bearish Zone

//****************************************************************************//
// Strategy Entry and Exit Conditions

if (BullZone and not BullZone[1])
    strategy.entry("Buy", strategy.long)  // Buy on the transition into BullZone

if (BearZone and not BearZone[1])
    strategy.close("Buy")  // Sell on the transition into BearZone

//****************************************************************************//
// Display color on chart

plotcolor = BullZone ? color.green : BearZone ? color.red : color.gray
barcolor(color=fillSW ? plotcolor : na)

//****************************************************************************//
// Plot Fast and Slow Moving Averages

plot(fastSW ? FastMA : na, color=color.red, title="Fast EMA", linewidth=2)
plot(slowSW ? SlowMA : na, color=color.blue, title="Slow EMA", linewidth=2)

//****************************************************************************//
// Plot Buy and Sell Signals

plotshape(series=plotSigsw and BullZone and not BullZone[1], location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(series=plotSigsw and BearZone and not BearZone[1], location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")

//****************************************************************************//


관련

더 많은