
이 전략은 MACD 기둥 도표의 역동량에서 벗어난 트렌드 역전 거래 시스템이다. K선 모양의 변화와 MACD 기둥 도표의 역동량 변화 사이의 관계를 분석하여 시장 역전 신호를 포착한다. 전략의 핵심 아이디어는 시장에서 역동량 쇠퇴의 징후가 발생했을 때 역전 거래를 수행하여 추세가 반전될 때 미리 배열한다.
이 전략의 거래 논리는 두 가지 방향으로 나뉘어져 있습니다. 공백 조건: 큰 선이 나타나면 (폐쇄 가격이 개장 가격보다 높으며), 그 실체는 전의 K 선보다 크며, MACD 기둥 모양의 도표가 연속으로 3 회 동안 하향 경향을 나타내면, 상향 변동력이 약화되고 있음을 나타냅니다. 시스템 공백 신호를 냅니다. 다중 조건: 큰 음선이 나타났을 때 (폐쇄 가격이 오픈 가격보다 낮다) 그리고 그 실체는 전의 K선보다 크며, MACD 기둥 모양의 도표가 연속적으로 3 회 동안 상승 추세를 나타냈을 때, 하향 움직임이 약화되고 있다는 것을 나타냅니다. 시스템은 다중 신호를 냅니다. 포지션 관리는 상대의 신호 평소 포지션 메커니즘을 채택합니다. 즉, 반대 방향으로 거래 신호가 발생하면 현재 포지션을 평소합니다. 전략은 중지 손실과 정지를 설정하지 않고 신호에 전적으로 의존하여 포지션을 관리합니다.
이 전략은 K선 형태와 MACD 기둥 모양의 동적량 변화를 결합하여 시장 역전 기회를 포착하기 위해 운영이 간단하고 신호가 명확한 특징이 있다. 일정 위험이 존재하지만 합리적인 최적화 및 위험 관리 조치를 통해 전략의 안정성과 수익성을 크게 향상시킬 수 있다. 전략은 특히 추세가 명백한 시장 환경에 적합하며 거래 시스템의 중요한 구성 요소로 사용될 수 있다.
/*backtest
start: 2024-11-10 00:00:00
end: 2025-02-19 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("MACD Momentum Reversal Strategy", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// === MACD Calculation ===
fastLength = input.int(12, "MACD Fast Length")
slowLength = input.int(26, "MACD Slow Length")
signalLength = input.int(9, "MACD Signal Length")
[macdLine, signalLine, histLine] = ta.macd(close, fastLength, slowLength, signalLength)
// === Candle Properties ===
bodySize = math.abs(close - open)
prevBodySize = math.abs(close[1] - open[1])
candleBigger = bodySize > prevBodySize
bullishCandle = close > open
bearishCandle = close < open
// === MACD Momentum Conditions ===
// For bullish candles: if the MACD histogram (normally positive) is decreasing over the last 3 bars,
// then the bullish momentum is fading – a potential short signal.
macdLossBullish = (histLine[2] > histLine[1]) and (histLine[1] > histLine[0])
// For bearish candles: if the MACD histogram (normally negative) is increasing (moving closer to zero)
// over the last 3 bars, then the bearish momentum is fading – a potential long signal.
macdLossBearish = (histLine[2] < histLine[1]) and (histLine[1] < histLine[0])
// === Entry Conditions ===
// Short entry: Occurs when the current candle is bullish and larger than the previous candle,
// while the MACD histogram shows fading bullish momentum.
enterShort = bullishCandle and candleBigger and macdLossBullish
// Long entry: Occurs when the current candle is bearish and larger than the previous candle,
// while the MACD histogram shows fading bearish momentum.
enterLong = bearishCandle and candleBigger and macdLossBearish
// === Plot the MACD Histogram for Reference ===
plot(histLine, title="MACD Histogram", color=color.blue, style=plot.style_histogram)
// === Strategy Execution ===
// Enter positions based on conditions. There is no stop loss or take profit defined;
// positions remain open until an opposite signal occurs.
if (enterShort)
strategy.entry("Short", strategy.short)
if (enterLong)
strategy.entry("Long", strategy.long)
// Exit conditions: close an existing position when the opposite signal appears.
if (strategy.position_size > 0 and enterShort)
strategy.close("Long")
if (strategy.position_size < 0 and enterLong)
strategy.close("Short")