Ultimate Oscillator

Technical Analysis Indicator: ultosc

Fork me on GitHub

Function Prototype

/* Ultimate Oscillator */
/* Type: indicator */
/* Input arrays: 3    Options: 3    Output arrays: 1 */
/* Inputs: high, low, close */
/* Options: short period, medium period, long period */
/* Outputs: ultosc */
int ti_ultosc_start(TI_REAL const *options);
int ti_ultosc(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 Ultimate Oscillator is really a combination of three separate oscillators, each using a different smoothing period.

It takes three parameter: a short period n, a medium period m, and a long period p.

It is calculated as follows:

$$tl_{t} = minimun(low_{t}, close_{t-1})$$
$$th_{t} = maximum(high_{t}, close_{t-1})$$
$$bp_{t} = close_{t} - tl_{t}$$
$$r_{t} = th_{t} - tl_{t}$$
$$ultosc_{t} = \frac{100}{7} \left( 4 \frac{\sum_{i=0}^{n-1} bp_{t-i}}{\sum_{i=0}^{n-1} r_{t-i}} + 2 \frac{\sum_{i=0}^{m-1} bp_{t-i}}{\sum_{i=0}^{m-1} r_{t-i}} + \frac{\sum_{i=0}^{p-1} bp_{t-i}}{\sum_{i=0}^{p-1} r_{t-i}} \right) $$

See Also

References

Example Usage

Calling From C

/* Example usage of Ultimate Oscillator */
/* Assuming that 'high', 'low', and 'close' are pre-loaded arrays of size 'in_size'. */
TI_REAL *inputs[] = {high, low, close};
TI_REAL options[] = {2, 3, 5}; /* short period, medium period, long period */
TI_REAL *outputs[1]; /* ultosc */

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

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

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

Calling From Lua (with Tulip Chart bindings)

-- Example usage of Ultimate Oscillator
ultosc = ti.ultosc(high, low, close, 2, 3, 5)

Example Calculation

short period = 2, medium period = 3, long period = 5

datehighlowcloseultosc
2005-11-0182.1581.2981.59
2005-11-0281.8980.6481.06
2005-11-0383.0381.3182.87
2005-11-0483.3082.6583.00
2005-11-0783.8583.0783.61
2005-11-0883.9083.1183.1543.50
2005-11-0983.3382.4982.8434.04
2005-11-1084.3082.3083.9965.88
2005-11-1184.8484.1584.5573.96
2005-11-1485.0084.1184.3653.39
2005-11-1585.9084.0385.5364.15
2005-11-1686.5885.3986.5481.28
2005-11-1786.9885.7686.8990.19
2005-11-1888.0087.1787.7786.11
2005-11-2187.8787.0187.2965.45

Chart

 

Other Indicators

Previous indicator: Typical Price

Next indicator: Variance Over Period

Random indicator: Accumulation/Distribution Oscillator