Hull Moving Average (HMA): Formula, Settings & TradingView
Understand the HMA formula with a numerical example, check rounding differences, add Hull Moving Average in TradingView, and test settings without hindsight.
The Hull Moving Average (HMA) is Alan Hull's price overlay designed to reduce moving-average lag. It combines a half-length and full-length weighted moving average, then smooths their difference. It still uses current and past prices: a faster turn is not a prediction or a complete trading strategy.
The compact formula is:
Raw HMA = 2 × WMA(price, n/2) − WMA(price, n)
HMA = WMA(Raw HMA, √n)
The final WMA runs over a series of Raw HMA values, not over the latest raw value alone. Derived periods must be integers; implementations can handle fractional lengths differently. That detail matters when trying to match a chart or spreadsheet.
| Your question | What to check first |
|---|---|
| How is HMA calculated? | The three WMA stages and the numerical example below |
| Why do two HMA lines disagree? | Source, bar data, half/root rounding and indicator version |
| How do I add it in TradingView? | Search for the built-in Hull Moving Average |
| What are the best settings? | Define a task and test a small fixed set; no universal best length |
| Does a turn mean buy or sell? | Separate the slope observation from your entry, exit and risk rules |
For the broader choice between averages, use the moving-average comparison guide. This page focuses on calculating and testing HMA.
HMA Formula: Calculate the Three WMA Stages
A standard linearly weighted moving average gives the newest of m values weight m, the next newest weight m−1, and the oldest weight 1. The denominator is the sum of those weights: m(m+1)/2. See the WMA formula guide for that component.
To compute HMA, choose the full length n, the half length h, and the final smoothing length s. At each bar:
- Calculate
WMA(price, h)andWMA(price, n)from the same price source. - Form
Raw HMA = 2 × WMA(price, h) − WMA(price, n). - Apply
WMA(Raw HMA, s)after enough raw values exist.
Alan Hull's original explanation uses integer versions of n/2 and √n. Subtracting the longer average makes this a different construction from simply shortening a WMA. The output can overshoot price; “moving average” does not mean every HMA value must stay inside its input price range.
Numerical Example: HMA(4) on Five Closes
Use these invented closing prices, oldest first: 100, 101, 102, 101, 103. This small example makes every weight visible; length 4 is a calculation example, not a recommended setting. Here h = 2 and s = 2, so rounding is irrelevant.
| Calculation | At bar 4 | At bar 5 |
|---|---|---|
| WMA(2) of closes | (102 + 2×101) / 3 = 101.3333… | (101 + 2×103) / 3 = 102.3333… |
| WMA(4) of closes | (100 + 2×101 + 3×102 + 4×101) / 10 = 101.2 | (101 + 2×102 + 3×101 + 4×103) / 10 = 102 |
| Raw HMA | 2×101.3333… − 101.2 = 101.4666… | 2×102.3333… − 102 = 102.6666… |
The HMA at bar 5 weights the newest raw value twice:
HMA(4) at bar 5
= (Raw HMA at bar 4 + 2 × Raw HMA at bar 5) / 3
= (101.4666… + 2 × 102.6666…) / 3
= 102.2666…
Keep full precision between stages; the decimals above are display approximations. This output does not come from applying WMA(2) directly to the closing prices. Those closes produced the inner averages first. With this complete-window calculation, the first raw value arrives at bar 4 and the first final value at bar 5. Platform warm-up behavior can differ.
Integer Lengths: Why HMA Values Can Differ
Do not assume every implementation rounds to the nearest integer. Hull's published notation uses Integer(); StockCharts ChartSchool explicitly documents nearest-integer rounding. The latter is an implementation convention, not a rule to silently apply to every platform.
| Full length | Half length: integer part / nearest | Root length: integer part / nearest |
|---|---|---|
| 11 | 5 / 6 | 3 / 3 |
| 20 | 10 / 10 | 4 / 4 |
| 21 | 10 / 11 | 4 / 5 |
The old length-20 example happens to produce the same periods under both conventions. It cannot establish which convention a chart uses. TradingView's HMA help page describes the three stages but does not specify integer handling. Verify the implementation you use before claiming a spreadsheet reproduces its output exactly.
When comparing values, also match the instrument and data feed, session, bar interval, price source, indicator length and display offset. Save those inputs with the result. A screenshot with the label “HMA 20” alone is insufficient to reproduce it.
Add Hull Moving Average in TradingView
On a TradingView Superchart, open Indicators and search for Hull Moving Average. Select the built-in indicator rather than assuming a similarly named community script has the same calculation or signals. Open its settings to check the inputs and visual style.
Record the available Length and Source settings. Keep the display offset at zero while measuring signal timing. Moving a line on the time axis is not evidence that it predicted price. If you use a community script with slope colors, alerts or extra filters, record its name and version separately.
The official HMA documentation is the calculation reference. A script called “Hull Suite,” an adaptive Hull variant and the built-in HMA should not be treated as interchangeable solely because they share a name.
HMA Settings: Choose a Test, Not a Universal Best Length
Length counts bars, not minutes or days by itself. HMA(20) on a five-minute chart uses a different span from HMA(20) on a daily chart. Price source and market conditions also change what a turn represents.
Start with one task: describe a trend, measure turns, or filter a separately defined setup. Then choose a small fixed set of lengths before looking at results. For example, comparing 20 and 50 can illustrate the effect of smoothing; those are experimental choices, not optimized settings for a particular market.
| Test question | What to keep fixed | What to record |
|---|---|---|
| Does a shorter length turn more often? | Market, source, interval and sample dates | Turns per sample and subsequent reversals |
| Does a longer length delay my trigger? | Written trigger definition and entry timing | Bars until the trigger; missed entries |
| Does the filter help a setup? | The setup's risk, exit and cost assumptions | Accepted/rejected trades and net results |
| Does the result transfer? | Parameters chosen on the first sample | Results on a separate untouched sample |
Do not label a length “best” because it fits one visible trend. A setting can look clean on that trend and repeatedly change direction in a range. Reserve separate data before choosing parameters, and include sideways periods and transitions in both samples.
Reading HMA Slope, Turns and Crossovers
A rising HMA means its current value is higher than its preceding value; a falling HMA means the opposite. Flat values need a separate rule. Intrabar values can change before the candle closes, so record whether your rule uses confirmed closes or live updates.
A testable turn rule might be: “At a completed bar, the HMA changes from falling to rising; equal values do not count.” That only defines an observation. You still need market context, an entry rule, invalidation, sizing and an exit before testing a trading strategy.
Hull proposes studying turns and discourages HMA crossover applications because they rely on lag differences. That methodological preference is not proof that any turn is profitable or that every crossover system fails. A price crossing HMA and two HMA lines crossing are also different events; label them separately in your records. Fidelity's HMA guide discusses using shorter and longer periods for different trend-reading tasks.
HMA vs SMA, EMA and WMA
| Average | Construction | What to compare in your own sample |
|---|---|---|
| SMA | Equal weights over a window | Baseline smoothing and turn timing |
| EMA | Recursive exponential smoothing | Responsiveness and initialization effects |
| WMA | Linear weights over a window | The building block used inside HMA |
| HMA | Difference of two WMAs, then another WMA | Turn timing, overshoot and repeated turns |
A same-length comparison helps reveal construction differences. It does not make the lines equivalent in effective smoothing, or establish a universal speed ranking. Count behavior on the same data rather than deciding from one attractive chart. Calculation details belong in the dedicated SMA guide and EMA guide.
Replay Drill: Measure HMA Without Picking Known Reversals
Select sample dates before viewing the future chart. Do not start by finding a completed reversal and then ask which average saw it first; that selects the outcome in advance.
- Choose a market, interval, price source and indicator version. Record lengths and rounding conventions where known.
- Write the turn rule and the comparison rule. For an HMA/SMA timing comparison, use the same source and bar interval, and record the lengths explicitly.
- Start replay before the chosen sample with enough prior bars for both lines to initialize. Hide future candles and advance one completed bar at a time.
- Log every qualifying turn, including turns that fail. Freeze the observation before advancing.
- If measuring a “false turn,” define it first. An illustrative rule is a slope reversal within the next five completed bars; five is a chosen evaluation horizon, not an industry standard.
- Review the full sample, then test the unchanged rules on the reserved sample. Any trading-result claim also needs execution and cost assumptions.
| Sample/date | Source/interval | HMA/SMA lengths | HMA turn bar | SMA turn bar, if any | Timing difference | Reversed within defined horizon? |
|---|---|---|---|---|---|---|
If SMA never turns within the observation window, record “no turn”; do not invent a timing difference. Record equal-value handling and distinguish finalized from still-open candles. The worksheet measures indicator behavior, not a win rate.
Use TradingView Bar Replay for this overlay exercise. For a separate exercise in making chart decisions before the next candle, open ChartMini forex replay. That mode advances historical five-minute forex bars; Daily Replay for stocks uses daily stock bars. Choose the interval that matches the question you are practicing, and keep indicator-comparison outputs tied to their original data source.
Common HMA Testing Mistakes
- Treating reduced lag as forecasting. The calculation still depends on observed prices.
- Mixing implementations. Check integer conventions before blaming the data or the formula.
- Choosing samples after the fact. Include all turns in preselected periods, not just memorable reversals.
- Changing length after each loss. Keep the test version fixed; evaluate a change on separate data.
- Assuming a colored line supplies a strategy. A slope color does not specify fills, stops, costs or position size.
Frequently Asked Questions
What is the Hull Moving Average?
HMA is a price overlay created by Alan Hull. It combines weighted averages to reduce lag while smoothing the plotted series. It can help describe trend behavior, but it does not predict future prices.
How is HMA calculated?
Calculate a half-length WMA and a full-length WMA of the same price source. Double the first and subtract the second to form a raw series. Smooth that raw series with a WMA whose length derives from the square root of the full length, using your implementation's integer convention.
Why does my HMA calculation differ from the chart?
Compare the half-length and square-root rounding rules, price source, bar data, session, interval, warm-up and offset. Matching the displayed full length alone does not guarantee matching values.
What are the best HMA settings?
There is no universal best setting. Define the task, choose a small parameter set in advance, measure every qualifying event and validate on separate data. A number that worked on one sample is a hypothesis for the next sample.
Is HMA better than EMA?
They use different constructions. Compare turn timing, smoothing and false turns under the same data and written rules. Faster reactions alone do not establish better net trading results.
Should I trade HMA crossovers?
Hull favors turns over HMA crossovers. If you test a crossover, define whether it is price versus HMA or one average versus another, and specify the rest of the strategy. The crossing itself is not a demonstrated edge.
Sources
- Alan Hull: original HMA explanation and formula
- TradingView: Hull Moving Average
- StockCharts ChartSchool: HMA calculation and rounding
- Fidelity: Hull Moving Average
All examples are educational. Indicator behavior in historical data does not establish future returns or executable fills.