Positive Volume Index

Technical Analysis Indicator: pvi

Fork me on GitHub

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

dateclosevolumepvi
2005-11-0181.595,653,100.001,000.00
2005-11-0281.066,447,400.00993.50
2005-11-0382.877,690,900.001,015.69
2005-11-0483.003,831,400.001,015.69
2005-11-0783.614,455,100.001,023.15
2005-11-0883.153,798,000.001,023.15
2005-11-0982.843,936,200.001,019.34
2005-11-1083.994,732,000.001,033.49
2005-11-1184.554,841,300.001,040.38
2005-11-1484.363,915,300.001,040.38
2005-11-1585.536,830,800.001,054.81
2005-11-1686.546,694,100.001,054.81
2005-11-1786.895,293,600.001,054.81
2005-11-1887.777,985,800.001,065.49
2005-11-2187.294,807,900.001,065.49

Chart

 

Other Indicators

Previous indicator: Parabolic SAR

Next indicator: Qstick

Random indicator: Mass Index