Introduction
The Anchored VWAP Indicator for ThinkOrSwim helps traders spot high-probability setups using volatility and trend alignment. By combining Average True Range (ATR) with moving averages, it filters stocks exhibiting compression near critical support levels. This tutorial focuses on two actionable scans: one for volatility spikes and another for consolidation patterns.
The first scan identifies stocks with ATR values exceeding their 50-day average, signaling unusual volatility. The second scan pinpoints assets compressing within 5% of their 50-day SMA while maintaining bullish moving average stack (8 EMA > 34 EMA > 50 SMA). These strategies help traders anticipate breakouts while managing risk through quantifiable volatility metrics.
Using real-world examples like Micron Technologies (MU) and NVIDIA (NVDA), you’ll learn to customize scans for intraday or swing trading. The tutorial includes step-by-step code implementation, parameter optimization, and live trading applications. Master these tools to streamline your market analysis and improve trade timing.
The Problem with Regular VWAP
If you use VWAP in ThinkOrSwim, you’ve probably noticed it resets every day at market open. That’s fine for some analysis, but what if you want to see how price has behaved since an earnings announcement at 2 PM? Or since a major reversal three days ago? Regular VWAP can’t help you there.
Anchored VWAP fixes this by letting you start the calculation from any date and time you choose. No more daily resets – just pure volume-weighted price action from the moment that matters to your trade.
When Anchored VWAP Actually Matters
This isn’t just another indicator to clutter your charts. Anchored VWAP works best in specific situations:
Day Trading Reversals: When you spot an intraday reversal, anchor VWAP to that exact time. Now you can see if the new direction has volume backing it or if it’s just noise.
Earnings Plays: Anchor to earnings announcement dates. Microsoft reports earnings on April 25th? Anchor your VWAP there and track how price respects that level in the following days.
Major Market Events: December 2018 lows, Fed announcements, breakouts from key levels – any time significant volume entered the market at a specific moment.
Building It From Scratch
Here’s exactly how to build Anchored VWAP in ThinkOrSwim’s ThinkScript editor. We’ll walk through each piece so you understand what’s happening.
Step 1: Start with Basic VWAP
VWAP is just the sum of (price × volume) divided by sum of volume. In ThinkScript:
plot anchoredVWAP = TotalSum(((high + low + close) / 3) * volume) / TotalSum(volume);
This gives you regular VWAP, but we need to add the anchoring logic.
Step 2: Add Your Anchor Inputs
Create two input variables so you can change the anchor point without editing code:
input anchorDate = 20190612; input anchorTime = 0930;
Date format is YYYYMMDD. Time is 24-hour Eastern (0930 = 9:30 AM, 1445 = 2:45 PM).
Step 3: Create Boolean Tests
Now we need to test whether each bar is after our anchor point:
def postAnchorDate = GetYYYYMMDD() >= anchorDate; def postAnchorTime = SecondsFromTime(anchorTime) >= 0;
The first line checks if the current bar’s date is on or after your anchor date. The second uses SecondsFromTime() – if it returns a positive number, you’re past the anchor time.
Step 4: Add Conditional Logic
Here’s where it gets interesting. We modify the VWAP calculation to only include bars that pass both tests:
plot anchoredVWAP = TotalSum(if postAnchorDate and postAnchorTime
then ((high + low + close) / 3) * volume
else 0) /
TotalSum(if postAnchorDate and postAnchorTime
then volume
else 0);
This ensures only volume and price from your anchor point forward affects the calculation.
Making It Look Professional
Add some styling so the line stands out on your charts:
anchoredVWAP.SetStyle(Curve.FIRM); anchoredVWAP.SetLineWeight(3); anchoredVWAP.AssignValueColor(Color.CYAN);
Cyan color makes it easy to spot. Line weight of 3 ensures visibility on busy charts.
Real Example: Microsoft Earnings
Let’s say you want to track Microsoft’s price action since their April 25, 2019 earnings. Set anchorDate to 20190425, and suddenly you can see exactly how price has behaved since that catalyst.
In the example from the tutorial, price kept hitting Anchored VWAP as resistance for weeks – bouncing off it multiple times before finally breaking through. Once it broke above, that level became support.
This kind of analysis is impossible with regular VWAP because it resets daily, losing the connection to that specific earnings event.
Common Setup Mistakes
Wrong Date Format: Use YYYYMMDD format. June 12, 2019 = 20190612, not 6/12/19 or 12/6/19.
Time Zone Confusion: Anchor time always uses Eastern timezone. If you’re in Pacific time and want to anchor to 11:30 AM local, that’s 1430 Eastern.
Line Not Showing: The line only appears from your anchor point forward. If you anchor to tomorrow’s date, you won’t see anything.
Anchoring to Low-Volume Times: Avoid anchoring to overnight hours or thin trading periods. The VWAP calculation works best with significant volume.
Advanced Applications
Multiple Anchors: Run several Anchored VWAP indicators with different colors and anchor points. One for earnings, one for the daily open, one for a reversal.
Session-Based Analysis: Anchor to different market session opens – 9:30 AM for NYSE open, 8:00 AM for pre-market action, 2:00 PM for European close.
Event-Driven Trading: Keep a calendar of earnings, Fed meetings, and economic data. Anchor VWAP to these events to track institutional flow.
How the Code Actually Works
The genius of this approach is in the conditional logic. Instead of calculating VWAP from market open every day, we’re calculating it from any moment we choose.
The TotalSum() function normally sums all historical data. But by wrapping the price and volume calculations in if-statements, we’re telling it to only sum data from our anchor point forward.
Before the anchor point: the if-statement returns 0, so those bars don’t affect the calculation.
After the anchor point: the if-statement returns the actual price and volume data.
This creates a clean break where the VWAP calculation truly begins only from your chosen moment.
Practical Trading Tips
Support and Resistance: When price is above Anchored VWAP, it often provides support. When below, it often acts as resistance. This works because VWAP represents the average price at which volume has traded.
Breakout Confirmation: A decisive break above or below Anchored VWAP, especially with volume, often signals the start of a new trend phase.
Re-anchoring Strategy: As new significant events occur, consider updating your anchor point. Don’t let old anchor points overstay their relevance.
Volume Context: Anchored VWAP is most meaningful when anchored to high-volume events. Low-volume anchor points produce less reliable support/resistance levels.
Anchored VWAP transforms a simple daily reset indicator into a powerful tool for tracking institutional flow from any moment you choose. Whether you’re day trading around intraday levels or swing trading from major events, this gives you the flexibility to analyze exactly what matters for your trade setup.
# Anchored VWAP for ThinkOrSwim
# Created by TOS Indicators
# Full tutorial: tosindicators.com/indicators/anchored-vwap
# Input variables for anchor date and time
input anchorDate = 20190612;
// ... 29 more lines ...Here are some resources that you may find useful: