indicator · own pane · open source

MACD

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

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

//@version=5
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")
[m, s, h] = ta.macd(src, fast, slow, sig)
hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)
p_MACD = plot(m, "MACD", color=color.blue, linewidth=2)
p_Signal = plot(s, "Signal", color=color.orange)
p_Histogram = plot(h, "Histogram", color=h >= 0 ? color.green : color.red, 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")

Comments

No comments yet.

Sign in to comment.