Logo
OFFLINEPIXEL
/ pinescript-strategies / pine-script-positive-volume-index

$ Pinescript Positive Volume Index (PVI)

Master this unique volume-based indicator in TradingView's Pinescript, designed to track "uninformed money" activity, particularly on high-volume days, to confirm trends and anticipate price movements.

500+ Clients Helped
100% Satisfaction
Live Trading Ready
⚠️
Trading financial markets carries risk. All content (PineScript code, indicators, strategies) on this website is for educational purposes only. Past performance is not indicative of future results. By using any code or information from this site, you agree that you are solely responsible for your trading decisions. The author disclaims all liability for any losses incurred. To gain from experts experiences, You can always try our Invite Only Scripts
01

What is the Positive Volume Index (PVI)?

The Positive Volume Index (PVI) is a cumulative momentum indicator that focuses on periods of increasing volume. Developed by Paul Dysart and popularized by Norman Fosback, the underlying theory behind PVI is that "uninformed money" or the general public tends to be most active and influence price changes on high-volume days, reacting to news or trends. Therefore, changes in price action on high-volume days are considered significant.

The PVI essentially tracks a cumulative sum that is adjusted only when volume increases from the previous day. If volume increases, the PVI is adjusted by the percentage change in price. If volume decreases or stays the same, the PVI remains unchanged. A rising PVI suggests that public participation (high volume) is pushing the price higher, often confirming an uptrend. A falling PVI suggests public distribution. PVI is primarily used to:

  • Identify divergences: When price and PVI move in opposite directions, it can signal an impending trend reversal, particularly from the perspective of public interest.
  • Confirm price trends: PVI's trend confirms the underlying strength of a price trend, especially on high-volume days.
  • Gauge long-term sentiment: It's often used as a long-term indicator for the overall market or individual stocks.
02

Components and Calculation

The calculation of the Positive Volume Index is cumulative and depends on the relationship between current and previous volume:

  1. Initialize PVI: The starting value of PVI is usually set to 1000 (or some other arbitrary base value) to provide a convenient reference point.
  2. Conditional Update: For each period:
    • If Current Volume > Previous Volume: `PVI = Previous PVI + (Previous PVI * ((Close - Previous Close) / Previous Close))` Essentially, `PVI = Previous PVI * (1 + Price Percentage Change)` * Handle `Previous Close == 0` to avoid division by zero.
    • If Current Volume <= Previous Volume: `PVI = Previous PVI` (PVI remains unchanged)
03

Basic Positive Volume Index (PVI) Implementation in Pinescript

pine-script@terminal
//@version=5
indicator("My Positive Volume Index (PVI)", overlay=false) // overlay=false to plot in a separate pane

// Input for PVI starting value (arbitrary, but common to start at 1000)
pviStartValue = input.float(1000, title="PVI Start Value")

// Calculate PVI using the built-in function
// ta.pvi() uses 'close' for price comparison and 'volume' for volume comparison
pviValue = ta.pvi(pviStartValue, close, volume)

// Plot the PVI line
plot(pviValue, title="PVI", color=color.blue, linewidth=2)

// Optional: Add a Moving Average of PVI (often a long-term EMA) as a signal line
// A common length for the PVI MA is 255 (representing roughly a year of trading days)
pviMALength = input.int(255, title="PVI MA Length", minval=1)
pviMA = ta.ema(pviValue, pviMALength)

// Plot the PVI Moving Average
plot(pviMA, title="PVI MA", color=color.orange, linewidth=1)
$ ✓ Compiled successfully
04

Public Participation

Public Participation

PVI focuses on high-volume days, theorizing that these are driven by the broader, often less informed, public responding to market moves.

05

Practical PVI Trading Strategies

06

1. PVI and Moving Average Crossovers (Trend Confirmation)

pine-script@terminal
//@version=5
strategy("PVI Crossover Strategy", overlay=true)

pviStartValue = input.float(1000, title="PVI Start Value")
pviMALength = input.int(255, title="PVI MA Length", minval=1) // Long-term MA

pviValue = ta.pvi(pviStartValue, close, volume)
pviMA = ta.ema(pviValue, pviMALength)

plot(pviValue, "PVI", color.blue, display=display.pane_only)
plot(pviMA, "PVI MA", color.orange, display=display.pane_only)

// Long entry: PVI crosses above its MA
longCondition = ta.crossover(pviValue, pviMA)

// Short entry: PVI crosses below its MA
shortCondition = ta.crossunder(pviValue, pviMA)

if (longCondition)
    strategy.entry("Long PVI", strategy.long)

if (shortCondition)
    strategy.entry("Short PVI", strategy.short)

// Basic exit: opposite signal
strategy.close("Long PVI", when=shortCondition)
strategy.close("Short PVI", when=longCondition)
$ ✓ Compiled successfully
07

2. PVI Divergence (Key Reversal Signal)

pine-script@terminal
//@version=5
strategy("PVI Divergence Strategy", overlay=true)

pviStartValue = input.float(1000, title="PVI Start Value")
pviValue = ta.pvi(pviStartValue, close, volume)
pviMALength = input.int(255, title="PVI MA Length", minval=1)
pviMA = ta.ema(pviValue, pviMALength)

