Weighted Moving Average Trading Strategy: Backtest and Evaluation

Weighted moving average strategy backtest

Some simply call it weighted moving average, while others call it a linearly weighted moving average. They are referring to the same indicator, which is one of the most popular and widely used MA indicators on most trading platforms. But what is it? And do you know if a weighted moving average strategy works?

Yes, weighted moving average strategies do work. Our backtests show that weighted moving averages can be used profitably for both mean-reversion and trend-following strategies on stocks.

As the name implies, the weighted moving average puts more weight on recent data and less on past data. This is done by multiplying each period’s price by a weighting factor that decreases linearly you move from recent to old data. Given this unique calculation, the WMA will follow prices more closely than a corresponding simple moving average.

Weighted moving average strategy backtest and best settings

Before we go on to explain what a weighted 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 weighted moving average strategy work? Can you make money by using weighted moving average 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:

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

8.53

8.05

5.99

5.17

5

3.28

MDD

-23.82

-33.9

-42.66

-40.24

-49.38

-49.2

Strategy 2

Period

5

10

25

50

100

200

CAR

1.09

1.54

3.5

4.31

4.48

6.21

MDD

-75.45

-65.93

-39.08

-41.21

-44.53

-42.69

The results from the backtests are pretty revealing: in the short run, the stock market shows tendencies to mean-reversion. In the long run, it is better to use tr