Function Prototype
/* Variable Index Dynamic Average */
/* Type: overlay */
/* Input arrays: 1 Options: 3 Output arrays: 1 */
/* Inputs: real */
/* Options: short period, long period, alpha */
/* Outputs: vidya */
int ti_vidya_start(TI_REAL const *options);
int ti_vidya(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 Variable Index Dynamic Average indicator modifies the Exponential Moving Average by varying the smoothness based on recent volatility.
It takes three parameters: a short period n
, a long period m
, and a
smoothing factor a
. a
is usually 0.2
.
It is built up using a ratio of a long Standard Deviation Over Period to a short Standard Deviation Over Period as as smoothing factor.
The calculation is as follows:
Alternately, it can be expressed in terms of Standard Deviation Over Period like this:
See Also
References
Example Usage
Calling From C
/* Example usage of Variable Index Dynamic Average */
/* Assuming that 'input' is a pre-loaded array of size 'in_size'. */
TI_REAL *inputs[] = {input};
TI_REAL options[] = {2, 5, .2}; /* short period, long period, alpha */
TI_REAL *outputs[1]; /* vidya */
/* Determine how large the output size is for our options. */
const int out_size = in_size - ti_vidya_start(options);
/* Allocate memory for output. */
outputs[0] = malloc(sizeof(TI_REAL) * out_size); assert(outputs[0] != 0); /* vidya */
/* Run the actual calculation. */
const int ret = ti_vidya(in_size, inputs, options, outputs);
assert(ret == TI_OKAY);
Calling From Lua (with Tulip Chart bindings)
-- Example usage of Variable Index Dynamic Average
vidya = ti.vidya(input, 2, 5, .2)
Example Calculation
short period = 2, long period = 5, alpha = .2
date | input | vidya |
---|---|---|
2005-11-01 | 81.59 | |
2005-11-02 | 81.06 | |
2005-11-03 | 82.87 | |
2005-11-04 | 83.00 | 83.00 |
2005-11-07 | 83.61 | 83.04 |
2005-11-08 | 83.15 | 83.05 |
2005-11-09 | 82.84 | 83.02 |
2005-11-10 | 83.99 | 83.29 |
2005-11-11 | 84.55 | 83.40 |
2005-11-14 | 84.36 | 83.43 |
2005-11-15 | 85.53 | 83.71 |
2005-11-16 | 86.54 | 84.02 |
2005-11-17 | 86.89 | 84.12 |
2005-11-18 | 87.77 | 84.39 |
2005-11-21 | 87.29 | 84.58 |
Chart
Other Indicators
Previous indicator: Vertical Horizontal Filter
Next indicator: Annualized Historical Volatility
Random indicator: Vector Degree Conversion