We read every line of the 10 most-boosted open-source MACD indicator scripts on TradingView (from our 12 November 2026 search census of 104 scripts in total—86 open source, 15 protected, and 3 invite-only). Two findings surprised even us: the #2 script, vkno422's 20,650-boost <TvScript id="4IYKX938">MACD 4C</TvScript>, accidentally discards the Signal and Histogram in [currMacd,_,_] and plots the raw MACD line as columns; and the #1 script, ChrisMoody's 82,869-boost <TvScript id="OQx7vju0">CM_MacD_Ult_MTF</TvScript>, uses sma() instead of ema() for its 9-bar signal line with 0 built-in alerts.
If you want standard 12, 26, 9 EMA math with confirmed closed-bar alerts today, start with ChrisMoody's Pine v5 upgrade <TvScript id="XFr7xHqZ">CM MACD Custom Indicator - Multiple Time Frame - V2</TvScript> (18,134 boosts, keeping its MTF input blank on the chart timeframe). If your main frustration with MACD is endless whipsaw crosses in sideways ranges, pair or compare it with LazyBear's <TvScript id="qt6xLfLi">Impulse MACD [LazyBear]</TvScript> (10,033 boosts)—or paste our unified //@version=6 indicator at the bottom of this page, which combines both modes with confirmed-bar alerts.
Scorecard: 10 open-source TradingView MACD indicators, read from source
To compare pure indicator() / study() scripts apples-to-apples in strict boost order down to 8,224 boosts, two strategy() backtests in that boost bracket (ChartArt's 32,039-boost MACD + SMA 200 Strategy, which uses sma() for all three lines and zero commission, and SeaSide420's 10,540-boost Ichimoku/Hull strategy) plus two protected scripts (18,229 and 8,639 boosts) are noted outside the table:
| Script & Author | Boosts (12 Nov 2026) | Pine & Defaults | Signal / Histogram Math | Bar-Close Lock & MTF Safety | Alerts | Verdict from Source |
|---|---|---|---|---|---|---|
MacD Custom Indicator-Multiple Time Frame+All Available Options! (ChrisMoody, OQx7vju0) | 82,869 | v1 · 12, 26, 9 (close) | ema fast/slow, sma(macd, 9) signal | Live bar; security(..., "60", ...) streams unclosed HTF if MTF turned on | 0 | Classic 4-color look, but SMA signal + no alerts; superseded by V2 below |
MACD 4C (vkno422, 4IYKX938) | 20,650 | v1 · 12, 26 (hardcoded 9) | Bug: [currMacd,_,_] = macd(...) drops Signal & Histogram! | Live bar (close[0]) | 0 | Skip if you want a true MACD histogram—it plots the raw 12 - 26 MACD line as columns |
CM MACD Custom Indicator - Multiple Time Frame - V2 (ChrisMoody, XFr7xHqZ) | 18,134 | v5 · 12, 26, 9 (EMA default, SMA option) | Standard ta.ema for fast, slow, and signal | Fires alert(..., alert.freq_once_per_bar_close); keep res = "" to avoid live HTF | 2 (alert()) | Best free classic MACD for standard 12, 26, 9 + bar-close alerts |
MACD Crossover (HPotter, oMMT8OQZ) | 14,048 | v1 · 8, 16, 11 | ema fast/slow, sma(aMACD, 11) signal | Live bar; barcolor + pos state (1 / -1) | 0 | Non-standard 8, 16, 11 defaults and SMA signal; chart candle tinting only |
MACD_VXI (vdubus, WMxf5UKW) | 11,697 | v1 · 13, 21, 8 | Fibonacci ema(13) - ema(21), sma(8) signal | Live bar cross(signal, macd) circle + bgcolor | 0 | Clean Fibonacci lengths (13, 21, 8), but live-bar crossover dots can flash and vanish |
AK MACD BB INDICATOR V 1.00 (Algokid, lWRJKlbP) | 11,393 | v1 · 12, 26 (10-bar ±1σ BB) | Wraps raw macd inside 10-bar Bollinger Bands; signalLength = 9 input is unused dead code | Causal single-TF math; live bar dots | 0 | Useful volatility-band concept (cousin of Squeeze Momentum settings), dead 9 input |
Impulse MACD [LazyBear] (LazyBear, qt6xLfLi) | 10,033 | v1 · 34 MA, 9 Signal (hlc3) | ZLEMA(hlc3, 34) vs SMMA(high/low, 34) — prints 0 inside channel | Causal single-TF math; live bar | 0 | Best free chop-filtered MACD—goes completely flat (0) during sideways ranges |
MACD Leader [LazyBear] (LazyBear, y9HCZoQi) | 9,099 | v1 · 12, 26, 9 (close) | Giorgos Siligardi error-corrected EMAs (i1 - i2), optional sma(9) | Causal single-TF math; live bar | 0 | Leads standard EMA(12) - EMA(26) turns at the cost of extra intrabar whipsaws |
MACD Based Price Forecasting [LuxAlgo] (LuxAlgo, r9gp40kp) | 8,644 | v5 · 12, 26, 9, 50 memory, 100 horizon | Standard ta.macd(close, 12, 26, 9) drives 80/50/20 percentile cones on chart | Past regime percentiles (CC BY-NC-SA 4.0), redrawn on every regime cross | 0 | Chart overlay descriptive cone of up to 50 prior MACD regimes—not a predictive signal |
OBV MACD Indicator (RafaelZioni, jXvqrU4q) | 8,224 | v4 · OBV(1), DEMA(9) vs EMA(close, 26) | Subtracts ema(close, 26) from DEMA of rescaled On-Balance Volume + Alex Grover T-Channels | Live bar; offset = -1 on optional cross marks + 3-bar pivot check | 0 | Hybrid volume-price oscillator (DEMA of shadow-scaled OBV minus price EMA(26)), not pure MACD |
Four source-code traps every TradingView MACD user should know
1. The 20,650-boost MACD 4C tuple bug (vkno422, 4IYKX938)
MACD 4C is only 12 lines long, and tens of thousands of traders load it expecting TradingView's standard MACD - Signal histogram colored in four momentum shades. Look at lines 5–7 of 4IYKX938:
[currMacd,_,_] = macd(close[0], fastMA, slowMA, 9)
[prevMacd,_,_] = macd(close[1], fastMA, slowMA, 9)
plotColor = currMacd > 0 ? currMacd > prevMacd ? lime : green : currMacd < prevMacd ? maroon : red
plot(currMacd, style = histogram, color = plotColor, linewidth = 3)
In Pine Script, macd() returns [macdLine, signalLine, histLine]. By binding [currMacd, _, _], the script throws away both the 9-bar Signal line and the Histogram, then plots currMacd (EMA(12) - EMA(26)) in style = histogram! That means every zero-line color flip in MACD 4C is a slow 12 / 26 EMA crossover—arriving bars later than a true MACD - Signal histogram flip.
2. Hidden SMA signal lines (OQx7vju0, oMMT8OQZ, WMxf5UKW, y9HCZoQi)
Gerald Appel's classic MACD—and TradingView's built-in ta.macd()—computes all three averages with EMA. Yet four of the top 10 community scripts (ChrisMoody's OQx7vju0 on line 27 via signal = sma(macd, signalLength), HPotter's oMMT8OQZ, vdubus's WMxf5UKW, and LazyBear's y9HCZoQi) compute their signal line with sma(macd, signalLength). That isn't "wrong" (Linda Raschke's 3, 10, 16 oscillator intentionally uses SMA), but if you port a TradingView strategy to MetaTrader 5's iMACD() or Python ta-lib without noticing sma vs ema, your crossover timestamps won't match. (See our Pine to MQL5 port planner if you are automating a MACD rule in MT5.)
3. Why Impulse MACD [LazyBear] (qt6xLfLi) goes flat (0) in chop
Standard EMA(12) - EMA(26) has no concept of range consolidation: as two moving averages braid together in a tight sideways session, the histogram crosses 0 back and forth repeatedly. LazyBear's qt6xLfLi (10,033 boosts) solves that structurally in 32 lines:
- Compute a
34-bar Wilder moving average (SMMA, identical tota.rma) ofhigh(hi) andlow(lo). - Compute a
34-bar Zero-Lag EMA (ZLEMA) ofhlc3(mi). - On line
23, set impulsemd = (mi > hi) ? (mi - hi) : (mi < lo) ? (mi - lo) : 0.
Whenever ZLEMA(hlc3, 34) stays inside the [SMMA(low, 34), SMMA(high, 34)] volatility channel, md is literally 0. No phantom crossover dots fire until price momentum pushes the zero-lag average clean outside the 34-bar high-low band.
4. MACD Divergence scripts and offset = -lbR (soSwR4mX, 5,946 boosts)
Just outside the top 10 sits daviddtech's open-source <TvScript id="soSwR4mX">MACD Divergences by @DaviddTech</TvScript> (5,946 boosts, Pine v4). Like the scripts in our best RSI divergence indicators code read, it calls pivotlow(osc, lbL, lbR) and pivothigh(osc, lbL, lbR) with lbL = 5 and lbR = 5, then stamps "Bull" and "Bear" labels 5 bars into the past using offset = -lbR. Once bar t + 5 closes, the divergence never disappears from history (see how to tell if an indicator repaints), but any backtest or alert can only act 5 bars after the swing extreme.
Clean-Room Pine Script v6: Classic MACD (12,26,9) + Optional Impulse Chop Filter
This complete, original //@version=6 indicator gives you both worlds in one clean pane: run classic EMA (or Linda Raschke SMA) 12, 26, 9 with true 4-color histogram momentum, or switch Mode to Impulse (Zero-Chop Channel) to flatten range noise to 0—with every crossover dot and alertcondition() locked to barstate.isconfirmed by default:
//@version=6
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ProEA Lab (https://proea.app)
indicator("ProEA MACD + Impulse Chop Filter v6 (Confirmed Alerts)", shorttitle = "MACD / Impulse v6", overlay = false)
string GRP_MODE = "Oscillator Mode"
string calcMode = input.string("Classic MACD", "Calculation Mode", options = ["Classic MACD", "Impulse (Zero-Chop Channel)"], group = GRP_MODE)
bool waitBar = input.bool(true, "Confirm Cross Signals on Bar Close", group = GRP_MODE)
string GRP_STD = "Classic MACD Settings"
float srcIn = input.source(close, "Source (Classic)", group = GRP_STD)
int fastLen = input.int(12, "Fast Length", minval = 1, group = GRP_STD)
int slowLen = input.int(26, "Slow Length", minval = 2, group = GRP_STD)
int sigLen = input.int(9, "Signal Length", minval = 1, group = GRP_STD)
string maKind = input.string("EMA", "Oscillator & Signal MA", options = ["EMA", "SMA"], group = GRP_STD)
string GRP_IMP = "Impulse Channel Settings"
int impLen = input.int(34, "Channel & ZLEMA Length", minval = 2, group = GRP_IMP)
int impSig = input.int(9, "Impulse Signal SMA", minval = 1, group = GRP_IMP)
calcAvg(float s, int l, string kind) =>
kind == "EMA" ? ta.ema(s, l) : ta.sma(s, l)
calcZlema(float s, int l) =>
float e1 = ta.ema(s, l)
float e2 = ta.ema(e1, l)
e1 + (e1 - e2)
float fastMa = calcAvg(srcIn, fastLen, maKind)
float slowMa = calcAvg(srcIn, slowLen, maKind)
float stdMacd = fastMa - slowMa
float stdSig = calcAvg(stdMacd, sigLen, maKind)
float hiBand = ta.rma(high, impLen)
float loBand = ta.rma(low, impLen)
float zlMid = calcZlema(hlc3, impLen)
float impMacd = zlMid > hiBand ? zlMid - hiBand : zlMid < loBand ? zlMid - loBand : 0.0
float impSigLn = ta.sma(impMacd, impSig)
bool isImp = calcMode == "Impulse (Zero-Chop Channel)"
float macdLine = isImp ? impMacd : stdMacd
float sigLine = isImp ? impSigLn : stdSig
float histVal = macdLine - sigLine
color histCol = histVal >= 0
? (histVal > nz(histVal[1]) ? #089981 : #80cbc4)
: (histVal < nz(histVal[1]) ? #f23645 : #ef9a9a)
bool gate = not waitBar or barstate.isconfirmed
bool bullCross = ta.crossover(macdLine, sigLine) and (not isImp or macdLine != 0.0) and gate
bool bearCross = ta.crossunder(macdLine, sigLine) and (not isImp or macdLine != 0.0) and gate
bool zeroUp = ta.crossover(macdLine, 0.0) and gate
bool zeroDn = ta.crossunder(macdLine, 0.0) and gate
hline(0.0, "Zero Line", color = color.new(#787b86, 55), linestyle = hline.style_dashed)
plot(histVal, "Histogram", style = plot.style_columns, color = histCol)
plot(macdLine, "MACD Line", color = #2962ff, linewidth = 2)
plot(sigLine, "Signal Line", color = #ff6d00, linewidth = 2)
plotshape(bullCross, "Confirmed Bull Cross", shape.circle, location.bottom, #089981, size = size.tiny)
plotshape(bearCross, "Confirmed Bear Cross", shape.circle, location.top, #f23645, size = size.tiny)
alertcondition(bullCross, "Confirmed MACD Bull Cross", "Confirmed closed-bar MACD bullish signal cross")
alertcondition(bearCross, "Confirmed MACD Bear Cross", "Confirmed closed-bar MACD bearish signal cross")
alertcondition(zeroUp, "Confirmed MACD Above Zero", "Confirmed closed-bar MACD cross above zero")
alertcondition(zeroDn, "Confirmed MACD Below Zero", "Confirmed closed-bar MACD cross below zero")
Pairing momentum crossovers with structure and fee-aware execution
Even a mathematically clean MACD or Impulse MACD is only a single momentum filter—without structure, session gating, and spread-aware stop placement, tight intraday crossovers lose heavily to round-turn costs (see the fee arithmetic in our best scalping indicators code read).
If you want readable, non-repainting //@version=6 scripts where oscillator momentum, regime structure, ATR risk plans, and bar-close JSON alerts are already engineered together, explore Signal Desk and the full six-desk Pine Pro Library ($49 once, full .pine source included).
ProEA's Signal Desk: $49 once in Pine Pro Library (every desk), full Pine v6 source for TradingView; also in the $97 Complete Suite. Facts checked 15 November 2026.
Frequently asked questions
Which free MACD indicator is best on TradingView?
Out of the 10 most-boosted open-source MACD indicators we read on 12 November 2026, two stand out depending on your goal. For classic 12, 26, 9 MACD with genuine closed-bar alerts, use ChrisMoody's CM MACD Custom Indicator V2 (18,134 boosts) with its MTF timeframe left blank on the chart timeframe so request.security does not stream an unclosed higher-timeframe bar. For filtering sideways chop, use LazyBear's Impulse MACD (10,033 boosts), which flattens the oscillator to 0 whenever ZLEMA(hlc3, 34) sits inside the 34-bar SMMA high-low channel.
Why does MACD 4C (20,650 boosts) look different from TradingView's built-in MACD?
Reading all 12 lines of vkno422's MACD 4C (4IYKX938) reveals a tuple bug on line 5: [currMacd,_,_] = macd(close[0], fastMA, slowMA, 9) throws away both the 9-bar signal line and the histogram, then plots the raw MACD line itself as a 4-color histogram. Zero-crossings on MACD 4C are 12/26 EMA crosses, not MACD-minus-Signal histogram crosses.
Does ChrisMoody's 82,869-boost CM_MacD_Ult_MTF match Gerald Appel's standard MACD?
Almost, with two code differences you should know. First, line 27 computes signal = sma(macd, signalLength), a simple moving average rather than Gerald Appel's and TradingView's standard exponential moving average ema(macd, 9). Second, enabling Use Current Chart Resolution = false calls Pine v1 security(tickerid, res, ...) on a 60-minute default without a confirmed-bar offset, which streams unclosed higher-timeframe values.
How does LazyBear's Impulse MACD filter out range chop?
Instead of subtracting a 26-bar EMA from a 12-bar EMA on every bar, Impulse MACD (qt6xLfLi, 10,033 boosts) compares a 34-period zero-lag EMA of hlc3 against a 34-period Wilder SMMA channel of the highs and lows. Whenever ZLEMA(hlc3, 34) sits between SMMA(low, 34) and SMMA(high, 34), line 23 sets md = 0, printing a flat zero line until momentum breaks outside the volatility channel.
Do TradingView MACD divergence indicators repaint?
Open-source pivot scripts such as daviddtech's MACD Divergences (5,946 boosts) confirm swing highs and lows using pivothigh and pivotlow with lbR = 5 closed bars to the right. Once confirmed 5 bars later, the line never vanishes from history, but plotting labels with offset = -lbR places the Bull or Bear tag 5 candles earlier on the swing extreme rather than on the confirmation bar where a live trader actually sees it.
What are standard MACD settings vs Linda Raschke's fast MACD settings?
Gerald Appel's classic settings are Fast = 12, Slow = 26, Signal = 9 using EMAs on close. Linda Raschke's 3/10 oscillator uses Fast = 3, Slow = 10, Signal = 16 with simple moving averages (which you can toggle inside ChrisMoody's V2 script by switching Oscillator MA Type and Signal Line MA Type to SMA). Neither setting is proven superior across all markets; faster lengths react earlier and cross more often in chop.


![Explainer diagram titled thinkScript to Pine v6, line for line: four side-by-side rows mapping thinkorswim CompoundValue recursive state, AggregationPeriod.DAY[1] higher-timeframe reads, multi-statement plot styling, and AddOrder(OrderType.BUY_AUTO) strategy orders into verified TradingView Pine Script v6.](/_next/image?url=%2Fblog%2Fthinkscript-to-pine-script.jpg&w=3840&q=75&dpl=dpl_BiEhRQzj8TcRZ2HYquKCfA5CnSZb)
