← Script Marketplace
Open-source scriptindicator/v1

Moving Average Convergence Divergence

by Kodexius·@kodexius·

Compare fast and slow momentum with configurable MACD, signal line, histogram, and crossover alerts.

#macd#momentum#oscillator#trend
Moving Average Convergence Divergence chart preview
Open-source script. Everyone can inspect the source code, use the script on a chart, and save an editable copy.

About this script

A configurable Moving Average Convergence Divergence indicator with MACD line, signal line, and histogram. Built-in alert conditions mark bullish and bearish signal-line crosses.

Source code
mpl-2.0
// Moving Average Convergence Divergence
indicator("Moving Average Convergence Divergence", { overlay: false });

const fastLen = input.number("Fast length", 12, { min: 1, max: 100 });
const slowLen = input.number("Slow length", 26, { min: 2, max: 200 });
const signalLen = input.number("Signal length", 9, { min: 1, max: 100 });
const [macdLine, signalLine, histogram] = macd(close, fastLen, slowLen, signalLen);

plot(histogram, { title: "Histogram", type: "histogram", color: "#94a3b8" });
plot(macdLine, { title: "MACD", color: "#22d3ee" });
plot(signalLine, { title: "Signal", color: "#f59e0b" });
hline(0, { title: "Zero", color: "#475569", overlay: false });

alertcondition(crossover(macdLine, signalLine), "MACD crossed above the signal line");
alertcondition(crossunder(macdLine, signalLine), "MACD crossed below the signal line");

Release notes

Initial official release.