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
date | volume | vosc |
---|---|---|
2005-11-01 | 5,653,100.00 | |
2005-11-02 | 6,447,400.00 | |
2005-11-03 | 7,690,900.00 | |
2005-11-04 | 3,831,400.00 | |
2005-11-07 | 4,455,100.00 | -26.22 |
2005-11-08 | 3,798,000.00 | -21.32 |
2005-11-09 | 3,936,200.00 | -18.46 |
2005-11-10 | 4,732,000.00 | 4.42 |
2005-11-11 | 4,841,300.00 | 9.97 |
2005-11-14 | 3,915,300.00 | 3.15 |
2005-11-15 | 6,830,800.00 | 10.76 |
2005-11-16 | 6,694,100.00 | 25.17 |
2005-11-17 | 5,293,600.00 | 8.68 |
2005-11-18 | 7,985,800.00 | 8.07 |
2005-11-21 | 4,807,900.00 | 1.18 |
Chart
Other Indicators
Previous indicator: Annualized Historical Volatility
Next indicator: Volume Weighted Moving Average
Random indicator: Vector Division
Copyright © 2016-2024 Tulip Charts LLC. All Rights Reserved.