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.

The chosen EMA-signal variant (12, 26, 9)
The MACD line (main line)EMA12 of closes minus EMA26 of closes
The signal lineEMA9 calculated from the MACD line, not from price
The MACD histogramThe MACD line minus the signal line, plotted as bars
The zero lineHorizontal reference where EMA12 and EMA26 are exactly equal

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

A rounded-data zero is not an indicator zeroFull EMA12 1.10004 and EMA26 1.09996 give MACD 0.00008. Rounded to four places, both are 1.1000 and subtract to zero. With signal 0.00006, full histogram is 0.00002.ROUNDED EXPORT LOSES THE DIFFERENCEFull precisionExport: 4 placesEMA12 1.10004EMA26 1.09996M +0.00008S +0.00006H +0.00002EMA12 1.1000EMA26 1.1000Their difference 0This is not full M.Two rounded EMAs cannot recover M.Full EMA difference is 0.8 pip.Full H is 0.2 pip; both are positive here.Preserve calculation precision in exports.

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.

The right-hand zero comes from digits lost on export. It does not replace the positive full-precision difference on the left.

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.

Calculating the MACD line on a hypothetical EUR/USD bar
EMA12 current value1.08540
EMA26 current value1.08312
MACD line1.08540 minus 1.08312 equals 0.00228 (22.8 pips)
Signal line, EMA9 of the recent MACD line0.00194 (19.4 pips)
MACD histogram0.00228 minus 0.00194 equals 0.00034 (3.4 pips, a positive bar)
InterpretationM is positive and H is positive. This single state does not establish a crossing or acceleration of price.

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.

State the series before detecting an event
Zero-line crossoverM changes sign under a stated equality convention
Regular or hidden divergenceSpecified price pivots and M or H pivots differ in direction
Signal-line crossoverM changes side relative to S; test H across observations

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 four types of MACD divergence and their meaning
Regular bullishPrice lower low, M higher low; a pivot relationship, not a guaranteed outcome
Regular bearishPrice higher high, M lower high; a pivot relationship, not a guaranteed outcome
Hidden bullishPrice higher low, M lower low; a pivot relationship, not a guaranteed outcome
Hidden bearishPrice lower high, M higher high; a pivot relationship, not a guaranteed outcome

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

Synthetic C(t) = 100 + t with explicitly chosen initial states
Initial t = 0C = 100; EMA12 = 94.5; EMA26 = 87.5; M = S = 7; H = 0
After t = 1C = 101; EMA12 = 95.5; EMA26 = 88.5; M = S = 7; H = 0
After t = 10C = 110; EMA12 = 104.5; EMA26 = 97.5; M = S = 7; H = 0
Steady-state EMA relationEMA(N,t) = C(t) − (N − 1)/2 under α = 2/(N + 1)
Main-line differenceM = 12.5 − 5.5 = 7 at every update
Signal initialisationEMA9 starts at 7 and receives M = 7 at each step, so S stays 7
Price change versus histogramC rises by 10 units while H stays zero. Different starting states can create transient differences.

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.