
이 전략은 MACD의 동적 변화 특성을 기반으로 거래 결정을 내립니다. 전략의 핵심은 MACD 기둥 모양의 도표를 관찰함으로써 변화하는 경향을 예측하여 발생할 수 있는 금 포크와 사다리 포크를 예측하여 거래를 미리 배열하는 것입니다. 이 전략은 전통적인 MACD 지표 교차 신호뿐만 아니라 기둥 모양의 도표의 동적 변화 특성에 더 집중하여 교차 신호를 미리 판단하여 더 나은 진입 시간을 얻습니다.
전략은 개선된 MACD 지표 시스템을 사용하여 빠른 이동 평균 ((EMA12) 와 느린 이동 평균 ((EMA26) 의 차차 계산과 2 주기를 기반으로 한 신호 라인을 포함합니다. 핵심 거래 논리는 다음과 같은 몇 가지 핵심 포인트에 기반합니다.
이 전략은 MACD 기둥 도표의 역동적인 변화 특성을 혁신적으로 적용하여 전통적인 MACD 거래 시스템에 대한 개선과 최적화를 실현한다. 전략의 사전 판단 메커니즘은 더 이른 입시 신호를 제공 할 수 있으며, 엄격한 거래 조건과 위험 제어 조치는 전략의 안정성을 보장한다. 이 전략은 더 나은 최적화 및 개선으로 실제 거래에서 더 나은 성능을 기대한다.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-25 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title="Demo GPT - Moving Average Convergence Divergence", shorttitle="MACD", commission_type=strategy.commission.percent, commission_value=0.1, slippage=3, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Getting inputs
fast_length = input(title="Fast Length", defval=12)
slow_length = input(title="Slow Length", defval=26)
src = input(title="Source", defval=close)
signal_length = input.int(title="Signal Smoothing", minval=1, maxval=50, defval=2) // Set smoothing line to 2
sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"])
sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"])
// Date inputs
start_date = input(title="Start Date", defval=timestamp("2018-01-01T00:00:00"))
end_date = input(title="End Date", defval=timestamp("2069-12-31T23:59:59"))
// Calculating
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
hist = macd - signal
// Strategy logic
isInDateRange = true
// Calculate the rate of change of the histogram
hist_change = hist - hist[1]
// Anticipate a bullish crossover: histogram is negative, increasing, and approaching zero
anticipate_long = isInDateRange and hist < 0 and hist_change > 0 and hist > hist[1] and hist > hist[2]
// Anticipate an exit (bearish crossover): histogram is positive, decreasing, and approaching zero
anticipate_exit = isInDateRange and hist > 0 and hist_change < 0 and hist < hist[1] and hist < hist[2]
if anticipate_long
strategy.entry("Long", strategy.long)
if anticipate_exit
strategy.close("Long")
// Plotting
hline(0, "Zero Line", color=color.new(#787B86, 50))
plot(hist, title="Histogram", style=plot.style_columns, color=(hist >= 0 ? (hist > hist[1] ? #26A69A : #B2DFDB) : (hist < hist[1] ? #FF5252 : #FFCDD2)))
plot(macd, title="MACD", color=#2962FF)
plot(signal, title="Signal", color=#FF6D00)
// Plotting arrows when anticipating the crossover
plotshape(anticipate_long, title="Long +1", location=location.belowbar, color=color.green, style=shape.arrowup, size=size.tiny, text="Long +1")
plotshape(anticipate_exit, title="Short -1", location=location.abovebar, color=color.red, style=shape.arrowdown, size=size.tiny, text="Short -1")