VWAP Trading Strategy

VWAP Trading Strategy (Backtest)

Investors and analysts are always looking for ways to analyze the market, and one method of evaluating the current price of a stock to determine whether it is relatively overpriced or underpriced compared to the average trading price for the day is using the VWAP.

Abbreviated as VWAP, the volume-weighted average price is the average price of a stock weighted by the total trading volume. The VWAP is a trading benchmark that represents the average price an asset has traded at throughout the day when both volume and price are considered. It provides traders with pricing insight into both the trend and value of the asset.

Want to know more about VWAP, let’s dive in. Additionally, we make a VWAP trading strategy backtest at the end of the article.

VWAP Trading Strategy (Backtest)

A few months back we made a wide backtest of all the different types of moving averages – including the VWAP moving average:

Let’s repeat our main findings from that specific backtest we did on the VWAP strategy (4 different backtests on SPY – S&P 500):

  • Strategy 1: When the close of SPY crosses BELOW the N-day VWAP 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 VWAP 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 VWAP 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 VWAP 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


Strategy 2


What can we conclude from backtest 1 and 2?

Perhaps as expected, in the short run it shows that mean reversion strategies work, while in the long run, it’s better to use a trend-following approach.

When we use a short number of days in the 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.

In the second backtest, the best strategy is to use many days in the moving average. The longer, the better. The 200-day moving average returns 6.38%, which is pretty good.

The results from backtests 3 and 4 look like this (the results are not CAGR, but average gains per trade):

Strategy 3


Strategy 4


Again, the longer you are invested in stocks, the better returns you get. Inflation and earnings growth make sure of that.

However, be aware that we have tested just four strategies of the moving average and this might not be the optimal trading strategy. There might be better trading strategies out there. There are basically unlimited ways you can use a moving average and your imagination is probably the most restricting factor!

What is VWAP?

As the name suggests, the volume-weighted average price (VWAP) is the average price of a stock weighted by the total trading volume. VWAP is a commonly used benchmark derived from a ratio of the average share price for a stock compared to the total volume of shares traded over a particular time frame.

It is used to calculate the average price of a stock over a period of time and helps compare the current price of the stock to a benchmark, making it easier for investors to decide when to enter and exit the market.

In other words, it helps investors and analysts evaluate the current price of a stock and determine whether it is relatively overpriced or underpriced compared to the average trading price for the day. The VWAP can also assist investors in determining their approach toward a stock (active or passive) so as to make the right trade at the right time.

Institutional investors, who often trade in large orders, use VWAP as a benchmark to determine the quality of executions.

For example, say a fund manager wants to acquire 20 thousand shares of company X at a price below the average price for the day, he would keep an eye on the VWAP and try to beat it because that is what will be used to judge whether he succeeded in getting in at a good price. Their average purchase price would be compared to the VWAP at the time the position was accumulated.

VWAP Trading Strategy

VWAP example in the chart

Most trading platforms and charting packages come with built-in VWAP. Once you attach the indicator to a price chart, the platform calculates the values and overlays the indicator line on the price chart.

On TradingView, the indicator is displayed as 3 lines: an upper green line, a middle blue line, and a lower green line. It is the middle blue line that shows the VWAP. See the charts below:

VWAP trading strategy
VWAP example – Tradingview.

VWAP trading strategy example

Notice that the indicator coalesced into a single line that wraps around the price bars on the D1 chart (first chart), but on the 5-min chart (second chart), it spreads out to show the 3 lines for each day’s trading session. This is because the indicator is calculated for intraday trading and is anchored for a day’s trading session.

Note that the timeframe is set at a trader’s discretion, so you can set it at any timeframe, other than five minutes, but since VWAP only uses intraday data, the timeframe can only be an intraday timeframe, else you won’t see the indicator lines.

Understanding how the VWAP works

The VWAP works as a technical indicator that can be attached to the price chart, but is used only on intraday charts unless it is set to use another trading session (say weekly or monthly trading session), other than the daily trading session. It resets at the start of every new trading session. So, for a daily trading session, which is the usual configuration, it resets at the market open for the day and coalesces at the day’s market close.

As an intraday price measure, the VWAP can be used by intraday traders and investors to decide whether to adopt an active or passive approach to position entries. It’s a trading benchmark that represents the average price a security has traded at throughout the day, based on both volume and price. So, it can also be useful for making decisions on whether to enter or exit a given security.

Intraday traders consider VWAP important because it gives them some pricing insight into both the trend and value of a security. So, they use it to help them buy at relatively inexpensive prices and sell at comparatively higher prices.

How is VWAP calculated?

Although your trading platform automatically does the calculations and displays the indicator on the chart, it doesn’t hurt to have an idea of how the indicator is calculated to broaden your understanding of the indicator.

Typically, VWAP starts calculating the opening price for each day and keeps adjusting in real time right up until the close of the day’s trading session. So, the calculation uses intraday data only. This is the formula for calculating VWAP:

VWAP = (Cumulative typical price x Volume)/Cumulative Volume

The steps in calculating VWAP

Here are the steps:

Step 1: Calculating the Typical Price (TP)

The calculation starts with getting the Typical Price (TP) price of the first completed candle on the chart. This means that the calculation is dependent on the time frame of the chart being observed. So, on a five-minute chart, it would calculate the Typical Price of the first five-minute candle. This is the average of the high price, the low price, and the closing price of the candle. The formula is

TP = (H+L+C)/3

Let’s assume these data: H = 50.50, L = 45.00, and C = 48.50.

TP = (50.50+45.00+48.50) / 3 = 48.00

Step 2: Calculating the TPV

The next step in the calculation is to multiply TP by the volume (V) of shares that traded within the period being measured to find the Total Price Volume (TPV). Assuming the volume is 40,000, the TPV is calculated as follows:

