
MACD 트렌드 추적 전략은 MACD 지표에 기반한 정량 거래 전략이다. 이 전략은 MACD 지표의 골드 포크와 데드 포크 신호를 식별하여 시장 추세를 판단하여 주가 추세를 추적한다.
MACD 트렌드 추적 전략의 핵심 논리는 다음과 같습니다.
이러한 트렌드 추적을 통해, 이 전략은 시장의 트렌드 전환을 적시에 포착하여 수익을 창출할 수 있다.
MACD 트렌드 추적 전략은 다음과 같은 장점이 있습니다.
MACD 트렌드 추적 전략에는 다음과 같은 위험도 있습니다.
위와 같은 위험에 대해 다음과 같은 최적화 조치가 적용될 수 있습니다.
MACD 트렌드 추적 전략은 다음과 같은 측면에서 최적화 될 수 있습니다.
MACD 지표 파라미터를 최적화하여 거짓 신호율을 낮춘다. 다른 주기 파라미터를 테스트할 수 있는 MACD이다.
거래량을 증가시키는 것과 같은 다른 지표 필터 신호. 최소 거래량 조건을 설정할 수 있다.
동적으로 추적하는 스톱 메커니즘을 설정한다. 스톱 포인트는 변동률에 따라 실시간으로 조정할 수 있다.
오프닝을 시작하는 신호 결정 논리를 최적화한다. 더 엄격한 신호 트리거 조건을 설정할 수 있다.
기계 학습 모델과 결합하여 신호를 필터링한다. 신호의 신뢰성을 판단하는 모델을 훈련시킬 수 있다.
MACD 트렌드 추적 전략은 전체적으로 좀 더 성숙한 양적 전략이다. 이 전략은 MACD 지표를 사용하여 시장 트렌드 방향을 판단하고, 스톱 손실 메커니즘 제어 위험과 함께, 주식 가격 트렌드를 효과적으로 추적 할 수 있다. 그러나 MACD 지표 자체는 특정 결함이 있으며, 거짓 신호를 발생시키는 데 쉽다. 따라서 이 전략에는 추가적인 최적화 공간이 있으며, 주로 지표 매개 변수, 스톱 손실 메커니즘, 신호 필터링 등에 초점을 맞추고 있다.
/*backtest
start: 2023-11-10 00:00:00
end: 2023-12-10 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("MACD Cross Strategy", overlay=true)
// Get MACD values
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)
var float entryLongPrice = na
var float entryShortPrice = na
var float highestLongProfit = 0
var float highestShortProfit = 0
var float highestMACD = 0
var float lowestMACD = 0
var bool haveOpenedLong = false
var bool haveOpenedShort = false
var float stoploss = 0.04 // To be adjust for different investment
var float minProfit = 0.05 // To be adjust for different investment
if macdLine > 0
lowestMACD := 0
highestMACD := math.max(highestMACD, macdLine)
haveOpenedShort := false
else
highestMACD := 0
lowestMACD := math.min(lowestMACD, macdLine)
haveOpenedLong := false
// Enter long position when MACD line crosses above the signal line
if ta.crossover(macdLine, signalLine) and macdLine < highestMACD and macdLine > 0 and haveOpenedLong == false
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", from_entry = "Long", stop=close*(1 - stoploss))
entryLongPrice := close
haveOpenedLong := true
if ta.crossunder(macdLine, signalLine) and macdLine > lowestMACD and macdLine < 0 and haveOpenedShort == false
strategy.entry("Short", strategy.short)
strategy.exit("Exit Short", from_entry = "Short", stop=close*(1 + stoploss))
entryShortPrice := close
haveOpenedShort := true
// log.info("entryLongPrice:{0}", entryLongPrice)
if strategy.position_size > 0
profit = close - entryLongPrice
log.info("profit:{0}", profit)
if profit > 0
highestLongProfit := math.max(highestLongProfit, profit)
if profit / entryLongPrice > minProfit and highestLongProfit * 0.8 > profit
strategy.close("Long")
highestLongProfit := 0
if strategy.position_size < 0
profit = entryShortPrice - close
if profit > 0
highestShortProfit := math.max(highestShortProfit, profit)
log.info("highestShortProfit={0}, profit={1}", highestShortProfit, profit)
if profit / entryShortPrice > minProfit and highestShortProfit * 0.8 > profit
strategy.close("Short")
highestShortProfit := 0