TradingView indicator comparisons

HMA vs EMA on TradingView: lag, overshoot and noise

HMA uses weighted averages and a subtraction to compensate for lag; EMA gives recent prices exponentially greater weight. In the matched 16-period experiments below, HMA follows a rising trend more closely and reaches a price step sooner, but overshoots the new level. On an alternating sideways sample, HMA eventually oscillates less than EMA, yet both produce the same repeated price crosses. Choose by the behavior of your signal rule, not by which line looks faster.

See the decision guide

Fix the experiment before choosing an average

Use N = 16, closing prices and no plot offset for both methods. Each of the three independent synthetic samples starts after 32 closes of 100; seed EMA at 100 and reset both methods before the next sample. These are calculated responses, not market observations or backtests. Bar 1 is the first new close after initialization. Calculate with full precision and round only the displayed results to three decimals.

  • Define an up cross as current close > current average and previous close ≤ previous average. A down cross reverses both inequalities. Equality on the current bar produces no signal. Read each condition only after that bar closes.
  • Count the first up cross separately from later direction changes. All three samples start with price equal to both averages at bar 0.
  • The cross rule is a measurement probe, not a recommended HMA trading system. Alan Hull describes turning points as a possible use and cautions against crossover signals in his original explanation.
SampleCloses on bars 1 through 24Question
Step110 on every barHow quickly does the line reach the new level, and does it overshoot?
One-way trend102, 104, 106, …, 148; close = 100 + 2 × barHow far behind the rising price does each line remain?
Sideways102, 98 repeated 12 timesDoes a smaller oscillation remove repeated price crosses?

The minimum arithmetic needed to reproduce the test

For a WMA of length m, give the newest observation weight m, the previous one m − 1, down to 1 for the oldest, then divide by m(m + 1)/2. Compute R = 2 × WMA(close, 8) − WMA(close, 16), then HMA = WMA(R, 4). Update EMA = (2/17) × close + (15/17) × previous EMA. Sixteen makes both N/2 and the square root of N integers, so this experiment has no length-rounding ambiguity.

  • On the first step bar, WMA(8) = 100 + 10 × 8/36 = 102.222222 and WMA(16) = 100 + 10 × 16/136 = 101.176471. R is 103.267974. With the three earlier R values at 100, HMA = 100 + (4/10) × 3.267974 = 101.307190. EMA is 101.176471.
  • HMA needs enough observations for both inner windows and its final smoothing. With these lengths, 19 consecutive source observations provide the first complete HMA window. EMA also needs a seed; matching the visible start date alone does not match its history.
  • For other lengths, document how each implementation converts N/2 and √N into integer windows. Do not silently round differently across platforms. Handle missing observations explicitly rather than treating them as zero.

Step response: HMA arrives sooner and goes past the target

Price jumps from 100 to 110 and stays there. Define response speed as the first completed bar on which the average reaches 109, or 90% of the ten-unit step. HMA reaches that threshold on bar 5; EMA reaches it on bar 19. Reaching a threshold and settling at the final price are different measurements.

  • HMA peaks at 112.512255 on bar 8. Overshoot relative to the input step is (112.512255 − 110) / (110 − 100) × 100 = 25.123%. This is a filter-response percentage, not a return.
  • Both methods give an up cross on bar 1. HMA then gives a down cross on bar 6 even though price has not fallen. EMA remains below 110 throughout these 24 bars. The HMA exit would be caused by the moving line passing price.
  • HMA equals 110 from bar 19 onward because every observation in its finite window is then 110. EMA approaches 110 from below: EMA at bar t = 110 − 10 × (15/17)^t. Its positive weighting prevents overshoot in this constant-step experiment.
BarCloseHMA (16)EMA (16)
1110101.307101.176
4110108.117103.939
5110109.939104.652
6110111.279105.281
8110112.512106.326
12110111.140107.773
16110110.110108.650
19110110.000109.073
24110110.000109.504

One-way trend: less tracking error, the same first cross