TPV = 48.00 x 40,000 = 1,920,000

Step 3: Calculating the VWAP for the first candle

Therefore, using the VWAP formula above:

VWAP = TPV / V (since it is just the first data set)

= 1,920,000 / 40,000 = 48.00

As you can see, the VWAP for the first candle ends up being the Typical Price because the volume component cancels out in the first iteration of the calculation.

Further steps in the calculation

For the next candle and subsequent ones, the formula then calculates cumulative price and volume:

VWAP = [TPV (Candle 1) + TPV (Candle 2) + ….] / [V (Candle 1) + V (Candle 2) + …]

For our sample calculation, if we assume that the second candle closed with a typical price of 49.40, and a volume of 40,500, the TPV for the second candle would be 2,000,700. This would be added to the first candle’s TPV. Similarly, the cumulative volume is calculated by adding the volume for the second candle to the volume for the first candle, giving us a value of 80,500

The VWAP then is calculated by dividing the TPV sum by the cumulative volume. Thus, the VWAP after the second candle would be obtained as follows:

VWAP = [1,920,000 + 2,000,700] / 80,500 = 48.70

Note that this indicator is calculated for any intraday timeframe to show the VWAP for every data point in an intraday stock chart. The charting platform algorithms do the calculations automatically. You just have to attach the indicator on the chart and specify an intraday timeframe you want to see the indicator line.

What does VWAP tell you?

Since the VWAP combines price and volume in its calculation, analysts consider the indicator a better representative of the true average price of the stock than the moving average. Moreover, the calculation of the VWAP is independent of, and does not directly affect the stock’s closing price.

The VWAP indicator can tell you a lot about the price, depending on how you want to use it.

First, it gives you a context of the price trend and momentum regarding where the stock is trading — above or below — in relation to the VWAP line. If the stock is trading above the VWAP as the line rises, the stock is likely in an uptrend with bullish momentum. Conversely, if the stock is trading below the VWAP line as the line descends, the stock is likely in a downtrend with bearish momentum.

In addition to this, since institutional traders use the VWAP as a benchmark for execution activity, the VWAP price level is considered to be highly influential in intraday price action.

For instance, if Apple has a falling VWAP line but you want to take a long position, you may want to wait for the stock price to pierce the VWAP and reverse back up, showing that the short-term momentum is no long bearish before you make your trade.

The VWAP is, however, still considered a lagging indicator, as its calculation is based on historical data. But that doesn’t stop traders from using the indicator to establish support and resistance levels suitable for intraday trading. It provides a visual basis for supply and demand based on its relation to the stock price and the direction of the trend.

Moreover, the VWAP is a popular tool used by many traders, so it often presents the characteristics of a self-fulling prophecy.

For example, if a stock is trading higher but still below the VWAP line, traders may anticipate that it would rise to test the VWAP line, so they place buy orders, targeting the VWAP line. As more traders jump on board trying to get ahead of the others, the stock may naturally rise towards the VWAP.

Taking it a little further, bears that expect a rejection at the VWAP line may place their limit sell orders to short-sell the stock at the VWAP expecting profit takers and more sellers to come in and drag the price down. Whichever way you want to interpret it, the VWAP is most useful when combined with other indicators to confirm the longer-term trend.

What Institutional traders use VWAP for

While intraday retail traders see VWAP as a trend indicator for short-term price moves, money managers and institutional traders often use it as benchmark price value to gauge the quality of their order executions from their market makers or traders. If they are constantly getting filled above the VWAP, it may cause the manager to seek other market makers or traders to carry out the order fills.

Also, when institutions want to get into a position but the price at which they get in can make a market impact, they use VWAP to gauge the liquidity and market impact of their orders. Placing huge orders at once will cause the price to rise triggering a chasing element to the fills. Subsequently, there may be a potential steep drop once the orders are filled.

Pros and cons of VWAP

The use of VWAP has some pros and cons. The pros are as follows:

  • In algorithmic trading, VWAP ratios can be used to determine the best price at which to buy or sell, in line with the volume of the market.
  • When trading large numbers of shares, the VWAP can be used to ensure that prices aren’t being overinflated by the trading volume.

Despite the benefits, there are some cons as well. The cons of VWAP include:

  • Lagging: The main problem with VWAP is that it is a cumulative indicator, meaning it relies on a vast amount of data points that will only increase in quantity throughout the day. With such a large data set, the VWAP line lags, just like the moving average, which is why most traders and investors only use one-minute and five-minute timeframes.
  • Only for short-term trading: The indicator is not really suitable for long-term trading since it uses intraday timeframe data.

Amibroker code for all moving averages

We have a product that contains the Amibroker code (some in Tradestation) for all the strategies that we have published for free. It also contains the logic of the strategy in plain English, and it’s thus very relevant for those traders backtesting in Python:

Final words about the VWAP trading strategy

While both retail and professional traders may use the VWAP to help them determine price trends, the indicator is typically most useful to short-term traders.


– How is VWAP calculated?

VWAP is calculated by taking the cumulative typical price (average of high, low, and close prices) multiplied by the volume, and then dividing this by the cumulative volume. This calculation is performed iteratively throughout the trading day, providing a dynamic indicator of the average price.

– Why do investors use VWAP?

Investors use VWAP to evaluate whether a stock is overpriced or underpriced compared to the average trading price for the day. It aids in decision-making for entering or exiting the market and assists institutional investors in assessing the quality of their executions.

– What timeframes are suitable for using VWAP?

VWAP is typically used on intraday charts, as it resets at the beginning of each trading session. While the timeframe can be set at the trader’s discretion, it must be an intraday timeframe since VWAP relies on intraday data.

Similar Posts