동적 이동 평균 트렌드 크로스오버 전략

저자:차오장, 날짜: 2023-11-21 17:18:20
태그:

img

전반적인 설명

동적 이동 평균 트렌드 크로스오버 전략 (Dynamic Moving Average Trend Crossover Strategy) 은 이동 평균 컨버전스 디버전스 (MACD) 지표에 기반한 거래 시스템이다. 이 전략은 구매 또는 판매 결정을 내리기 위해 단기 및 장기 이동 평균의 차이에 의존하며, 주요 아이디어는 잠재적인 시장 변화를 예측하기 위해 단기 및 장기 트렌드의 관계를 모니터링하는 것입니다.

전략 원칙

이 전략은 두 가지 다른 기간의 기하급수적 이동 평균 (EMA) 을 사용합니다: 빠른 EMA (8일) 및 느린 EMA (16일). MACD 값은이 두 EMA 사이의 차이에서 파생됩니다. 또한 전략은 11 일 동안 MACD의 간단한 이동 평균 (SMA) 인 신호 라인을 포함합니다. MACD 라인이 신호 라인의 위를 넘을 때 구매 신호가 생성되며 상승 추세를 나타냅니다.

코드 수준에서 전략은 빠르고 느린 EMA를 계산하고 MACD 값을 도출합니다. 이후 MACD의 SMA는 신호 라인으로 계산됩니다. 포지션은 MACD의 위치를 신호 라인과 비교하여 결정됩니다. 또한 전략은 역 거래 옵션을 제공하여 반대 신호로 시장에 진출 할 수 있습니다.

전략적 장점

동적 이동 평균 트렌드 크로스오버 전략의 주요 장점은 시장 트렌드 변화에 대한 단순성과 민감함이다. 다른 기간의 EMA를 사용하여이 전략은 단기 및 장기 트렌드 사이의 편차를 효과적으로 파악하여 시장 변화에 적시에 대응합니다. 신호 라인의 추가는 전략의 정확성을 더욱 향상시켜 투자자가 트렌드 반전을 더 빠르게 식별 할 수 있습니다.

위험 분석

동적 이동 평균 트렌드 크로스오버 전략은 많은 상황에서 좋은 성능을 발휘하지만, 또한 특정 위험을 안고 있습니다. 주요 위험은 매우 변동적인 시장이나 불분명한 트렌드에서 잘못된 신호를 생성하는 것입니다. 또한, 역사적 데이터에 의존하는 것은 지연된 응답으로 이어질 수 있습니다. 이러한 위험을 완화하기 위해 투자자는 전략을 다른 기술적 지표 또는 시장 분석과 결합하여 의사 결정을 내릴 수 있습니다.

최적화 방향

이 전략의 최적화는 EMA 기간의 길이를 조정하고 추가적인 기술적 지표를 통합하고 시장 변동성 요인을 고려하는 것을 포함 할 수 있습니다. 기간 길이를 조정하면 전략이 다른 시장 조건에 더 적응 할 수 있습니다.

RSI 또는 볼링거 밴드는 시장에 대한 보다 포괄적인 시각을 제공 할 수 있습니다. ATR로 전략을 조정하는 것과 같은 시장 변동성 요인을 고려하면 전략의 적응력과 견고성을 향상시킬 수 있습니다.

결론

동적 이동 평균 트렌드 크로스오버 전략 (Dynamic Moving Average Trend Crossover Strategy) 은 MACD를 중심으로 한 양적 거래 전략이다. 단기 및 장기 트렌드 사이의 관계를 분석함으로써 시장 움직임을 파악하는 것을 목표로 한다. 이 전략은 간단하고 효과적이지만, 그 한계와 잠재적 위험을 인식하는 것이 중요하다. 다른 분석 도구를 지속적으로 최적화하고 통합함으로써 투자자들은 효과적인 시장 운영을 위해 이 전략을 더 잘 활용할 수 있다.


/*backtest
start: 2022-11-14 00:00:00
end: 2023-11-20 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 06/09/2017
// MACD – Moving Average Convergence Divergence. The MACD is calculated 
// by subtracting a 26-day moving average of a security's price from a 
// 12-day moving average of its price. The result is an indicator that 
// oscillates above and below zero. When the MACD is above zero, it means 
// the 12-day moving average is higher than the 26-day moving average. 
// This is bullish as it shows that current expectations (i.e., the 12-day 
// moving average) are more bullish than previous expectations (i.e., the 
// 26-day average). This implies a bullish, or upward, shift in the supply/demand 
// lines. When the MACD falls below zero, it means that the 12-day moving average 
// is less than the 26-day moving average, implying a bearish shift in the 
// supply/demand lines.
// A 9-day moving average of the MACD (not of the security's price) is usually 
// plotted on top of the MACD indicator. This line is referred to as the "signal" 
// line. The signal line anticipates the convergence of the two moving averages 
// (i.e., the movement of the MACD toward the zero line).
// Let's consider the rational behind this technique. The MACD is the difference 
// between two moving averages of price. When the shorter-term moving average rises 
// above the longer-term moving average (i.e., the MACD rises above zero), it means 
// that investor expectations are becoming more bullish (i.e., there has been an 
// upward shift in the supply/demand lines). By plotting a 9-day moving average of 
// the MACD, we can see the changing of expectations (i.e., the shifting of the 
// supply/demand lines) as they occur.
//  You can change long to short in the Input Settings
//  WARNING:
//  - For purpose educate only
//  - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="MACD Crossover", shorttitle="MACD Crossover")
fastLength = input(8, minval=1)
slowLength = input(16,minval=1)
signalLength=input(11,minval=1)
reverse = input(false, title="Trade reverse")
// hline(0, color=purple, linestyle=dashed)
fastMA = ema(close, fastLength)
slowMA = ema(close, slowLength)
macd = fastMA - slowMA
signal = sma(macd, signalLength)
pos = iff(signal < macd , 1,
	   iff(signal > macd, -1, nz(pos[1], 0))) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1, 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	   	    
barcolor(possig == -1 ? red: possig == 1 ? green : blue )  
plot(signal, color=red, title="SIGNAL")
plot(macd, color=blue, title="MACD")


더 많은