Reset the initialization, then raise every close by two units. HMA moves closer to this sustained trend, but both methods produce their first up cross on bar 1 and no down cross during bars 1 through 24. Less distance from price does not move the entry earlier under this particular rule.

  • At bar 24, close minus HMA is 1.333333; close minus EMA is 14.256112. Dividing by the two-unit rise gives equivalent distances of 0.667 and 7.128 bars along this ramp. These are ramp-specific measurements, not universal delays for arbitrary markets.
  • A rule based on the slope of an average measures something different from a price cross. Choose that rule before comparing the methods and repeat all three samples for it; do not report the best-looking rule from each sample as one strategy.
BarCloseHMA (16)EMA (16)
1102100.261100.235
4108103.728102.092
8116112.901106.511
12124122.334112.340
19138136.667124.391
24148146.667133.744

Sideways prices: less line movement, just as many crosses

Reset again, then alternate closes between 102 and 98 for 24 bars. Each close is above both averages on odd bars and below both on even bars. Both methods therefore give one initial up cross and 23 later direction changes. Waiting for closed candles cannot remove this pattern because every value in the experiment is already a completed close.

  • Once its window contains only alternating prices, HMA oscillates by about ±0.065359 around 100. EMA approaches an oscillation of ±0.125. HMA is smoother on this particular input, while the crossing count is identical.
  • A long-only enter-on-up, exit-on-down interpretation would create 12 signal pairs in this sample. That is not a profit calculation: the next tradable price, position size, spread, commission and slippage are absent.
  • A distance threshold or persistence requirement may reduce activity, but it also changes the rule and can delay a trend signal. Repeat the step and trend samples after any such change.
BarCloseHMA (16)EMA (16)Cross for both
1102100.261100.235Up
298100.15899.972Down
3102100.325100.211Up
498100.13699.951Down
19102100.065100.137Up
209899.93599.885Down
249899.93599.881Down

Repeat the comparison on TradingView without changing the test

Add the built-in Hull Moving Average and Exponential Moving Average to the same standard candlestick chart. Set both lengths to 16, use the same close source and chart timeframe, and keep offsets at zero. Compare the main EMA plot, not an additional smoothing plot. Record the symbol, exchange feed, session, adjustment settings, dates and loaded history.

  • Inspect both readings on the same completed candle. Values based on the current close can change while that candle is open. Chart-bar confirmation also does not confirm a separate higher-timeframe input.
  • Select trend and range evaluation windows before seeing the winner. Keep a later period separate to check whether the behavior persists. Synthetic tests explain the filter; they cannot estimate market performance.
  • For a strategy comparison, hold entry and exit definitions, sizing, costs and order-fill settings fixed. Record signal time separately from fill time. A bar-close signal with the usual next-tick market-order setup generally fills at the following open.
  • Use the results to choose a tradeoff: HMA for testing a smaller trend-following delay with explicit overshoot handling; EMA for testing a recursive positive-weight average. Neither choice establishes profitability or removes range failures.

Turn the chosen rules into inspectable Pine Script

Give the Pine Script AI Coding Agent your own written rules: a shared source and length, an HMA/EMA selector, both plots, completed-bar signals and explicit order timing. Ask it to draft the script, then request a syntax check and review the generated calculations. Use TradingView to inspect timestamps and strategy behavior before relying on the result.

  • Include the three sample definitions and expected values in your review notes. A syntax check can find supported compilation errors; it cannot prove that entries, exits or trading assumptions are correct.
  • The next step is code for rules you can specify and inspect. It does not require access to proprietary scripts, account migration or automatic trade execution.
Where Pineify fits

Pine Script AI Coding Agent

Draft a comparison from your specified HMA or EMA rules, request a syntax check, and inspect the generated script before testing it in TradingView.

Draft an HMA/EMA comparison

Frequently asked questions

Educational comparison, not investment advice. All numerical examples use synthetic prices and show calculated filter responses, not backtests or live trading results. Neither average predicts future prices or guarantees returns. Generated code and trading assumptions require independent review.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.