Negative Volume Index (NVI)
Summary
Negative Volume Index: a running cumulative index that changes only on days when volume falls versus the prior day, compounding that day's percentage price change. The premise is that quiet, low-volume days reflect the actions of well-informed "smart money", so NVI is read as a proxy for that cohort's positioning.
Chart
Chart metadata i
Outputs
outReal:line·zero·positive
Formula
NVI[startIdx] = 1000
For each subsequent bar i:
NVI[i] = NVI[i-1] + ( inVolume[i] < inVolume[i-1]
? ((inClose[i] - inClose[i-1]) / inClose[i-1]) * NVI[i-1]
: 0 )
The index carries forward unchanged on bars whose volume did not fall (and on the degenerate case of a zero previous close, which would otherwise divide by zero).
Notes
- The input is assumed positive. The previous close is the divisor. Near zero the divisor is small and the output very large; no error is returned. A series that reaches or crosses zero, such as an oscillator or a spread, has no meaningful result here.
- The index compounds, so it has no upper bound. If a run of large rises ever pushes it past the largest representable number, the last representable value is carried forward instead of returning infinity. Real price series stay far away from that.
Inputs
inClose— Close price of each barinVolume— Volume of each bar
Outputs
outReal— Cumulative negative volume index (seeded at 1000)
Properties
Numerical Stability: Path-Dependent
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ☐ Candlestick |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ✅ Input Must Be Positive i |
Example
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double close[252]; /* your data, oldest first */
double volume[252]; /* your data, oldest first */
double out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_NVI( 0, n - 1, close, volume, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d: [%.4f, ..., %.4f]\n", outNBElement, outBegIdx, out[0], out[outNBElement - 1] );use ta_lib::Core;
let close = vec![0.0; 252]; // your data, oldest first
let volume = vec![0.0; 252]; // your data, oldest first
let mut out = vec![0.0; 252];
let core = Core::new();
let range = core.nvi(0, close.len() - 1, &close, &volume, &mut out)?;
println!("{} values from bar {}: [{:.4}, ..., {:.4}]", range.count, range.beg_idx, out[0], out[range.count - 1]);import io.github.talib.Core;
import io.github.talib.OutRange;
import java.util.Locale;
double[] close = new double[252]; // your data, oldest first
double[] volume = new double[252]; // your data, oldest first
double[] out = new double[252];
Core core = Core.DEFAULT;
OutRange r = core.nvi(0, close.length - 1, close, volume, out);
System.out.printf(Locale.ROOT, "%d values from bar %d: [%.4f, ..., %.4f]%n", r.count(), r.begIdx(), out[0], out[r.count() - 1]);using System;
using TALib;
var close = new double[252]; // your data, oldest first
var volume = new double[252]; // your data, oldest first
var outReal = new double[252];
var core = Core.Default;
OutRange r = core.Nvi(0, close.Length - 1, close, volume, outReal);
Console.WriteLine(FormattableString.Invariant($"{r.Count} values from bar {r.BegIdx}: [{outReal[0]:F4}, ..., {outReal[r.Count - 1]:F4}]"));import { nvi } from 'ta-lib';
const close = new Float64Array(252); // your data, oldest first
const volume = new Float64Array(252); // your data, oldest first
const { begIdx, values } = nvi({ close, volume });
console.log(values.length + ' values from bar ' + begIdx + ': [' + values[0].toFixed(4) + ', ..., ' + values[values.length - 1].toFixed(4) + ']');import (
"fmt"
"log"
talib "ta-lib.github.io/go"
)
close := make([]float64, 252) // your data, oldest first
volume := make([]float64, 252) // your data, oldest first
out := make([]float64, 252)
core := talib.NewCore()
r, err := core.NVI(0, len(close)-1, close, volume, out)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d values from bar %d: [%.4f, ..., %.4f]\n", r.NBElement, r.BegIdx, out[0], out[r.NBElement-1])Implementation
Added in 0.8.1 (ta-lib-python 0.8.1).
TA-Lib Definition: nvi.c · nvi.yaml
| Native | File |
|---|---|
| C | ta_NVI.c |
| Rust | nvi.rs |
| Java | Core_NVI.java |
| C# | Core_NVI.cs |
| TypeScript | nvi.ts |
| Go | nvi.go |
Python: talib.NVI (ta-lib-python 0.8.1 or later), see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Negative Volume Index
References
- Norman G. Fosback, Stock Market Logic, The Institute for Econometric Research (ISBN 0917604482)