
이 전략은 MACD (Moving Average Convergence Spread Indicator) 에 기반한 고급 정량화 거래 시스템으로, 동적 배경 디스플레이와 여러 기본 파라미터 조합을 통해 거래 의사 결정의 정확성을 강화합니다. 이 전략의 핵심은 MACD 지표의 교차 신호를 통해 시장 추세의 전환점을 포착하고 시각적으로 시장의 빈 상태를 직관적으로 보여줍니다.
이 전략은 표준 설정 ((12,26,9), 단기 ((5,35,5), 장기 ((19,39,9) 등 10가지의 다른 MACD 파라미터 설정을 사용하여 다양한 시장 환경과 거래 스타일에 적합합니다. MACD 라인이 신호 라인과 금이 교차하면 시스템이 구매 신호를 생성하고 사망이 교차하면 시스템이 판매를 생성합니다. 신호 전략은 동적 배경 색상 변화를 통해 시각적 인식을 강화하여 거래자가 시장 움직임을 더 잘 파악할 수 있도록 도와줍니다.
이것은 구조가 완벽하고, 논리가 명확한 MACD 전략의 진보된 버전이다. 다중 변수 사전 설정과 동적 시각적 피드백을 통해 전략의 실용성과 작동성을 크게 향상시켰다. 일부 고유한 위험이 있지만, 제공되는 최적화 방향을 개선한 후, 이 전략은 견고한 거래 시스템이 될 전망이다. 거래자는 실내 사용 전에 충분한 피드백을 수행하고, 특정 시장 환경에 따라 적절한 변수 설정을 선택하도록 권장한다.
/*backtest
start: 2024-10-12 00:00:00
end: 2024-11-11 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Hanzo - Top 10 MACD Strategy", overlay=false) // MACD in a separate pane
// Define dropdown options for MACD settings
macdOption = input.string(title="Select MACD Setting",
defval="Standard (12, 26, 9)",
options=["Standard (12, 26, 9)",
"Short-Term (5, 35, 5)",
"Long-Term (19, 39, 9)",
"Scalping (3, 10, 16)",
"Cryptocurrency (20, 50, 9)",
"Forex (8, 17, 9)",
"Conservative (24, 52, 18)",
"Trend-Following (7, 28, 7)",
"Swing Trading (5, 15, 5)",
"Contrarian (15, 35, 5)"])
// MACD setting based on user selection
var int fastLength = 12
var int slowLength = 26
var int signalLength = 9
switch macdOption
"Standard (12, 26, 9)" =>
fastLength := 12
slowLength := 26
signalLength := 9
"Short-Term (5, 35, 5)" =>
fastLength := 5
slowLength := 35
signalLength := 5
"Long-Term (19, 39, 9)" =>
fastLength := 19
slowLength := 39
signalLength := 9
"Scalping (3, 10, 16)" =>
fastLength := 3
slowLength := 10
signalLength := 16
"Cryptocurrency (20, 50, 9)" =>
fastLength := 20
slowLength := 50
signalLength := 9
"Forex (8, 17, 9)" =>
fastLength := 8
slowLength := 17
signalLength := 9
"Conservative (24, 52, 18)" =>
fastLength := 24
slowLength := 52
signalLength := 18
"Trend-Following (7, 28, 7)" =>
fastLength := 7
slowLength := 28
signalLength := 7
"Swing Trading (5, 15, 5)" =>
fastLength := 5
slowLength := 15
signalLength := 5
"Contrarian (15, 35, 5)" =>
fastLength := 15
slowLength := 35
signalLength := 5
// MACD Calculation
[macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalLength)
macdHist = macdLine - signalLine
// Buy and Sell conditions based on MACD crossovers
enterLong = ta.crossover(macdLine, signalLine)
exitLong = ta.crossunder(macdLine, signalLine)
// Execute buy and sell orders with price labels in the comments
if (enterLong)
strategy.entry("Buy", strategy.long, comment="Buy at " + str.tostring(close, "#.##"))
if (exitLong)
strategy.close("Buy", comment="Sell at " + str.tostring(close, "#.##"))
// Plot the signal price using plotchar for buy/sell prices
//plotchar(enterLong ? close : na, location=location.belowbar, color=color.green, size=size.small, title="Buy Price", offset=0)
//plotchar(exitLong ? close : na, location=location.abovebar, color=color.red, size=size.small, title="Sell Price", offset=0)
// Background highlighting based on bullish or bearish MACD
isBullish = macdLine > signalLine
isBearish = macdLine < signalLine
// Change background to green for bullish periods and red for bearish periods
bgcolor(isBullish ? color.new(color.green, 90) : na, title="Bullish Background")
bgcolor(isBearish ? color.new(color.red, 90) : na, title="Bearish Background")
// Plot the MACD and Signal line in a separate pane
plot(macdLine, title="MACD Line", color=color.blue, linewidth=2)
plot(signalLine, title="Signal Line", color=color.orange, linewidth=2)
hline(0, "Zero Line", color=color.gray)
plot(macdHist, title="MACD Histogram", style=plot.style_histogram, color=color.red)