Z-distance from VWAP with Kalman Smoother
Oct 9, 2023

The Z-distance from VWAP with Kalman Smoother indicator provides a standardized way to measure price deviations from the Volume Weighted Average Price (VWAP) using a smoothed Z-score to identify trend stages and potential reversals.
Usage
The tool categorizes market movement into five distinct stages based on the Z-score's position relative to predefined thresholds. Users can identify these stages through the color-coded step line:
- Extreme Up Trend: Occurs when the Z-score rises above the "ZScore Upper Limit," signaling potentially overextended bullish momentum.
- Normal Up Trend: Identified when the Z-score resides between the "Flip Upper" level and the "Upper Limit."
- Transition (Flip): A neutral or transitional phase where the Z-score oscillates within the specified flip range, suggesting a lack of strong direction.
- Normal Down Trend: Occurs when the Z-score is between the "Flip Lower" level and the "Lower Limit."
- Extreme Down Trend: Triggered when the Z-score falls below the "Lower Limit," signaling aggressive selling pressure.
Traders can use the relationship between the raw Z-score and the Kalman-smoothed line to filter out market noise. Additionally, crossovers of the "Zscore Flip" line are often used as early signals for shifts in market sentiment.
Details
This script is built on the principle that while asset prices vary significantly in nominal value, their relationship to the VWAP can be standardized using a Z-score. The Z-score measures how many standard deviations the current price is from the volume-weighted mean, allowing for a comparative analysis of trends across different instruments.
To improve signal quality, a Kalman Smoother is applied to the Z-score. Unlike traditional moving averages, the Kalman filter dynamically adjusts to minimize the "noise" of price fluctuations while maintaining responsiveness to significant shifts in the underlying trend.
Settings
- Source price: The price data used for calculations (default is Close).
- VWAP Period: The lookback window used for calculating the mean and standard deviation for the Z-score.
- Kalman Gain: Controls the responsiveness of the Kalman Smoother; higher values result in a faster-moving smoother line.
- Positive Zscore Group: Includes the "Top Upper" and "Upper" limits to define overbought or extreme bullish territories.
- Negative Zscore Group: Includes the "Lower" and "Bottom Lower" limits to define oversold or extreme bearish territories.
- Flip Group: Sets the "Zscore Flip" center point and the "Flip Range" width to define the transitional zone.
FAQ
How do I interpret the Kalman line?
The blue line represents the Kalman-smoothed version of the Z-score. When the raw Z-score (step line) is consistently staying above or below the Kalman line, it indicates a strong, trending move with minimal noise.
What does the "Flip" range represent?
The Flip range is a buffer zone around the zero-line (fair value). When the Z-score is inside this range, it indicates the market is in a state of transition or consolidation, and a clear trend has not yet been established.
How 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.