What is the Volume Price Trend (VPT)?
The Volume Price Trend (VPT), sometimes referred to as Price-Volume Trend (PVT), is a momentum indicator that essentially measures the money flow into or out of an asset. It is a cumulative indicator that adds or subtracts a portion of daily volume to a running total, based on the percentage change in the security's price. The core idea behind VPT is similar to On-Balance Volume (OBV) but with a nuanced difference: while OBV adds/subtracts *all* volume based on a simple up/down close, VPT adjusts the volume added/subtracted based on the magnitude of the price change.
A rising VPT indicates that trading volume is higher on days when the price increases, suggesting strong buying pressure and accumulation. A falling VPT indicates higher volume on days when the price decreases, suggesting strong selling pressure and distribution. VPT is primarily used to:
- Confirm price trends: A rising VPT confirms an uptrend, and a falling VPT confirms a downtrend.
- Identify divergences: When price and VPT move in opposite directions, it can signal an impending trend reversal.
- Measure money flow: Provides insight into the underlying buying and selling interest proportional to price movement.
In Pine Script, VPT offers a valuable perspective on the health of a trend by weighing volume by price movement, making it a key tool for pine script strategies focused on volume analysis.
Components and Calculation
The calculation of the Volume Price Trend is cumulative:
- Daily Price Change Ratio: Calculate the percentage change of the current closing price from the previous closing price.
`Price Change Ratio = (Current Close - Previous Close) / Previous Close`
* Handle `Previous Close == 0` to avoid division by zero. - Volume Contribution: Multiply the `Price Change Ratio` by the current `Volume`.
`Volume Contribution = Price Change Ratio * Current Volume` - Volume Price Trend (VPT): This is a running, cumulative total of the `Volume Contribution`.
`VPT = Previous VPT + Current Volume Contribution`
The initial value of VPT is typically zero or the first bar's volume contribution.
Basic Volume Price Trend (VPT) Implementation in Pine Script
Pine Script v5 provides a convenient built-in function `ta.vpt()` for calculating the Volume Price Trend.
//@version=5
indicator("My Volume Price Trend (VPT)", overlay=false) // overlay=false to plot in a separate pane
// Calculate VPT using the built-in function
// ta.vpt() implicitly uses 'close' for price comparison and 'volume' for calculation
vptValue = ta.vpt(close, volume)
// Plot the VPT line
plot(vptValue, title="VPT", color=color.blue, linewidth=2)
// Optional: Add a Moving Average of VPT to act as a signal line
// Common lengths for VPT MA are 10, 20, or 30
vptMALength = input.int(20, title="VPT MA Length", minval=1)
vptMA = ta.sma(vptValue, vptMALength)
// Plot the VPT Moving Average (signal line)
plot(vptMA, title="VPT MA", color=color.orange, linewidth=1)
// Plot the Zero Line as a key reference point
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted)
Practical Volume Price Trend (VPT) Trading Strategies
1. Divergence (Key Strategy)
Divergence between price and VPT is one of the most powerful signals, suggesting a weakening trend and potential reversal, as the money flow is not confirming the price action's strength.
- Bullish Divergence: Price makes a lower low, but VPT makes a higher low (or fails to make a significantly lower low). This indicates that despite falling prices, the volume associated with price increases is overcoming volume associated with price decreases, hinting at a potential upward reversal.
- Bearish Divergence: Price makes a higher high, but VPT makes a lower high (or fails to make a significantly higher high). This indicates that despite rising prices, the volume associated with price decreases is overcoming volume associated with price increases, hinting at a potential downward reversal.
//@version=5
strategy("VPT Divergence Strategy", overlay=true)
vptValue = ta.vpt(close, volume)
// Plot VPT in a separate pane
plot(vptValue, "VPT", color=color.blue, display=display.pane_only)
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted, display=display.pane_only)
// Simple divergence detection (conceptual, robust detection requires advanced pivot logic)
// This example looks for recent higher/lower swings in price and VPT.
// Bullish Divergence: Price lower low, VPT higher low
bullishDiv = close < close[1] and close[1] < close[2] and vptValue > vptValue[1] and vptValue[1] > vptValue[2]
// Bearish Divergence: Price higher high, VPT lower high
bearishDiv = close > close[1] and close[1] > close[2] and vptValue < vptValue[1] and vptValue[1] < vptValue[2]
// Plot shapes on the chart to indicate divergence
plotshape(bullishDiv, title="Bullish VPT Divergence", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(bearishDiv, title="Bearish VPT Divergence", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
if (bullishDiv)
strategy.entry("Long Divergence", strategy.long)
if (bearishDiv)
strategy.entry("Short Divergence", strategy.short)
// Basic exit after a few bars or on opposite signal
strategy.exit("Long Divergence Exit", from_entry="Long Divergence", profit=close*0.02, loss=close*0.01)
strategy.exit("Short Divergence Exit", from_entry="Short Divergence", profit=close*0.02, loss=close*0.01)
2. Trend Confirmation and Strength
VPT can confirm the strength and direction of a price trend. Ideally, price and VPT should move in the same direction, indicating healthy money flow supporting the trend.
- Uptrend Confirmation: Price is making higher highs and higher lows, and VPT is also rising (making higher highs and higher lows). This confirms strong buying pressure proportional to price gains.
- Downtrend Confirmation: Price is making lower highs and lower lows, and VPT is also falling (making lower highs and lower lows). This confirms strong selling pressure proportional to price declines.
- Lack of Confirmation: If price is moving up but VPT is flat or falling, it suggests the uptrend lacks proportional money flow and might be vulnerable.
//@version=5
strategy("VPT Trend Confirmation", overlay=true)
vptValue = ta.vpt(close, volume)
vptMALength = input.int(20, "VPT MA Length", minval=1)
vptMA = ta.sma(vptValue, vptMALength) // Moving Average of VPT
plot(vptValue, "VPT", color=color.blue, display=display.pane_only)
plot(vptMA, "VPT MA", color=color.orange, display=display.pane_only)
// Price trend filter (e.g., using a long-term EMA)
priceMALength = input.int(50, "Price MA Length", minval=1)
priceMA = ta.ema(close, priceMALength)
// Conditions for trend confirmation based on VPT and Price
// Long: Price above MA AND VPT above its MA (or rising)
longConfirm = close > priceMA and vptValue > vptMA and vptValue > vptValue[1]
// Short: Price below MA AND VPT below its MA (or falling)
shortConfirm = close < priceMA and vptValue < vptMA and vptValue < vptValue[1]
if (longConfirm)
strategy.entry("Long Confirm", strategy.long)
if (shortConfirm)
strategy.entry("Short Confirm", strategy.short)
// Basic exit: Price crosses back over price MA OR VPT crosses its MA
strategy.close("Long Confirm", when=close < priceMA or vptValue < vptMA)
strategy.close("Short Confirm", when=close > priceMA or vptValue > vptMA)
3. Zero-Line Crossovers (Bias Shift)
While often used for confirmation, a decisive crossover of the zero line by VPT can indicate a shift in the overall money flow bias, sometimes preceding a price trend change.
- Bullish Crossover: VPT crosses above the zero line. This indicates a shift to net positive money flow, suggesting accumulation and potential bullish bias.
- Bearish Crossover: VPT crosses below the zero line. This indicates a shift to net negative money flow, suggesting distribution and potential bearish bias.
//@version=5
strategy("VPT Zero Line Crossover Strategy", overlay=true)
vptValue = ta.vpt(close, volume)
plot(vptValue, "VPT", color=color.blue, display=display.pane_only)
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted, display=display.pane_only)
// Long entry: VPT crosses above zero
longCondition = ta.crossover(vptValue, 0)
// Short entry: VPT crosses below zero
shortCondition = ta.crossunder(vptValue, 0)
if (longCondition)
strategy.entry("Long VPT Cross", strategy.long)
if (shortCondition)
strategy.entry("Short VPT Cross", strategy.short)
// Basic exit: opposite signal
strategy.close("Long VPT Cross", when=shortCondition)
strategy.close("Short VPT Cross", when=longCondition)
Optimizing Volume Price Trend (VPT) Performance
To get the most from the Volume Price Trend in Pine Script:
- Prioritize Divergence: Like OBV and other volume-based indicators, VPT's most powerful and actionable signals often come from divergences with price. These can provide early warnings of trend reversals.
- Smooth with Moving Averages: Applying a moving average to the VPT line (as a signal line) can help smooth out noise and make crossovers more reliable for trend confirmation or signal generation. Common lengths for a VPT MA are 10, 20, or 30.
- Combine with Price Action: Always confirm VPT signals with price action. A strong VPT reading is more significant if accompanied by a strong breakout or a clear reversal candlestick pattern.
- Trend Context: Use VPT in the context of the larger trend. In an uptrend, look for positive VPT and bullish divergences for long entries. In a downtrend, look for negative VPT and bearish divergences for short entries.
- Volume Data Quality: VPT relies heavily on accurate and reliable volume data. Ensure the asset you are analyzing has consistent volume reporting.
- Compare with OBV: Understand the subtle difference between VPT and OBV. VPT's weighting by price change might make it more sensitive to strong price moves, while OBV treats all price changes equally. Experiment to see which works better for your asset/strategy.
Common Volume Price Trend (VPT) Pitfalls
- Lag: As a cumulative indicator, VPT can exhibit lag, especially during sharp, fast-moving reversals. Divergence helps to address this to some extent.
- False Signals: Like any indicator, it can generate false signals, particularly in choppy or low-volume markets where price fluctuates without a clear trend.
- Scalability Issues: The absolute value of VPT varies widely between assets and can be very large. Its absolute level doesn't matter; what matters is its trend, slope, and divergence from price.
- Dependency on Price Change: If the previous closing price is zero (e.g., for very low-priced assets or certain data issues), it can lead to division by zero in manual calculations. The `ta.vpt()` built-in handles this robustly.
- Volume Data Quality: The accuracy of VPT is highly dependent on reliable and consistent volume data. Issues with volume data (e.g., OTC markets, highly illiquid assets) can impact its effectiveness.
- Not a Standalone Indicator: VPT provides crucial insights but should never be used in isolation. It works best as a confirming indicator within a broader trading strategy.
Conclusion
The Volume Price Trend (VPT) is an insightful and effective momentum indicator available in Pine Script for TradingView. By uniquely combining price changes with volume, it provides traders with a deeper understanding of the underlying money flow and conviction behind price movements. While its greatest strength lies in identifying powerful divergences with price (signaling potential trend reversals), it also excels at confirming existing trends and validating shifts in market sentiment. By understanding its calculation, thoughtfully utilizing its signals, and integrating it strategically with price action and other technical analysis tools, you can leverage VPT to enhance your pine script strategies and gain a clearer understanding of smart money activity.