plot(pviValue, "PVI", color.blue, display=display.pane_only)
plot(pviMA, "PVI MA", color.orange, 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 PVI.

// Bullish Divergence: Price lower low, PVI higher low
bullishDiv = close < close[1] and close[1] < close[2] and pviValue > pviValue[1] and pviValue[1] > pviValue[2]

// Bearish Divergence: Price higher high, PVI lower high
bearishDiv = close > close[1] and close[1] > close[2] and pviValue < pviValue[1] and pviValue[1] < pviValue[2]

// Plot shapes on the chart to indicate divergence
plotshape(bullishDiv, title="Bullish PVI Divergence", location=location.belowbar, color=color.new(color.green, 0), style=shape.triangleup, size=size.small)
plotshape(bearishDiv, title="Bearish PVI Divergence", location=location.abovebar, color=color.new(color.red, 0), 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)
$ ✓ Compiled successfully
08

3. PVI as a Long-Term Trend Filter (Opposite of NVI)

pine-script@terminal
//@version=5
strategy("PVI Trend Filter Strategy", overlay=true)

pviStartValue = input.float(1000, title="PVI Start Value")
pviMALength = input.int(255, title="PVI MA Length", minval=1) // Long-term MA filter

pviValue = ta.pvi(pviStartValue, close, volume)
pviMA = ta.ema(pviValue, pviMALength)

plot(pviValue, "PVI", color.blue, display=display.pane_only)
plot(pviMA, "PVI MA", color.orange, display=display.pane_only)

// Define PVI trend direction
isPviUptrend = pviValue > pviMA
isPviDowntrend = pviValue < pviMA

// Example: Combine with a simple price EMA crossover strategy
fastPriceMALength = input.int(10, title="Fast Price MA Length", minval=1)
slowPriceMALength = input.int(20, title="Slow Price MA Length", minval=1)

fastPriceMA = ta.ema(close, fastPriceMALength)
slowPriceMA = ta.ema(close, slowPriceMALength)

longEntrySignal = ta.crossover(fastPriceMA, slowPriceMA)
shortEntrySignal = ta.crossunder(fastPriceMA, slowPriceMA)

// Only take long entries if PVI confirms a bullish trend
if (longEntrySignal and isPviUptrend)
    strategy.entry("Filtered Long", strategy.long)

// Only take short entries if PVI confirms a bearish trend
if (shortEntrySignal and isPviDowntrend)
    strategy.entry("Filtered Short", strategy.short)

// Exit on opposite price MA crossover, regardless of PVI filter for simplicity
strategy.close("Filtered Long", when=ta.crossunder(fastPriceMA, slowPriceMA))
strategy.close("Filtered Short", when=ta.crossover(fastPriceMA, slowPriceMA))

// Optional: Color background based on PVI trend
bgcolor(isPviUptrend ? color.new(color.lime, 95) : na, title="PVI Bullish Bias")
bgcolor(isPviDowntrend ? color.new(color.maroon, 95) : na, title="PVI Bearish Bias")
$ ✓ Compiled successfully
09

Optimizing Positive Volume Index (PVI) Performance

To get the most from the Positive Volume Index in Pinescript:

  • Smoothing is Crucial: PVI can be quite volatile, especially on lower timeframes. Applying a long-term moving average (e.g., 255-period EMA for daily charts) is essential to smooth out noise and identify its underlying trend, which is often considered more reliable.
  • Focus on Divergence: PVI's most powerful signals often come from divergences with price. These can provide early warnings of trend reversals as general market participation either confirms or contradicts the price action.
  • Timeframe Consideration: PVI, like NVI, is generally more suited for longer-term analysis (daily, weekly charts) due to its theory focusing on the activity of the broader market responding to trends. It might be less effective or generate more noise on very short intraday timeframes.
  • Combine with Price Action: Always confirm PVI signals with price action. A PVI signal is more reliable if supported by clear candlestick patterns, breaks of support/resistance, or other price-based confirmations.
  • Context is Key: Interpret PVI in the context of the overall market or asset. Its absolute value (e.g., starting at 1000) is not important; what matters is its trend relative to its moving average, and its divergence from price.
  • Use with NVI: Consider using PVI in conjunction with the Negative Volume Index (NVI) for a more complete picture of market conviction, distinguishing between "smart money" (NVI) and "uninformed money" (PVI) activity.
10

Uninformed Money Insights

Uninformed Money Insights

PVI helps you analyze how the broader market (often reacting to established trends or news) is influencing price, giving insight into public sentiment.

11

Common PVI Pitfalls

  • Lag: As a cumulative indicator smoothed by a moving average, PVI inherently lags price action. Its signals are often for confirmation or long-term trend shifts rather than immediate entries.
  • False Signals: Like any indicator, it can generate false signals, especially in markets with erratic volume patterns or during periods of very low liquidity where volume changes might not truly reflect public sentiment.
  • Absolute Value Meaningless: The raw PVI value (e.g., starting at 1000) has no intrinsic meaning other than its relation to its past values and its moving average.
  • Limited on Low Volume Days: By design, PVI ignores price action on low-volume days. This means it misses significant information, and should always be used alongside other indicators (like NVI) that capture low-volume moves.
  • Not a Standalone Indicator: PVI provides crucial insights but should never be used in isolation. It works best as a confirming or filtering indicator within a broader trading strategy.
12

Conclusion

Conclusion

The Positive Volume Index (PVI) is a distinct and insightful technical indicator available in Pinescript for TradingView. By specifically focusing on price movements on high-volume days, it attempts to track the activity of the broader market participation ("uninformed money") and provide a unique perspective on underlying market sentiment. While its greatest strengths lie in confirming long-term trends and identifying powerful divergences with price (signaling potential trend reversals), it is most effective when smoothed with a moving average and integrated strategically with price action and other technical analysis tools. By understanding its calculation and thoughtfully utilizing its signals, you can leverage PVI to enhance your Pinescript strategies and gain a clearer understanding of market conviction, particularly from the perspective of widespread public activity.

Enhance Your Trading

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