Master this insightful momentum indicator in TradingView's Pinescript that combines price changes and volume to confirm trends and anticipate price movements by tracking cumulative money flow.
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:
The calculation of the Volume Price Trend is cumulative:
//@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.gray, linestyle=hline.style_dotted)
Unlike OBV, VPT considers *how much* price moved. A small price change with high volume will impact VPT less than a large price change with the same volume, reflecting the efficiency of the move.
//@version=5
strategy("VPT Divergence Strategy", overlay=true)
vptValue = ta.vpt(close, volume)
// Plot VPT in a separate pane
plot(vptValue, "VPT", color.blue, display=display.pane_only)
hline(0, "Zero Line", 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)
//@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.blue, display=display.pane_only)
plot(vptMA, "VPT MA", 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)
//@version=5
strategy("VPT Zero Line Crossover Strategy", overlay=true)
vptValue = ta.vpt(close, volume)
plot(vptValue, "VPT", color.blue, display=display.pane_only)
hline(0, "Zero Line", 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)
To get the most from the Volume Price Trend in Pinescript:
VPT highlights whether money is flowing into or out of an asset, and critically, how much conviction (proportional to price change) that flow has.
The Volume Price Trend (VPT) is an insightful and effective momentum indicator available in Pinescript 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 Pinescript strategies and gain a clearer understanding of smart money activity.
Get a high-performance Pinescript analysis tool for actionable market insights, designed for traders on the move.
This strategy runs in live mode on TradingView, helping you identify potential opportunities.
Get Pinescript Strategy