Williams Accumulation/Distribution

Function Prototype

/* Williams Accumulation/Distribution */
/* Type: indicator */
/* Input arrays: 3    Options: 0    Output arrays: 1 */
/* Inputs: high, low, close */
/* Options: none */
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.

Williams Accumulation/Distribution can help determine trend direction.

It is calculated for each bar as:

$$ad_{t} = \begin{cases} close_{t} - min(close_{t-1}, low_{t}) & \mathrm{if} \; close_{t} > close_{t-1} \\ close_{t} - max(close_{t-1}, high_{t}) & \mathrm{if} \; close_{t} \lt close_{t-1} \\ 0 & \mathrm{else} \end{cases}$$
$$wad_{t} = wad_{t-1} + ad_{t}$$

Example Usage

Calling From C

/* Example usage of Williams Accumulation/Distribution */
/* Assuming that 'high', 'low', and 'close' are pre-loaded arrays of size 'in_size'. */
TI_REAL *inputs[] = {high, low, close};
TI_REAL options[] = {}; /* No options */

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

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

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


Calling From Lua (with Tulip Chart bindings)

-- Example usage of Williams Accumulation/Distribution


Example Calculation

2005-11-0182.1581.2981.59
2005-11-0281.8980.6481.06-0.83
2005-11-0383.0381.3182.870.98
2005-11-0483.3082.6583.001.33
2005-11-0783.8583.0783.611.94
2005-11-0883.9083.1183.151.19
2005-11-0983.3382.4982.840.70
2005-11-1084.3082.3083.992.39
2005-11-1184.8484.1584.552.95
2005-11-1485.0084.1184.362.31
2005-11-1585.9084.0385.533.81
2005-11-1686.5885.3986.544.96
2005-11-1786.9885.7686.896.09
2005-11-1888.0087.1787.776.97
2005-11-2187.8787.0187.296.39

Other Indicators

Previous indicator: Volume Weighted Moving Average

Next indicator: Weighted Close Price

Random indicator: Vector Tangent