Hull Moving Average Trading Strategy: Backtest
Hull moving average strategy backtest
Experienced traders know that the best trading indicators are those that can reduce lag, eliminate noise, and quickly respond to sustained market changes. The Hull Moving Average (HMA) seems to tick those boxes. What do you know about the indicator? Is it possible to find profitable Hull moving average strategies?
Yes, Hull moving average strategies do work. Our backtests show that a hull moving average can be used profitably for both mean-reversion and trend-following strategies on stocks depending on the time frame.
Developed by Alan Hull in 2005, the Hull Moving Average (HMA) indicator is a combination of weighted moving averages (WMAs) that prioritizes recent price changes over older ones. It is a directional trend indicator, which tries to capture the current state of the market and uses recent price action to determine if conditions are bullish or bearish relative to historical data. The indicator attempts to minimize the lag of a traditional moving average while retaining the smoothness of the moving average line.
Does a Hull moving average strategy work? (Backtest)
Before we go on to explain what a Hull moving average is and how you can calculate it, we go straight to the essence of what this website is all about: quantified backtests.
Our hypothesis is simple:
Does a Hull moving average strategy work? Can you make money by using Hull moving averages strategies?
We look at the most traded instrument in the world: the S&P 500. We test on SPDR S&P 500 Trust ETF which has the ticker code SPY.
All in all, we do four different backtests:
- Strategy 1: When the close of SPY crosses BELOW the N-day moving average, we buy SPY at the close. We sell when SPY’s closes ABOVE the same average. We use CAGR as the performance metric.
- Strategy 2: Opposite, when the close of SPY crosses ABOVE the N-day moving average, we buy SPY at the close. We sell when SPY’s closes BELOW the same average. We use CAGR as the performance metric.
- Strategy 3: When the close of SPY crosses BELOW the N-day moving average, we sell after N-days. We use average gain per trade in percent to evaluate performance, not CAGR.
- Strategy 4: When the close of SPY crosses ABOVE the N-day moving average, we sell after N-days. We use average gain per trade in percent to evaluate performance, not CAGR.
The results of the first two backtests look like this:
Strategy 1
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
4.86 |
6.08 |
8.84 |
6.06 |
6.83 |
7.7 |
MDD |
-47.94 |
-25.06 |
-30.62 |
-36.38 |
-38.58 |
-42.25 |
Strategy 2
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
4.62 |
3.42 |
0.8 |
3.44 |
2.69 |
1.86 |
MDD |
-38.45 |
-59.89 |
-72.02 |
-50.05 |
-49.88 |
-53.5 |
Compared to the simple moving average and the exponential moving average, the Hull moving average has decent returns for all number of days in strategy backtest 1.
Why is it like that?
We suspect it might build down to that the Hull moving average puts more emphasis on the most recent values (see more about the Hull moving average below).
Strategy 1 is better than strategy 2 indicating that the Hull average work better for mean-reversion strategies. It’s better to buy a break BELOW the Hull moving average than it’s to buy a break ABOVE the average.
The results from backtests 3 and 4 look like this (the results are not CAGR, but average gains per trade):
Strategy 3
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.23 |
0.36 |
0.96 |
2.31 |
4.05 |
8.94 |
10 |
0.11 |
0.37 |
1.03 |
2.03 |
4.04 |
8.69 |
25 |
0.24 |
0.38 |
1.16 |
2.28 |
4.29 |
9.25 |
50 |
0.23 |
0.52 |
1.14 |
2.32 |
3.47 |
9.09 |
100 |
0.2 |
0.38 |
0.99 |
2.29 |
4.01 |
8.08 |
200 |
0.14 |
0.25 |
0.62 |
1.94 |
4.02 |
7.8 |
Strategy 4
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.15 |
0.44 |
0.95 |
2.26 |
4.08 |
8.92 |
10 |
0.23 |
0.3 |
1.04 |
2.19 |
4.38 |
8.03 |
25 |
0.24 |
0.14 |
0.66 |
2.25 |
4.28 |
7.94 |
50 |
0.16 |
0.34 |
0.95 |
2.17 |
3.81 |
8.38 |
100 |
0.06 |
0.29 |
0.53 |
1.7 |
3.7 |
7.96 |
200 |
-0.03 |
0.18 |
0.56 |
1.24 |
3.47 |
8.19 |
As expected, the longer you are in the stock market, the better returns you get. This is because of the tailwind in the form of inflation and productivity gains. Strategy 3 and 4 seem pretty equal in terms of returns.
However, be aware that this is just one method of testing a moving average. There are basically unlimited ways you can use a moving average and your imagination is probably the most restricting factor!
What is Hull Moving Average?
Moving Averages are popular technical indicators that smoothen price series by continuously estimating the average price over a certain period. Many traditional moving average indicators tend to lag the price, which is why the Hull Moving Average (HMA) was created. Developed by Alan Hull in 2005, the HMA makes use of weighted moving averages to prioritize more recent values and greatly reduce lag. It not only minimizes the lag of a traditional moving average but also retains the smoothness of the moving average line.
The HMA is a directional trend indicator that tries to capture the current state of the market and uses recent price action to determine if conditions are bullish or bearish relative to historical data. It differs from more traditional trend indicators like the Exponential Moving Average (EMA) and the Simple Moving Average (SMA) by following the price closely yet retaining its smoothing effect.
The goal is to provide more information of higher quality to those whose trading strategy depends on the slim margins within the price movements of an instrument. It achieves this with a combination of weighted moving averages (WMAs) that prioritizes recent price changes over older ones. The result is a moving average that’s dynamic yet smooth, able to help identify the dominating market trend.
Thus, it is designed to provide a balance between providing an accurate signal that waits for confirmation and the first-mover advantage that can only come from a fast, low latency trigger. The indicator has two dimensions: positional value (an attribute native to all moving averages), which determines the location relative to price, and directional value, which is derived from the current slope direction.
Swing and long-term traders can use it to complement other indicators or confirm trading signals by combining various in-depth analysis techniques, as it generates a smooth line that is easy to work with. As with other indicators, it may not tell the whole story.
How to calculate Hull Moving Average
The Hull Moving Average indicator is created from two different weighted moving averages (WMAs) of price, plus a third WMA that smoothens the raw moving average. Thus, there are three parts to the calculation, as follows:
Step 1: Calculate two WMAs
Here you calculate the two WMAs that would form the basis of the indicator. One of the WMAs will have the specified number of periods and the other will be half the specified number of periods. The formula is as follows:
WMA1 = WMA(n/2) of price
WMA2 = WMA(n) of price
where “n” indicates the number of periods specified by the chartist
Step 2: Calculate the raw (non-smoothed) Hull Moving Average
The formula is as follows:
Raw HMA = (2 * WMA1) – WMA2
Step 3: Get a smoothened average of the raw HMA
You do this with another WMA, but this time, it’s with the square root of the specified number of periods. The formula is thus:
HMA = WMA(sqrt(n)) of Raw HMA
Note that you may not always get a whole number in any of the steps. In that case, you round up the value to the nearest whole number, so we can use that as the number of periods when calculating weighted moving averages.
However, you don’t necessarily need to do these calculations yourself, as most trading platforms have the indicator and inbuilt platform algorithms compute the indicator and display the line on the chart.
Best settings for Hull Moving Average Strategy
Just like any other technical indicator, you need to use the most appropriate settings to get the best out of it. That is also the same with the HMA — you need to have the right period. The default setting for the HMA is a period of 14. But you can easily tweak this to meet your trading strategy. The four different backtests we did earlier in the article might provide you with some clues.
The best way to get the right period for HMA is to spend some time checking different periods with a demo account to see the one that works well for you. You may try out higher periods like 15, 25, and 50 to see what they offer. If you trade on the daily timeframe, 21 may seem quite good, as it represents the average number of trading days in a month.
How Hull Moving Average works
Now, you may be wondering: How do these calculations reduce lag? Well, by placing additional weight on more recent values, the indicator reduces lag significantly. Also, lag is further reduced by offsetting one WMA with another WMA that covers only the most recent half of the specified timeframe, as this even puts more focus on recent values.
Finally, getting a WMA of the raw HMA, with even fewer periods (the square root of the number of periods in the specified timeframe), further weights towards the most recent data. So, you end up with a smooth moving average line that stays very close to the price bars.
How to interpret Hull Moving Average
The best trading indicators out there share some key similarities in the way they help traders to know what is happening in the market. Given its ability to reduce lag, eliminate noise, and respond quickly to market changes, HMA is one of the favorite indicators for many traders. The HMA is a comprehensive moving average indicator that makes market analysis a bit easier for traders, and it is also straightforward to interpret.
The Hull Moving Average can be interpreted in a similar way to traditional moving averages; the main difference is that responds more quickly because of the weight of recent price action. As with other moving averages, the HMA can be used to confirm a trend or spot a change in the trend.
HMAs with longer periods (for example, a 200-period HMA) can be used to identify the current overall trend. So, if the HMA is rising, the overall trend is up, and if the HMA is falling, the overall trend is down. On the other hand, HMAs with shorter periods can be used to identify entry points. When the overall trend is up and the HMA turns up, you may have a signal to go long. Likewise, when the overall trend is down and the HMA turns down, you may have a signal to sell short. There are infinite ways to look at trading ideas.
Some people also look at crossover signals (a shorter-term MA crossing a longer-term MA), as it’s done with other types of moving averages; however, HMA creator, Alan Hull, advises against using crossovers with HMAs. His reason is that the technique depends on looking at differences in lag between the two moving averages, but the lag has already been greatly reduced in Hull Moving Averages. Instead, Hull recommends looking at turning points to identify entries and exits, as outlined above.
The pros and cons of Hull Moving Average
There are several benefits and advantages of using the Hull Moving Average indicator. These are some of them:
- The indicator is like any other moving average indicator, so it is relatively easy to use.
- Unlike other types of moving average indicators, the HMA reduces the lag.
- The indicator is provided in most trading platforms, such as the MT4 and TradingView.
- The HMA can be used to analyze all types of assets, including ETFs and stocks.
- Should work in most markets, especially those that trend, for example, forex.
Apart from the benefits, there are also a few cons, and these are some of them:
- Some traders complain that reducing the lag makes it less effective as a moving average. It starts generating a lot of false signals.
- Calculating it is a relatively difficult process. However, the computer does it anyway.
- Most likely doesn’t work on scalping.
How to use Hull Moving Average in trading
From our discussion so far, you could see that there are several ways to use HMA in trading. these are some of them:
1. Identifying the trend
The HMA can be used to create a trend-following strategy. You can use the indicator to identify the trend, especially a longer-period HMA. If the HMA is rising, the prevailing trend is rising, indicating it may be better to enter long positions, and if the HMA is falling, the prevailing trend is also falling, indicating it may be better to enter short positions.
This also helps you to know the right time to buy or sell an asset. For this, it may be better to combine it with a trend line. In case of a rising asset’s price, your goal is to ensure that the HMA is below the price. A sell trigger emerges when the price moves below this moving average. See the chart below. Notice that the price kept rising when the HMA was below the price.
Source: Fidelity
2. Entry signals
You can use a shorter-period HMA to find good entry signals in the direction of the prevailing trend. For example, when the prevailing trend is rising, a long signal occurs when the HMA turns up. When the prevailing trend is falling, a short signal occurs when the HMA turns down.
Source: Fidelity
3. HMA crossover
You may also use two HMAs, a longer and a shorter one, and use the crossovers to identify trading opportunities, for example, a Death Cross. This method works for many traders, even though Alan Hull discourages that. Those who employ this strategy use a 50-day HMA and a 25-HMA. The goal is to identify where the two make a crossover. See the image below. The white thick line represents the 50-day HMA, while the thin yellow line represents the 25-day HMA. An upward cross can be a good signal to go long, while a downward cross could be a signal to short the market.
Source: TradingView
4. Combining HMA with another type of moving average indicator
Another approach would be to combine the HMA with another type of moving average of equal length. In this case, you can combine the 20-day HMA and a 20-day EMA, to identify potential crossovers. See the chart below. The red line is the 20-period HMA, while the blue line is the 20-period SMA. The HMA crossing above the SMA could be a signal to buy, while the HMA crossing below the SMA could be a signal to sell.
Hull Moving Average vs. other moving average indicators
There are many types of moving averages: the most basic being the simple moving average (SMA). Others include the exponential moving average (EMA), the linear-weighted moving average (LWMA), and the smoothed moving average (SMMA). (We have compiled a list of all moving averages further down.)
Of all the moving averages, the SMA lags price the most. The exponential and linear-weighted moving averages were developed to address this lag by placing more emphasis on more recent data, but the Hull Moving Average (HMA) does a better job than both, as it is an extremely fast and smooth moving average.
The HMA is very similar to other moving averages in the sense that it shows the average price in the series and can be interpreted the same way as other moving averages. However, it is designed to improve their main flaw in other moving averages — their inability to isolate market noise and avoid lag. In fact, the HMA almost eliminates lag altogether and manages to improve smoothing at the same time, and that is the main difference between it and the other moving averages.
Relevant articles about moving averages strategies and backtests
Moving averages have been around in the trading markets for a long time. Most likely, moving average strategies were the start of the systematic and automated trading strategies developed in the 1970s, for example by Ed Seykota. We believe it’s safe to assume moving averages were a much better trading indicator before the 1990s due to the rise of the personal computer. The most low-hanging fruit has been “arbed away”.
That said, our backtests clearly show that you can develop profitable trading strategies based on moving averages but mainly based on short-term mean-reversion and longer trend-following. Furthermore, there exist many different moving averages and you can use a moving average differently/creatively, or you can combine moving averages with other parameters.
Amibroker code for Hull moving average strategy
We have provided Amibroker code for the Hull moving average. We sell it together with a lot of other code for our free trading strategies:
Unfortunately, we have no python code (at the moment), and neither any documentation in pdf format. However, please register your e-mail and you get notifications on changes or updates (and you receive all our posts in your inbox).
FAQ Hull moving average
Let’s end the article with a few frequently asked questions about Hull moving average:
Is Hull moving average good?
It depends. We argue there is no good or bad moving average. Only a backtest can determine if a Hull moving average is good (or not). A certain moving average can work well on one type of asset, while it doesn’t work on another asset.
Which is better – EMA or HMA?
Again, see the answer above. Only a backtest can determine what is best.
What is the formula for Hull moving average?
The formula is as follows:
WMA1 = WMA(n/2) of price
WMA2 = WMA(n) of price
where “n” indicates the number of periods specified by the chartist.
Hull moving average – takeaways
Our takeaway from the backtests is that Hull moving average strategies work well if you buy on weakness (a close below the moving average) both long and short-term. Furthermore, as with most moving averages, a long-term trend following strategy also works well.
FAQ:
What is the Hull Moving Average (HMA) strategy?
The HMA strategy is a trading approach developed by Alan Hull in 2005. It utilizes a combination of weighted moving averages to prioritize recent price changes over older ones. The strategy aims to reduce lag, eliminate noise, and respond quickly to sustained market changes.
How does the Hull Moving Average differ from traditional moving averages?
Hull Moving Average strategies can be profitable for both mean-reversion and trend-following strategies, depending on the chosen time frame and trading conditions.The HMA differs by placing more emphasis on recent values, reducing lag significantly. It combines weighted moving averages to achieve a smoother line while maintaining responsiveness to market changes.
How is the Hull Moving Average calculated?
The HMA calculation involves two weighted moving averages (WMAs) of price and a third WMA to smoothen the raw HMA. The process includes calculating WMAs with specified periods, obtaining a raw HMA, and then applying another WMA with the square root of the specified number of periods.