Vector Cosine

Technical Analysis Indicator: cos

Fork me on GitHub

Function Prototype

/* Vector Cosine */
/* Type: simple */
/* Input arrays: 1    Options: 0    Output arrays: 1 */
/* Inputs: real */
/* Options: none */
/* Outputs: cos */
int ti_cos_start(TI_REAL const *options);
int ti_cos(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.

Vector Cosine calculates the Trigonometric cosine of each element in the input array.

$$cos_{t} = \cos{input_{t}}$$

This is sometimes useful as a building block to more complex functions.

See Also

References

Example Usage

Calling From C

/* Example usage of Vector Cosine */
/* Assuming that 'input' is a pre-loaded array of size 'in_size'. */
TI_REAL *inputs[] = {input};
TI_REAL options[] = {}; /* No options */
TI_REAL *outputs[1]; /* cos */

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

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

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

Calling From Lua (with Tulip Chart bindings)

-- Example usage of Vector Cosine
cos = ti.cos(input)

Example Calculation

dateinputcos
2005-11-0181.591.00
2005-11-0281.060.81
2005-11-0382.870.37
2005-11-0483.000.25
2005-11-0783.61-0.35
2005-11-0883.150.10
2005-11-0982.840.40
2005-11-1083.99-0.67
2005-11-1184.55-0.96
2005-11-1484.36-0.90
2005-11-1585.53-0.76
2005-11-1686.540.15
2005-11-1786.890.48
2005-11-1887.770.98
2005-11-2187.290.78

Chart

 

Other Indicators

Previous indicator: Chande Momentum Oscillator

Next indicator: Vector Hyperbolic Cosine

Random indicator: Vector Arctangent