Loading...
Email verification issues ongoing. Check your SPAM folder and kindly mark our emails as not SPAM. Thanks for your patience.

Backtesting an Anchored VWAP Strategy

Anchored VWAP can be a useful tool when trying to determine the "fair price" of an instrument after a large move. For example, anchoring a VWAP indicator to a recent low can give the trader an idea when price has pulled back enough to begin establishing a position.

Anchored VWAP Chart

The example above shows our VWAP tool for NinjaTrader anchored to a recent low on an hourly ES (SPY futures contract) chart. A bullish trader can wait until price connects with VWAP before entering a trade and help mitigate the risk of a pullback.

Market Moving Events and Anchored VWAP

When it comes to analyzing market trends and making informed trading decisions, the Volume Weighted Average Price (VWAP) indicator is a valuable tool for traders. One interesting strategy is to anchor the VWAP indicator after significant market-moving events, such as the release of key economic data like the Consumer Price Index (CPI) or Federal Reserve announcements.

Back Testing an Anchored VWAP Strategy After Market Moving Events

Given the recent market volatility surrounding CPI data and Federal Reserve announcements, using the VWAP indicator can provide traders with a quantitative measure of the average price at which a security has traded throughout the day.

The concept behind this back test is to apply an anchored VWAP to the candle corresponding to the time of the CPI release (8:30 AM EST) and observe how the market reacts to the information. If the closing price at the end of the day is above the VWAP by market close (4 PM), it is considered bullish, indicating a potential long position for the next trading day. Conversely, if the closing price is below the VWAP, it may signal a bearish trend.

We will use NinjaTrader's powerful back-testing features to test this strategy. The first step is to create a list of all CPI releases since 2023.

CPI Release Dates

From there, we dynamically create an anchored VWAP for all CPI dates that exist on the chart.

Anchored VWAP Code

The implementation of the strategy happens in OnBarUpdate(). The first block of code finds and paints the background of the chart green or red if the end-of-day price ends above or below VWAP, respectively. The second block of code enters long or short depending on yesterday's close at 11 AM EST to avoid the opening volatility.

VWAP Code

Performance

Disclaimer: This strategy is intended to demonstrate the application of AVWAP in a simplistic, naive algorithm. This has not been tested in real-world trading and past performance is not indicative of future results. Use this guide for educational purposes only.

Let's take a look at some of the trades.

Trade Example

The first CPI release day closes above VWAP, which is considered bullish. However, the volatility continues until the next day's open. Luckily, we narrowly avoid this by entering at 11 AM. A good example of why trading the open contains significant risk.

Losing Trade Example

Next, let's look at a losing trade. On this day, we open a long position; however, we get stopped out on a large candle, which was probably caused by a news event. A good reminder why a strategy built on a single variable is not a viable way to trade.

Strategy Example 1 Strategy Example 2 Strategy Example 3

The screenshots above show the settings and performance for the strategy.

  • Instrument: ES Futures
  • Period: 15 min
  • Time frame: Dec 2022 - Feb 2024
  • 25-point stop loss and take profit (100 ticks)
  • 11 trades
  • 0 slippage
  • 0.42 Sharpe ratio
  • 4.6K profit

Conclusion

Anchored VWAP can be a useful indicator in identifying entry points and understanding market reactions to significant events. For example, momentum traders can use it to enter after a pullback from a local swing high or low. While the strategy showed promise in certain scenarios, it's important to remember that it's a basic, untested approach in real-world trading and should be combined with a comprehensive trading strategy.

We've demonstrated the integration of the Scalp Radar AVWAP indicator with NinjaTrader for testing trading strategies, which is critical when developing new trading methodologies.

Download

Note, you will need a purchased copy of Scalp Radar AVWAP for this to work.


Related Tags:
3 minutes read
Share this post:
Top