indicator · own pane · open source
MACD indicator
MACD is a free open-source indicator by @deepwick. MACD plots the spread between two EMAs (12/26 by default) and its signal line (9). Deepwick Script runs a subset of Pine Script.
Running…
Loading chart…
What MACD does
MACD plots the spread between two EMAs (12/26 by default) and its signal line (9). The histogram is the spread between MACD and signal.
- Crossovers with the signal line are the standard momentum entries.
- Histogram flips signal strength; shrinking histogram warns of weakening trend.
- Raise the fast/slow gap for fewer, larger signals.
Source code
Deepwick Script, a subset of Pine Script · read-only
//@version=6
indicator("MACD", overlay=false)
fast = input.int(12, "Fast Length", minval=2, maxval=100)
slow = input.int(26, "Slow Length", minval=2, maxval=200)
sig = input.int(9, "Signal Length", minval=2, maxval=50)
src = input.source(close, "Source")
colorLine = input.color("color.blue", "Color Line")
colorMid = input.color("color.orange", "Color Mid")
colorUp = input.color("color.green", "Color Up")
colorDown = input.color("color.red", "Color Down")
colorNeutral = input.color("color.gray", "Color Neutral")
[m, s, h] = ta.macd(src, fast, slow, sig)
hline(0, "Zero", color=colorNeutral, linestyle=hline.style_dotted)
p_MACD = plot(m, "MACD", color=colorLine, linewidth=2)
p_Signal = plot(s, "Signal", color=colorMid)
p_Histogram = plot(h, "Histogram", color=h >= 0 ? colorUp : colorDown, style=plot.style_columns)
alertcondition(ta.crossover(m, s), "MACD crosses signal up", "MACD crossed above signal")
alertcondition(ta.crossunder(m, s), "MACD crosses signal down", "MACD crossed below signal")
No comments yet.
Sign in to comment.