In this article
After this article, you can
- Check whether an export retains the difference needed for MACD.
- Separate a full-precision zero from a rounding-produced zero.
Terms at hand: Exponential Moving Average (EMA) · Trading Journal · Commission · Stop loss · Stop out · Take profit (TP)
A MACD specification needs more than the numbers 12, 26 and 9: define the price source, average types, initial history and plotted series. This article calculates a complete two-step model, compares EMA and SMA signals, and shows why rounding or a different initial state changes the result. It explains calculation mechanics rather than attributing trading rules or performance claims to an author whose original work has not been read here.
What MACD is really made of
The first table uses a chosen close-price EMA variant: M = EMA12(C) − EMA26(C), S = EMA9(M) and H = M − S. These are related calculations, not three independent pieces of market evidence. For the built-in MT5 MACD, the documented signal is SMA9(M) and the bars show M; TradingView allows users to choose source and average types.
A MACD-line value of zero means that the selected fast and slow moving-average values are equal. Equality alone does not prove a crossover: compare the preceding and following values using the same inputs and settings. Above zero, the fast average exceeds the slow one; below zero, it is lower. Those relationships alone do not establish that the current price is rising or falling.
Periods, initialisation and reproducible settings
The periods count input observations, such as completed H1 or D1 candles. They are not a fixed number of calendar days or a guaranteed signal delay. The EMA coefficient chosen here is α = 2/(N + 1): 2/13 for EMA12, 2/27 for EMA26 and 0.2 for EMA9. TradingView’s moving-average explanation starts its example from an SMA; the experiments below instead declare their starting states explicitly.
Different initial states can remain visible even on identical later prices. Two EMAs with the same α and subsequent input sequence have a difference Δ(k) = (1 − α)^k × Δ(0). For EMA26, an initial difference of 10 pips becomes 10 × (25/27)^26 ≈ 1.3520 pips after 26 updates. This is a calculation, not a universal warm-up requirement or a claim about future performance.
Rounded EMAs cannot reconstruct full MACD
An export can look correct while losing a difference needed by a detector. Compare subtraction before and after rounding.
Scroll sideways to see the full diagram
Hypothetical assumed states for an EMA 12–26–9 variant. EMA12 = 1.10004, EMA26 = 1.09996, signal S = 0.00006. EUR/USD-style price units, pip = 0.0001. The right panel rounds only the two EMAs to the nearest four places, without altering full indicator calculations. No crossover is inferred without a previous observation. TradingView — MACD defines short-minus-long MA in M and subtracting signal in H.
Export both EMAs, M and S at calculation precision to reconcile implementations, then prepare the display. With only two numbers of 1.1000, do not guess missing digits: they can hide a positive, negative or zero difference. Larger fonts or different colours cannot restore lost data.
Exactly how each component is calculated
The exponential moving average that underpins all of MACD is calculated recursively. The formula is straightforward: today’s EMA equals today’s closing price multiplied by a smoothing factor plus yesterday’s EMA multiplied by one minus the same factor. The smoothing factor for an EMA with period N is two divided by N plus one. For EMA12 that gives a value of about 0.1538, and for EMA26 about 0.0741. In practice the most recent candle has roughly a fifteen percent influence on EMA12 and just under eight percent on EMA26. That asymmetry of reaction speeds is where the whole point of the indicator comes from.
The figures in the preceding table are assumed indicator states, not values derived from a supplied complete price history. EUR/USD-style pip = 0.0001 gives M = 22.8 pips, S = 19.4 pips and H = 3.4 pips. Their units follow the input-price scale; they are not universal “typical ranges” for EUR/USD, USD/JPY or gold. A consistent positive rescaling of prices and initial states rescales M, S and H without changing their signs.
Different relationships require different event definitions
A zero-line crossing concerns M changing sign. A signal-line crossing concerns H = M − S changing sign. Divergence compares selected pivots in price with a specified indicator series. None of these definitions assigns a universal frequency, success rate or reliability rank.
For a strict upward zero-line event, previous M < 0 and current M > 0; a sampled series need not contain an observation exactly equal to zero. A single M = 0 only establishes equal fast and slow averages. State how zeros and display rounding are treated before counting crossings.
For a strict upward signal-line event, previous H < 0 and current H > 0. It can occur with M still negative. Counting events does not establish trading outcomes: admission rules, position state, executable prices and costs are separate. A higher-timeframe filter also needs a rule for when its candle becomes available.
Why H is not the second derivative of price
The MACD histogram is the main line minus the signal line. It shows their signed gap, rather than a literal second derivative of price. Rising or falling bars describe a change in that gap; by themselves they do not prove that price is accelerating or decelerating. A single histogram value also does not establish whether the gap has changed.
- H rising and positive: M exceeds S and the signed gap is increasing. This alone is not evidence that price accelerated or a reason to hold a long position.
- H falling but positive: M still exceeds S while the signed gap decreases. Whether to reduce or exit a position belongs to a separately specified trade rule.
- H crosses downward through zero: M changes side relative to S under the chosen zero convention. This is a signal-line event, not a guaranteed change in price direction.
- H becomes more negative: the signed M − S difference falls. M itself may still be positive; negative H is not sufficient to identify a price downtrend.
A complete counterexample uses initial EMA12 = EMA26 = 1.10000 and S = 0, followed by two identical closes of 1.10351. At t1, EMA12 = 1.10054 and EMA26 = 1.10026, so M = 0.00028, S = 0.000056 and H = 0.000224. At t2, the unrounded recurrences give EMA12 ≈ 1.100996923, EMA26 ≈ 1.100500741, M ≈ 0.000496182, S ≈ 0.000144036 and H ≈ 0.000352146. Price did not change between t1 and t2, but H increased. The second price difference is −0.00351, not the positive H. These are hypothetical calculation controls, not market observations.
Name the pivots used in a divergence comparison
The table describes four directional comparisons using M as the selected indicator series. It does not rank them or demonstrate a profitable strategy. If you substitute H, relabel the comparison and calculate it separately. A pivot rule that needs later candles must be evaluated at its confirmation time.
The terms “regular” and “hidden” distinguish the directional pairings. Their interpretation needs a defined input series and pivot-selection rule; a descriptive label does not show when a reversal or continuation will occur. Compare rules on a documented sample rather than assigning a universal win rate to the names.
An additional price condition may be included in a strategy, but it does not convert divergence into a guaranteed profitable order. State the condition, confirmation delay, execution side and costs. Neither the table nor the arithmetic here establishes that hidden divergences outperform regular ones.
Practical takeaway: Rounding the exported EMAs can erase their difference. Keep calculation precision when checking MACD.
Control model — a rising price with H equal to zero
Substitute EMA(N,t) = C(t) − (N − 1)/2 into the declared recurrence to verify the linear model. Its initial states are artificial controls, not default platform seeds. Separately, the two-step EUR/USD model has eight prior M values equal to zero: at t1, SMA9(M) = 0.00028/9 ≈ 0.000031111 and M − SMA9 ≈ 0.000248889. The standard MT5 bars instead show M = 0.00028. Agreement with one formula does not make another formula wrong.
The most common mistakes in reading MACD
Applying MACD mechanically, without understanding what each signal means, leads to a handful of recurring errors. A few of them come back often enough to be worth listing separately.
- Confusing an equality with a crossing. M = 0 means equal fast and slow averages; H = 0 means M = S in the declared variant. Compare successive observations before reporting a newly crossed level.
- Assuming a fixed delay or best timeframe. The inputs and periods define the calculation. They do not establish that M5 fails, H4 succeeds or another oscillator is universally superior.
- Using information not yet available. If a filter requires a completed higher-timeframe candle or a confirmed pivot, record when it becomes known. Do not use the later final value for an earlier decision.
- Treating a named comparison as a complete order rule. Define any extra price condition and its observation time. A candle pattern or structural break does not guarantee the subsequent fill or profit.
- Selecting parameters and evaluating them on the same data. Preserve a separate evaluation sample and document costs, initialisation and all selection choices. A historical fit alone does not establish future performance.
What to remember and what to do next
A complete specification states the input prices, average types, periods, initial history and plotted series. The selected EMA variant and the built-in MT5 variant differ in signal construction and presentation. Match those definitions before comparing charts or trade rules.
Zero-line and signal-line events compare different series; divergence adds a pivot-selection rule. None carries a formula-defined reliability rank. The linear control shows that zero H can coexist with rising prices, while the two identical closes show that increasing H can coexist with unchanged price.
The histogram highlights changes in the signed gap between MACD and its signal. Peaks, troughs and contractions can be included in an exit rule, but there is no universal guarantee that such a rule exits earlier or performs better than a crossover rule.
Keep full calculation precision, declare initial states and use only information available at the decision. Correct reconstruction confirms the chosen calculation. Evaluating a strategy still requires separate admission, exit, fill and cost rules.
Related reading: MACD — how to read and use this momentum indicator — the practical guide to its signals; EMA vs SMA — which moving average is better — a deeper look at the maths of moving averages, on which MACD is built; RSI — how to read and when it fails — the complementary momentum indicator, the one most often paired with MACD.
Check your understanding
One short exercise
About 2 min · you can try again
Full EMAs are 1.10004 and 1.09996; S = 0.00006. Both exported EMAs show 1.1000. What is full histogram H?
- 0, because exported EMAs are equal.
- +0.00002, or 0.2 pip in the model.
- +0.00008, because the histogram always equals M.
Check the answer and explanation
+0.00002, or 0.2 pip in the model.
M = 1.10004 − 1.09996 = 0.00008; H = 0.00008 − 0.00006 = 0.00002.
Frequently asked
Why 12, 26 and 9? Where do those numbers come from?
12, 26 and 9 are common parameter values; the primary documentation read here does not establish the claimed historical derivation from Saturday trading or a universal performance advantage. For α = 2/(N + 1), the coefficients are 2/13, 2/27 and 0.2. The periods count input observations, not fixed calendar days. Specify source, average types and initial states too: built-in MT5 uses an SMA signal, while the first model uses EMA.
What exactly is the difference between a zero-line cross and a signal-line cross?
A zero-line event concerns M changing sign; a signal-line event concerns M − S changing sign. An observation exactly equal to zero proves equality, not a crossing. Under strict adjacent-bar rules, previous and current signs must differ; decide how to handle intermediate zeros and rounding. The calculation does not prescribe universal annual event counts or establish that one crossing type confirms a real price-trend change.
What is the histogram for if I already have the main and signal lines?
For the selected variant, H = M − S displays the same gap encoded by the two lines. It is not a literal second price derivative or a measure of its own rate of change. In the two-step model, price remains 1.10351 while H increases from 0.000224 to approximately 0.000352146. In the linear control, price rises while H stays zero. These counterexamples do not imply a particular exit rule. Check the plotted series: built-in MT5 bars are M.
What is the difference between regular and hidden divergence?
Using M as the named indicator series, regular bullish divergence pairs a lower price low with a higher M low; regular bearish pairs a higher price high with a lower M high. Hidden bullish pairs a higher price low with a lower M low; hidden bearish pairs a lower price high with a higher M high. Those labels describe selected pivots, not guaranteed reversal or continuation. State pivot-confirmation timing, and do not infer that hidden variants outperform regular variants without a specified study.
Sources & bibliography
-
Gerald Appel Technical Analysis: Power Tools for Active Investors · FT Press, 2005; Appel's book discusses technical-analysis tools, including MACD. www.amazon.com ↗
-
Investopedia MACD Indicator Explained · An introductory explanation of MACD and its formulas. www.investopedia.com ↗
-
StockCharts ChartSchool MACD (Moving Average Convergence/Divergence Oscillator) · An extended explanation of the MACD oscillator with chart examples. chartschool.stockcharts.com ↗
-
Constance Brown Technical Analysis for the Trading Professional · McGraw-Hill, 2011; discusses regular and hidden divergences. www.mhprofessional.com ↗
-
TradingView Moving Averages · EMA recurrence, α = 2/(N + 1) and an SMA-seeded example. The article explicitly chooses its own synthetic initial states. www.tradingview.com ↗
-
MetaQuotes MetaTrader 5 Help — Moving Average Convergence/Divergence · The built-in MT5 main calculation and SMA9 signal, distinct from the EMA9-signal variant used in the numerical controls. www.metatrader5.com ↗
-
TradingView Moving Average Convergence Divergence (MACD) indicator · M, S and H definitions and configurable input/average types. This does not establish a universal signal ranking or win rate. www.tradingview.com ↗
