Qstick

Technical Analysis Indicator: qstick

Fork me on GitHub

Function Prototype

/* Qstick */
/* Type: indicator */
/* Input arrays: 2    Options: 1    Output arrays: 1 */
/* Inputs: open, close */
/* Options: period */
/* Outputs: qstick */
int ti_qstick_start(TI_REAL const *options);
int ti_qstick(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.

Qstick can be used to quantify the ratio of recent up-bars to down-bars.

Qstick takes one parameter, the period n.

It is calculated for each bar as follows:

$$qstick_{t} = \frac{1}{n} \sum_{i=0}^{n-1} close_{t-i} - open_{t-i}$$

See Also

References

Example Usage

Calling From C

/* Example usage of Qstick */
/* Assuming that 'open' and 'close' are pre-loaded arrays of size 'in_size'. */
TI_REAL *inputs[] = {open, close};
TI_REAL options[] = {5}; /* period */
TI_REAL *outputs[1]; /* qstick */

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

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

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

Calling From Lua (with Tulip Chart bindings)

-- Example usage of Qstick
qstick = ti.qstick(open, close, 5)

Example Calculation

period = 5

dateopencloseqstick
2005-11-0181.8581.59
2005-11-0281.2081.06
2005-11-0381.5582.87
2005-11-0482.9183.00
2005-11-0783.1083.610.30
2005-11-0883.4183.150.30
2005-11-0982.7182.840.36
2005-11-1082.7083.990.35
2005-11-1184.2084.550.40
2005-11-1484.2584.360.32
2005-11-1584.0385.530.68
2005-11-1685.4586.540.87
2005-11-1786.1886.890.75
2005-11-1888.0087.770.64
2005-11-2187.6087.290.55

Chart

 

Other Indicators

Previous indicator: Positive Volume Index

Next indicator: Rate of Change

Random indicator: Money Flow Index