동력 이중 이동 평균 크로스오버 전략

저자:차오장, 날짜: 2023-10-20 16:44:30
태그:

img

전반적인 설명

이 전략은 이동 평균 크로스오버를 사용하여 가격 동력 방향을 결정하고, 전체 트렌드를 판단하기 위해 황금/죽음 크로스를 추가하여 트렌드 다음을 구현합니다.

전략 논리

이 전략은 EMA와 SMA의 교차점을 사용하여 가격 동력의 방향을 결정합니다. EMA는 더 빨리 반응하고 SMA는 더 안정적으로 반응합니다. EMA가 SMA를 넘을 때 상승 동력이 강하다고 판단되며, 길게 이동합니다. EMA가 SMA를 넘을 때 하락 동력이 강하다고 판단되며, 짧게 이동합니다.

또한, 전략은 또한 전체 트렌드 방향을 결정하기 위해 빠른 기간 SMA와 느린 기간 SMA의 교차를 사용합니다. 빠른 기간 SMA가 느린 기간 SMA를 넘을 때, 그것은 시장이 장기 상승 추세에 있음을 나타내는 황금 십자입니다. 빠른 기간 SMA가 느린 기간 SMA를 넘을 때, 그것은 시장이 장기 하락 추세에 있음을 나타내는 죽음의 십자입니다.

이 전략은 EMA가 SMA를 넘을 때 긴 기회를 식별합니다. 이 시점에서 황금 십자라면, 단기 동력과 장기 트렌드가 더 나은 장기 타이밍으로 지원된다는 것을 의미합니다. 사상 십자라면, 단기 동력과 더 위험한 장기 트렌드에 반대하여 단기 동력으로만 지원됩니다.

이점 분석

  • MA 크로스오버를 사용하여 가격 동력과 방향을 판단합니다.
  • 단기 동력과 장기 추세를 모두 고려합니다.
  • 이중 지표 확인은 신뢰성을 향상시킵니다.
  • MA 매개 변수를 조정하여 다른 기간에 적응할 수 있습니다.
  • 특정 트레이드 신호를 표시/숨기기 위해 사용자 정의

위험 분석

  • MA 크로스오버는 지연이 있고 가장 좋은 입구/출구 지점을 놓칠 수 있습니다.
  • 고정 기간 SMA는 가격 변화를 실시간으로 반영할 수 없습니다.
  • 장기/단기 MAs 사이에 잘못된 교차가 발생할 수 있습니다.
  • 장기 보유가 자본 위험을 증가시킬 수 있습니다.

위험은 신호 확인을 위한 다른 지표를 결합하거나 MA 기간을 최적화하거나 스톱 로스를 설정함으로써 줄일 수 있습니다.

최적화 방향

  • 부피, 볼링거 밴드 등과 같은 다른 필터를 추가합니다.
  • 스톱 로스 전략을 추가
  • MA 기간을 최적화
  • 자본 관리 최적화
  • 동적 위치 크기를 고려

결론

전체적으로, 이것은 비교적 안정적이고 신뢰할 수있는 트렌드 다음 전략입니다. 그것은 MA 크로스오버를 통해 거래 신호를 생성하여 단기 가격 동력과 장기 트렌드 방향을 모두 고려합니다. 단일 MA 전략과 비교하면 확인을 위해 이중 지표를 결합하여 더 높은 신뢰성을 가지고 있습니다. 그러나 트렌드 다음 전략으로 매개 변수 최적화 및 위험 통제가 매우 중요합니다. 잠재력을 진정으로 실현하기 위해 반복된 테스트와 조정이 필요합니다. 지속적인 최적화와 개선으로이 전략은 장기적인 양적 투자 포트폴리오의 귀중한 구성 요소가 될 수 있습니다.


/*backtest
start: 2023-09-19 00:00:00
end: 2023-10-19 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Cryptoluc1d

//@version=4
strategy("Equal-Length EMA/SMA Crossover Strategy", initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=25, commission_type=strategy.commission.percent, commission_value=0.2, overlay=true)

// Create inputs

mom_length = input(title="Momentum Length (EMA=SMA)", defval=50)
bias_length_fast  = input(title="Golden Cross Length (Fast)", defval=50)
bias_length_slow  = input(title="Golden Cross Length (Slow)", defval=100)

// Define MAs

ema = ema(close, mom_length) // EMA/SMA crossover of the same period for detecting trend acceleration/deceleration
sma = sma(close, mom_length)
bias_fast = sma(close, bias_length_fast) // golden/death cross for overall trend bias
bias_slow = sma(close, bias_length_slow)

// Define signal conditions

buy_trend = crossover(ema, sma) and bias_fast >= bias_slow // buy when EMA cross above SMA. if this happens during a bullish golden cross, buying is in confluence with the overall trend (bias).
buy_risky = crossover(ema, sma) and bias_fast < bias_slow // buy when EMA cross above SMA. if this happens during a bearish death cross, buying is early, more risky, and not in confluence with the overall trend (bias).
buy_late = crossover(sma, bias_slow) and ema > sma // the SMA crossing the Slow_SMA gives further confirmation of bullish trend, but signal comes later.
sell = crossunder(ema, sma) // sell when EMA cross under SMA.

// Enable option to hide signals, then plot signals

show_signal = input(title="Show Signals", defval=true)

plotshape(show_signal ? buy_trend : na, title='Trend Buy', style=shape.triangleup, location=location.belowbar, color=color.green, text='TREND BUY')
plotshape(show_signal ? buy_risky : na, title='Risky Buy', style=shape.triangleup, location=location.belowbar, color=color.olive, text='RISKY BUY')
plotshape(show_signal ? buy_late : na, title='Late Buy', style=shape.triangleup, location=location.belowbar, color=color.lime, text='LATE BUY')
plotshape(show_signal ? sell : na, title='Sell', style=shape.triangledown, location=location.abovebar, color=color.red, text='SELL')

// Define entry and exit conditions

longCondition = ema > sma and bias_fast >= bias_slow // LONG when EMA above SMA, and overall trend bias is bullish
if (longCondition)
    strategy.entry("BUY TREND", strategy.long)
exitLong = crossunder(ema, sma) // close LONG when EMA cross under SMA
strategy.close("BUY TREND", when=exitLong)

// // short conditions. turned off because up only.
// shortCondition = ema < sma and bias_fast <= bias_slow // SHORT when EMA under SMA, and overall trend bias is bearish
// if (shortCondition)
//     strategy.entry("SELL TREND", strategy.short)
// exitShort = crossover(ema, sma) // close SHORT when EMA cross over SMA
// strategy.close("SELL TREND", when=exitShort)

// Enable option to show MAs, then plot MAs

show_ma = input(title="Show MAs", defval=false)

plot(show_ma ? ema : na, title="Momentum EMA", color=color.green, linewidth=1)
plot(show_ma ? sma : na, title="Momentum SMA", color=color.yellow, linewidth=1)
plot(show_ma ? bias_fast : na, title="Golden Cross SMA (Fast)", color=color.orange, linewidth=2)
plot(show_ma ? bias_slow : na, title="Golden Cross SMA (Slow)", color=color.red, linewidth=2)

더 많은