Volume Oscillator

Technical Analysis Indicator: vosc

Fork me on GitHub

Function Prototype

/* Volume Oscillator */
/* Type: indicator */
/* Input arrays: 1    Options: 2    Output arrays: 1 */
/* Inputs: volume */
/* Options: short period, long period */
/* Outputs: vosc */
int ti_vosc_start(TI_REAL const *options);
int ti_vosc(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.

The Volume Oscillator displays the difference between two Simple Moving Average of a security's volume.

It takes two parameters, a short period n and a long period m.

It is calculated for each bar as:

$$fastma_{t} = \frac{1}{n} \sum_{i=0}^{n-1} volume_{t-i}$$
$$slowma_{t} = \frac{1}{m} \sum_{i=0}^{m-1} volume_{t-i}$$
$$vosc_{t} = 100 \cdot \frac{fastma_{t} -slowma_{t}}{slowma_{t}} $$

The Volume Oscillator cannot be calculated for the first m-1 bars.

See Also

References

Example Usage

Calling From C

/* Example usage of Volume Oscillator */
/* Assuming that '', and 'volume' are pre-loaded arrays of size 'in_size'. */
TI_REAL *inputs[] = {volume};
TI_REAL options[] = {2, 5}; /* short period, long period */
TI_REAL *outputs[1]; /* vosc */

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

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

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

Calling From Lua (with Tulip Chart bindings)

-- Example usage of Volume Oscillator
vosc = ti.vosc(volume, 2, 5)

Example Calculation

short period = 2, long period = 5

datevolumevosc
2005-11-015,653,100.00
2005-11-026,447,400.00
2005-11-037,690,900.00
2005-11-043,831,400.00
2005-11-074,455,100.00-26.22
2005-11-083,798,000.00-21.32
2005-11-093,936,200.00-18.46
2005-11-104,732,000.004.42
2005-11-114,841,300.009.97
2005-11-143,915,300.003.15
2005-11-156,830,800.0010.76
2005-11-166,694,100.0025.17
2005-11-175,293,600.008.68
2005-11-187,985,800.008.07
2005-11-214,807,900.001.18

Chart

 

Other Indicators

Previous indicator: Annualized Historical Volatility

Next indicator: Volume Weighted Moving Average

Random indicator: Vector Arctangent