Volume Weighted Average Price – Trading Strategy Backtest (Does it work?)
Last Updated on May 21, 2022 by Quantified Trading
Volume-weighted average price strategy backtest
Several indicators are used for technical analysis; some of these indicators combine different market data to tell a better story about what the market is doing. The volume-weighted average price (VWAP), which combines both volume and price data, is one such indicator. But what is it? Can we make profitable volume-weighted moving average strategies in the markets?
Yes, volume-weighted moving average strategies do work. Our backtests show that a volume-weighted moving average can be used profitably for both mean-reversion and trend-following strategies on stocks.
The volume-weighted average price (VWAP) is an indicator that traders use to determine the average price that a financial instrument has traded, based on volume and price. The volume-weighted average price is calculated by multiplying the sum of price and volume, then dividing the result by the total volume. VWAP is important because it provides traders with insight into the trend and its strength.
Table of contents:
Does a volume-weighted moving average strategy work? We backtest different strategies
Before we go on to explain what a volume-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 volume-weighted moving average strategy work? Can you make money by using volume-weighted 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 |
8.18 |
7.8 |
5.09 |
5.05 |
2.67 |
2.93 |
MDD |
-27.93 |
-33.22 |
-38.71 |
-40.27 |
-50.57 |
-49.2 |
Strategy 2
Period |
5 |
10 |
25 |
50 |
100 |
200 |
CAR |
1.42 |
1.81 |
4.43 |
4.48 |
6.86 |
6.38 |
MDD |
-62.58 |
-57.08 |
-41.1 |
-41.68 |
-45.99 |
-40.12 |
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 trend-following strategies.
Why do we reach that conclusion?
Because if we use a short moving average, the best strategy is to buy when stocks drop below the average and sell when it turns around and closes above the moving average (buy on weakness and sell on strength). This can clearly be seen in the first test above for the 5-day moving average. The 5-day moving average returns a CAGR of 8.18%, which is almost as good as buy and hold even though the time spent in the market is substantially lower.
When we buy on strength and sell on weakness, in the second test in the table above, the best strategy is to use many days in the average. The longer the average is, the better. The 200-day moving average returns 6.38%, which is pretty decent. However, the drawdowns are higher than compared to many other moving averages.
The results from backtests 3 and 4 looks like this (the results are not CAGR, but average gains per trade):
Strategy 3
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.3 |
0.45 |
1.01 |
2.27 |
3.85 |
8.66 |
10 |
0.12 |
0.55 |
1.16 |
2.34 |
4.55 |
8.78 |
25 |
0.19 |
0.57 |
1.1 |
2.06 |
4.16 |
9.08 |
50 |
0.25 |
0.59 |
1.04 |
1.86 |
5.45 |
11.17 |
100 |
0.83 |
1.06 |
1.95 |
3.22 |
5.58 |
10.24 |
200 |
0.2 |
0.49 |
1.03 |
2.82 |
4.46 |
7.21 |
Strategy 4
Period |
5 |
10 |
25 |
50 |
100 |
200 |
5 |
0.22 |
0.19 |
0.85 |
2.06 |
4.16 |
9.1 |
10 |
0.13 |
0.23 |
1.1 |
1.89 |
4.32 |
8.34 |
25 |
0.19 |
0.17 |
0.95 |
1.52 |
4.2 |
7.67 |
50 |
0.11 |
0.27 |
0.61 |
1.31 |
4.49 |
8.98 |
100 |
0.36 |
0.44 |
1.36 |
2.31 |
4.98 |
8.07 |
200 |
-0.11 |
-0.39 |
-0.04 |
2.03 |
3.86 |
7.13 |
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. The results for the 200-day moving average in strategy 3 is perhaps the best of all the moving averages we have tested (below we have links to all of them).
However, be aware that we have tested just four strategies of the moving average. There are basically unlimited ways you can use a moving average and your imagination is probably the most restricting factor!
What is the volume-weighted average price (VWAP)?
Volume-weighted average price (VWAP) is a common technical analysis tool used to show the average share price of a stock relative to the volume of shares traded over a particular time frame. The information provided by the volume-weighted average price can help traders to determine the average price at which the stock is traded over a given period — that is, it shows whether the price is relatively overpriced or underpriced compared to the average trading price for the day.
This can help traders to know when to enter or exit the market. This is done by comparing the stock’s current price to the VWAP as the benchmark. Since the VWAP can be seen as a benchmark, it can determine institutional traders can use it to gauge the quality of their order executions. For example, if a portfolio manager wants to acquire thousands of shares and purchase the position below the average price for the day, the VWAP will usually be the price to beat. By comparing the average price of execution and the VWAP when the position was accumulated, the trader would know if he had been successful in getting the orders filled at a good price.
How to calculate the volume-weighted average price
The volume-weighted average price can be calculated for any timeframe, but it is usually calculated for the daily timeframe: thus, the calculation begins when the markets open and ends when they close for the day.
So, the calculation uses intra-day data. The price is multiplied by the number of shares traded and then divided by the total shares traded. The formula for the calculation is given as follows:
VWAP = (Typical price x volume)/cumulative volume
The calculation begins with finding the Typical Price (TP) price. The typical price can be gotten by calculating the average of the high price, the low price, and the closing price of the stock for that day.
The simple formula for the typical price is given as : [(H+L+C)/3]
So, if H = 10, L = 5 and C = 10, the stock’s average price would be:
Typical Price = (30+20+10) / 3 = 20.
Next, you need to multiply the typical price by the volume. If V = 20, then:
20 * 20 = 400
You can keep a running total of the volume as they aggregate through the day to give you the cumulative volume. Let’s assume the cumulative volume, in our example, is 60.
Therefore, using the VWAP formula above:
VWAP = 400 / 60 = 6.667
Why use the volume-weighted average price?
Since the VWAP reflects price levels weighted by volume, it shows the liquidity points on the chart. This information provided by the VWAP can help institutional traders with large orders to determine the liquid and illiquid price points that can guide their order placements.
VWAP can also be used to measure trading efficiency. After buying or selling a security, institutions or individuals can compare their price to VWAP values. A buy order executed below the VWAP value would be considered a good fill because the security was bought below average. Conversely, a sell order executed above the VWAP would be deemed a good fill because it was sold above average.
How to use the volume-weighted average price
Traders can calculate the volume-weighted average price every day to show the VWAP for every data point in the stock chart. The results of the VWAP are represented on the stock chart as a line. However, traders do not always need to calculate the VWAP; it is done automatically on the trading platform. The trader only needs to specify the desired number of periods in the VWAP calculation.
How can you use the volume-weighted average price?
Traders can use the VWAP to determine if the market is bearish or bullish. If the price falls below the VWAP, it is an indication that the market is bearish. Also, the market is bullish whenever the price rises above the VWAP. VWAP is very useful when trading large numbers of shares
The VWAP allows traders to buy a security at a low price, thereby making more profits when they sell. Generally, it helps traders know the right time to enter and exit the market to reduce slippage or incomplete filling of orders.
Drawbacks with the volume-weighted average price
The volume-weighted average price also comes with some limitations that traders should pay close attention to. For instance, while some institutional traders may prefer to buy when the security’s price is below the VWAP or sell when it is above, VWAP is not the only factor to consider. In strong uptrends, the price may continue to move higher for many days without dropping below the VWAP at all or only occasionally. Therefore, waiting for the price to fall below VWAP could mean a missed opportunity if prices rise quickly.
Another drawback of using the volume-weighted average price in trading is that the VWAP is a cumulative indicator. It relies on vast data points that will only increase in quantity throughout the day. The implication of using such a data set is that it can cause lags in the VWAP line similar to moving average lags, so most traders and investors only use one-minute and five-minute timeframes.
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.
For your convenience, we have covered all moving averages with both detailed descriptions and backtests. This is our list:
- Are moving averages good or bad?
- Exponential moving average (backtest strategy)
- Hull moving average (backtest strategy)
- Linear-weighted moving average (backtest strategy)
- Adaptive moving average (backtest strategy)
- Smoothed moving average (backtest strategy)
- Variable moving average (backtest strategy)
- Weighted moving average (backtest strategy)
- Zero lag exponential moving average (backtest strategy)
- Triple exponential moving average TEMA (backtest strategy)
- Variable Index Dynamic Average (backtest strategy)
- Triangular moving average (backtest strategy)
- Guppy multiple moving average (backtest strategy)
- McGinley Dynamic (backtest strategy)
- Geometric moving average GMA (backtest strategy)
- Fractal adaptive moving average FRAMA (backtest strategy)
- Fibonacci moving averages (backtest strategy)
- Double exponential moving average (backtest strategy)
- Moving average slope (backtest strategy)
We have also published relevant trading moving average strategies:
- The 200-day moving average strategy
- Trend-following system/strategy in gold (12-month moving average)
- Trend following strategies Treasuries
- Is Meb Faber’s momentum/trend-following strategy in gold, stocks, and bonds still working?
- Trend following strategies and systems explained (including strategies)
- Does trend following work? Why does it work?
- A simple trend-following system/strategy on the S&P 500 (By Meb Faber and Paul Tudor Jones)
- Conclusions about trend-following the S&P 500
- Why arithmetic and geometric averages differ in trading and investing
Volume-weighted moving average – takeaways
Our takeaway from the backtests is that volume-weighted average strategies work well if you buy on weakness (a close below the moving average) and sell on strength (a close above the moving average) when you use a short number of days. Opposite, it’s best to buy on strength (a close above the moving average) when you use a longer moving average.