Function Prototype
/* Positive Volume Index */
/* Type: indicator */
/* Input arrays: 2 Options: 0 Output arrays: 1 */
/* Inputs: close, volume */
/* Options: none */
/* Outputs: pvi */
int ti_pvi_start(TI_REAL const *options);
int ti_pvi(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.
Positive Volume Index is very similar to Negative Volume Index, but changes on volume-up days instead.
It is calculated for each bar as:
$$pvi_{t} = pvi_{t-1} +
\begin{cases}
pvi_{t-1} \frac{close_{t}-close_{t-1}}{close_{t-1}} & \text{if } \; volume_{t} \gt volume_{t-1} \\
0 & \text{else}
\end{cases}
$$
Positive Volume Index is initialized so that the first value is 1,000.
See Also
References
Example Usage
Calling From C
/* Example usage of Positive 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]; /* pvi */
/* Determine how large the output size is for our options. */
const int out_size = in_size - ti_pvi_start(options);
/* Allocate memory for output. */
outputs[0] = malloc(sizeof(TI_REAL) * out_size); assert(outputs[0] != 0); /* pvi */
/* Run the actual calculation. */
const int ret = ti_pvi(in_size, inputs, options, outputs);
assert(ret == TI_OKAY);
Calling From Lua (with Tulip Chart bindings)
-- Example usage of Positive Volume Index
pvi = ti.pvi(close, volume)
Example Calculation
date | close | volume | pvi |
---|---|---|---|
2005-11-01 | 81.59 | 5,653,100.00 | 1,000.00 |
2005-11-02 | 81.06 | 6,447,400.00 | 993.50 |
2005-11-03 | 82.87 | 7,690,900.00 | 1,015.69 |
2005-11-04 | 83.00 | 3,831,400.00 | 1,015.69 |
2005-11-07 | 83.61 | 4,455,100.00 | 1,023.15 |
2005-11-08 | 83.15 | 3,798,000.00 | 1,023.15 |
2005-11-09 | 82.84 | 3,936,200.00 | 1,019.34 |
2005-11-10 | 83.99 | 4,732,000.00 | 1,033.49 |
2005-11-11 | 84.55 | 4,841,300.00 | 1,040.38 |
2005-11-14 | 84.36 | 3,915,300.00 | 1,040.38 |
2005-11-15 | 85.53 | 6,830,800.00 | 1,054.81 |
2005-11-16 | 86.54 | 6,694,100.00 | 1,054.81 |
2005-11-17 | 86.89 | 5,293,600.00 | 1,054.81 |
2005-11-18 | 87.77 | 7,985,800.00 | 1,065.49 |
2005-11-21 | 87.29 | 4,807,900.00 | 1,065.49 |
Chart
Other Indicators
Previous indicator: Parabolic SAR
Next indicator: Qstick
Random indicator: Williams Accumulation/Distribution
Copyright © 2016-2024 Tulip Charts LLC. All Rights Reserved.