Explainers / MACD 4C by vkno422
MACD 4C by vkno422, explained from the source
MACD 4C is an open-source TradingView indicator by vkno422 with about 21,000 boosts. In the code its title is "4 colour MACD". It draws one row of columns in four colours and a zero line. The whole script is 11 lines. This page walks through it, says what each part really does, and ends with where it fails. It does not say whether the indicator makes money, and it gives no trades.
The surprise: these columns are not the MACD histogram most charts draw
On most platforms the MACD histogram is the MACD line minus its signal line. The columns in this script are the MACD line itself: a fast exponential average of the close minus a slow one. The code does ask for a 9-bar signal value, then throws it away. No signal line is drawn and none is used.
So the columns here cross zero when the two averages cross, not when MACD crosses its signal. In our Python port the columns and a standard histogram were on opposite sides of zero on 38.9% of bars, and were moving in opposite directions on 22.7%. A reader who brings histogram habits to this pane will misread it about two bars in five.
Step 1: the MACD line
Fast average 12, slow average 26, both of the close. Each setting has a minimum of 7, so you cannot go faster than 7. Nothing stops the fast length being set above the slow one, which flips the sign of every column.
Step 2: the four colours
Two tests: is the value above zero, and is it higher or lower than one bar ago.
- Above zero and higher than a bar ago: lime.
- Above zero and not higher: green.
- At or below zero and lower than a bar ago: maroon.
- At or below zero and not lower: red.
The "bar ago" value is worked out by running the same MACD on the previous close, which gives the previous bar's MACD.
Step 3: what is not in the code
No signal line, no classic histogram, no alert conditions, no marks where a colour changes. A yellow colour is named in the code and never used.
What we checked in Python
We ported the logic to Python and ran it on invented random-walk prices with a typical move of 1% a bar, each bar built from 10 smaller steps: 40 runs of 5,000 bars, the first 300 of each run left out.
Against a standard histogram. Opposite side of zero on 38.9% of bars; opposite direction on 22.7%.
How often the colour changes. A median of 1,175 changes per 4,700 bars, one bar in four. These prices have nothing to find, so the colour changes that often on noise.
The live bar flickers. The averages use the current price until the bar closes. On 33.8% of bars the column showed a different colour at some point inside the bar from the one it finished with. With finer steps inside each bar that rose to 41%.
These figures describe the code on invented data, not any market.
Where it fails
- It is not the histogram. The columns are the MACD line. Zero here means the averages crossed, not that MACD crossed its signal.
- There is no signal line. The 9-bar value is computed and dropped.
- Colour changes are frequent. One bar in four on random prices.
- The live column changes colour. About one bar in three showed another colour before the close.
- Equal values lean one way. A column that has not moved is shown green above zero and red below.
- Lengths below 7 are blocked, and a fast length above the slow one is allowed.
- No alerts.
- It lags like any average. Both tests are built from 12 and 26-bar averages of past closes.
Educational only. Not financial advice. Nothing here is a recommendation to buy or sell anything. MACD 4C is by vkno422 on TradingView; this page describes its published open-source code in our own words and is not affiliated with the author. Simulation figures come from synthetic random-walk prices and say nothing about how the script behaves on any market.
Also explained: Repaint checker, VWAP, Supertrend, RSI, UT Bot Alerts, Nadaraya-Watson Envelope, Squeeze Momentum, What is repainting on TradingView?, Is TradingView backtesting accurate?, Chandelier Exit, WaveTrend Oscillator, QQE MOD, Pivot highs and lows, Hull Suite, Range Filter, Twin Range Filter, HalfTrend, ZigZag++, SSL Hybrid, CM MacD Ultimate MTF, Volume Profile / Fixed Range, ADX and DI, Support Resistance Channels, Market Structure Break & Order Block, Order Block Finder, Pivot Point SuperTrend, Trendlines with Breaks [LuxAlgo], Divergence for Many Indicators, TradingView script selling terms, Support and Resistance Levels with Break, Liquidity Swings [LuxAlgo], Pine Script errors, Breakout Probability (Expo), Did ChatGPT or Claude write your Pine Sc, Lorentzian Classification, SuperTrend AI (Clustering), Machine Learning Adaptive SuperTrend, Dynamic Swing Anchored VWAP, Support and Resistance Power Channel by , Support and Resistance (High Volume Boxe, Trendline Breakouts With Targets by Char, Breakout Finder by LonesomeTheBlue, Volume Flow Indicator by LazyBear, FVG Order Blocks by BigBeluga, CM_Williams_Vix_Fix by ChrisMoody, Bollinger + RSI Double Strategy by Chart, Ultimate Moving Average MTF by ChrisMood, Fibonacci Bollinger Bands by Rashad, Candlestick Patterns Identified by repo3, MACD + SMA 200 Strategy by ChartArt, Pine Script v5 to v6, Moving Average Cross Alert, Multi-Timefr, WaveTrend Oscillator [WT] by LazyBear, WaveTrend with Crosses [LazyBear], CM_Price-Action-Bars by ChrisMoody, RSI Candles by glaz, CM RSI-2 Strategy Lower Indicator by Chr, CM Stochastic Multi-TimeFrame by ChrisMo, CM_Ultimate RSI Multi Time Frame by Chri, TonyUX EMA Scalper - Buy / Sell by tux, My Pine Script is valid. What did the va
Get the next teardown by email
One short email when a new teardown or free tool goes live, about twice a month. No signals, no hype. Unsubscribe in one click.
Almost done. Check your inbox and click the confirmation link.
Sent with Kit. Your address is used only for these emails. Privacy
No TradingView account yet? This affiliate link gives you a $15 coupon toward a paid plan, and we earn a commission if you buy one. The free plan is enough to follow this page.