Volume Weighted Moving Average

Technical Analysis Indicator: vwma

Fork me on GitHub

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

dateclosevolumevwma
2005-11-0181.595,653,100.00
2005-11-0281.066,447,400.00
2005-11-0382.877,690,900.00
2005-11-0483.003,831,400.00
2005-11-0783.614,455,100.0082.33
2005-11-0883.153,798,000.0082.61
2005-11-0982.843,936,200.0083.07
2005-11-1083.994,732,000.0083.35
2005-11-1184.554,841,300.0083.68
2005-11-1484.363,915,300.0083.82
2005-11-1585.536,830,800.0084.41
2005-11-1686.546,694,100.0085.17
2005-11-1786.895,293,600.0085.70
2005-11-1887.777,985,800.0086.42
2005-11-2187.294,807,900.0086.81

Chart

 

Other Indicators

Previous indicator: Volume Oscillator

Next indicator: Williams Accumulation/Distribution

Random indicator: Aroon