Negative Volume Index

Technical Analysis Indicator: nvi

Fork me on GitHub

Function Prototype

/* Negative Volume Index */
/* Type: indicator */
/* Input arrays: 2    Options: 0    Output arrays: 1 */
/* Inputs: close, volume */
/* Options: none */
/* Outputs: nvi */
int ti_nvi_start(TI_REAL const *options);
int ti_nvi(int size,
      TI_REAL const *const *inputs,
      TI_REAL const *options,
      TI_REAL *const *outputs);

Description

This documentation is still a work in progress. It has omissions, and it probably has errors too. If you see any issues, or have any general feedback, please get in touch.

Negative Volume Index tries to show what smart investors are doing by staying flat on up-volume days and only changing on down-volume days.

It is calculated for each bar as:

$$nvi_{t} = nvi_{t-1} + \begin{cases} nvi_{t-1} \frac{close_{t}-close_{t-1}}{close_{t-1}} & \text{if } \; volume_{t} \lt volume_{t-1} \\ 0 & \text{else} \end{cases} $$

Negative Volume Index is initialized so that the first value is 1,000.

See Also

References

Example Usage

Calling From C

/* Example usage of Negative Volume Index */
/* Assuming that 'close' and 'volume' are pre-loaded arrays of size 'in_size'. */
TI_REAL *inputs[] = {close, volume};
TI_REAL options[] = {}; /* No options */
TI_REAL *outputs[1]; /* nvi */

/* Determine how large the output size is for our options. */
const int out_size = in_size - ti_nvi_start(options);

/* Allocate memory for output. */
outputs[0] = malloc(sizeof(TI_REAL) * out_size); assert(outputs[0] != 0); /* nvi */

/* Run the actual calculation. */
const int ret = ti_nvi(in_size, inputs, options, outputs);
assert(ret == TI_OKAY);

Calling From Lua (with Tulip Chart bindings)

-- Example usage of Negative Volume Index
nvi = ti.nvi(close, volume)

Example Calculation

dateclosevolumenvi
2005-11-0181.595,653,100.001,000.00
2005-11-0281.066,447,400.001,000.00
2005-11-0382.877,690,900.001,000.00
2005-11-0483.003,831,400.001,001.57
2005-11-0783.614,455,100.001,001.57
2005-11-0883.153,798,000.00996.06
2005-11-0982.843,936,200.00996.06
2005-11-1083.994,732,000.00996.06
2005-11-1184.554,841,300.00996.06
2005-11-1484.363,915,300.00993.82
2005-11-1585.536,830,800.00993.82
2005-11-1686.546,694,100.001,005.56
2005-11-1786.895,293,600.001,009.62
2005-11-1887.777,985,800.001,009.62
2005-11-2187.294,807,900.001,004.10

Chart

 

Other Indicators

Previous indicator: Normalized Average True Range

Next indicator: On Balance Volume

Random indicator: Rate of Change