Distance from Vwap
Apr 7, 2022

The Distance from Vwap indicator measures the percentage deviation of the current price from a higher timeframe Volume Weighted Average Price (VWAP) to help identify overextended market conditions and consolidation phases.
Usage
The indicator is displayed as a histogram representing the distance between price and the selected VWAP timeframe. It identifies three primary market states:
- Overextension (High Distance): When the histogram turns green (bullish extension) or red (bearish extension), it indicates that price has stretched beyond the recent highest distance threshold. This often suggests a potential for mean reversion or a weakening trend.
- Consolidation (Low Distance): When the histogram flashes orange, the price is exceptionally close to the VWAP relative to recent history. This typically indicates a period of consolidation, which often precedes a significant breakout or expansion move.
- Neutral: When the histogram is grey, the distance from VWAP is within its recent historical range.
Traders often use the high distance signals to look for reversals in conjunction with other technical levels, waiting for the first candle after a peak to confirm a potential shift in momentum.
Details
The script calculates the distance as a percentage: (Close - VWAP) / Close. To determine the "High" and "Low" thresholds, it uses a lookback period (defined by the Distance Threshold setting) to find the highest and lowest distance values within that window.
By utilizing request.security, the tool pulls VWAP data from a higher resolution (e.g., Weekly VWAP on an Hourly chart). This provides a more significant "anchor" for price, as higher timeframe VWAPs are generally more respected by institutional participants.
Settings
VWAP Settings
- VWAP Resolution: Sets the timeframe for the VWAP calculation (e.g., Daily, Weekly, Monthly).
- Distance Threshold: The lookback period used to determine the relative "high" and "low" distance values for the histogram coloring.
Plots
- Bull: Sets the color for the histogram when price is significantly stretched above or below the VWAP (user-configurable).
- Bear: Sets the color for the histogram when price is significantly stretched above or below the VWAP (user-configurable).
FAQ
How do I use the Distance from Vwap indicator?
You can use it to spot overextended prices that might revert to the mean or to identify low-volatility periods near the VWAP that may lead to expansion.
What is the best timeframe for the VWAP?
It depends on your trading style, but using a higher timeframe than your current chart is recommended. For example, a Weekly VWAP is often effective on the 1H chart, while a 4H VWAP may work well for the 1m or 5m charts.
Where can I access this tool?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.