//version=4
study("MACD Buy/Sell Signals", shorttitle="MACD Signals", overlay=true)

// Input parameters
fast_length = input(12, title="Fast Length")
slow_length = input(26, title="Slow Length")
signal_smoothing = input(9, title="Signal Smoothing")

// MACD calculation
[macdLine, signalLine, _] = macd(close, fast_length, slow_length, signal_smoothing)

// Sinyal buy dan sell
buySignal = crossover(macdLine, signalLine)
sellSignal = crossunder(macdLine, signalLine)

// Plot sinyal pada chart
plotshape(series=buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")

// Plot MACD dan garis sinyal (opsional)
plot(macdLine, title="MACD Line", color=color.blue)
plot(signalLine, title="Signal Line", color=color.orange)
Chart PatternsHarmonic PatternsTrend Analysis

免責聲明