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
date | close | volume | nvi |
---|---|---|---|
2005-11-01 | 81.59 | 5,653,100.00 | 1,000.00 |
2005-11-02 | 81.06 | 6,447,400.00 | 1,000.00 |
2005-11-03 | 82.87 | 7,690,900.00 | 1,000.00 |
2005-11-04 | 83.00 | 3,831,400.00 | 1,001.57 |
2005-11-07 | 83.61 | 4,455,100.00 | 1,001.57 |
2005-11-08 | 83.15 | 3,798,000.00 | 996.06 |
2005-11-09 | 82.84 | 3,936,200.00 | 996.06 |
2005-11-10 | 83.99 | 4,732,000.00 | 996.06 |
2005-11-11 | 84.55 | 4,841,300.00 | 996.06 |
2005-11-14 | 84.36 | 3,915,300.00 | 993.82 |
2005-11-15 | 85.53 | 6,830,800.00 | 993.82 |
2005-11-16 | 86.54 | 6,694,100.00 | 1,005.56 |
2005-11-17 | 86.89 | 5,293,600.00 | 1,009.62 |
2005-11-18 | 87.77 | 7,985,800.00 | 1,009.62 |
2005-11-21 | 87.29 | 4,807,900.00 | 1,004.10 |
Chart
Other Indicators
Previous indicator: Normalized Average True Range
Next indicator: On Balance Volume
Random indicator: Triple Exponential Moving Average
Copyright © 2016-2024 Tulip Charts LLC. All Rights Reserved.