Function Prototype
/* Volume Weighted Moving Average */
/* Type: overlay */
/* Input arrays: 2 Options: 1 Output arrays: 1 */
/* Inputs: close, volume */
/* Options: period */
/* Outputs: vwma */
int ti_vwma_start(TI_REAL const *options);
int ti_vwma(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 Weighted Moving Average is simalair to a Simple Moving Average, but it weights each bar by its volume.
It takes one parameter, the period n
.
It is calculated for each bar as follows:
$$vwma_{t} = \frac{\sum_{i=0}^{n-1} close_{t-i}volume_{t-i}}{\sum_{i=0}^{n-1} volume_{t-i}} $$
See Also
References
Example Usage
Calling From C
/* Example usage of Volume Weighted Moving Average */
/* Assuming that 'close' and 'volume' are pre-loaded arrays of size 'in_size'. */
TI_REAL *inputs[] = {close, volume};
TI_REAL options[] = {5}; /* period */
TI_REAL *outputs[1]; /* vwma */
/* Determine how large the output size is for our options. */
const int out_size = in_size - ti_vwma_start(options);
/* Allocate memory for output. */
outputs[0] = malloc(sizeof(TI_REAL) * out_size); assert(outputs[0] != 0); /* vwma */
/* Run the actual calculation. */
const int ret = ti_vwma(in_size, inputs, options, outputs);
assert(ret == TI_OKAY);
Calling From Lua (with Tulip Chart bindings)
-- Example usage of Volume Weighted Moving Average
vwma = ti.vwma(close, volume, 5)
Example Calculation
period = 5
date | close | volume | vwma |
---|---|---|---|
2005-11-01 | 81.59 | 5,653,100.00 | |
2005-11-02 | 81.06 | 6,447,400.00 | |
2005-11-03 | 82.87 | 7,690,900.00 | |
2005-11-04 | 83.00 | 3,831,400.00 | |
2005-11-07 | 83.61 | 4,455,100.00 | 82.33 |
2005-11-08 | 83.15 | 3,798,000.00 | 82.61 |
2005-11-09 | 82.84 | 3,936,200.00 | 83.07 |
2005-11-10 | 83.99 | 4,732,000.00 | 83.35 |
2005-11-11 | 84.55 | 4,841,300.00 | 83.68 |
2005-11-14 | 84.36 | 3,915,300.00 | 83.82 |
2005-11-15 | 85.53 | 6,830,800.00 | 84.41 |
2005-11-16 | 86.54 | 6,694,100.00 | 85.17 |
2005-11-17 | 86.89 | 5,293,600.00 | 85.70 |
2005-11-18 | 87.77 | 7,985,800.00 | 86.42 |
2005-11-21 | 87.29 | 4,807,900.00 | 86.81 |
Chart
Other Indicators
Previous indicator: Volume Oscillator
Next indicator: Williams Accumulation/Distribution
Random indicator: Time Series Forecast
Copyright © 2016-2024 Tulip Charts LLC. All Rights Reserved.