fintech-algorithms

Ultimate Oscillator

Install and import

bash
npm install fintech-algorithms
ts
import { ultimate_oscillator } from "fintech-algorithms/technical-indicators/momentum/ultimate-oscillator";

Signature

ultimate_oscillator(high, low, close, s, m, g)

Weighted buying pressure across three lookbacks at once, which is what makes it less sensitive to the choice of any single period than a plain oscillator.

Parameters

NameTypeNotes
highnumber[]Per-bar high prices, chronological.
lownumber[]Per-bar low prices, chronological.
closenumber[]Per-bar closing prices, chronological.
snumberShort lookback, conventionally weighted 4.
min: 1 · integer: true
mnumberMedium lookback, conventionally weighted 2.
min: 1 · integer: true
gnumberLong lookback, conventionally weighted 1.
min: 1 · integer: true

Returns

Record<string, (number | null)[]> · length same-as-input

Parallel series: buying_pressure, true_range and ultimate_oscillator.

Warm-up

The first the longest of the three lookbacks positions are null.

Errors

  • When any lookback is < 1 or is not an integer — throws RangeError
  • When the input series are not all the same length — throws RangeError

Complexity: time O(n × g), space O(n).

Worked example

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input

high
[101, 101.992465, 103.28276, 104.655405, 105.856544, 106.661472]

Showing 6 of 120 elements.

low
[99.08, 99.149664, 100.233798, 101.654978, 103.180913, 104.534685]

Showing 6 of 120 elements.

close
[100, 100.999214, 102.324548, 103.755998, 105.030823, 105.911843]

Showing 6 of 120 elements.

Call

ultimate_oscillator(high, low, close, s, m, g)

Returns

object with 3 fields: buying_pressure, true_range, ultimate_oscillator

{
  "buying_pressure": [
    null,
    1.8495499999999936,
    2.09075,
    2.1010200000000054,
    1.8499099999999942,
    1.3771580000000085
  ],
  "true_range": [
    null,
    2.8428009999999944,
    3.048962000000003,
    3.000427000000002,
    2.6756309999999957,
    2.1267870000000073
  ],
  "ultimate_oscillator": [null, null, null, null, null, null]
}

Other exports

This module also exports rsi, stochastic, stochastic_rsi, williams_r, cci, tsi, connors_rsi. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams

Ultimate Oscillator — ultimate oscillator mechanism

How it works

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References

  • Ultimate Oscillator (ULTOSC) — TA-Lib
  • TA-Lib Technical Analysis Documentation — TA-Lib
  • Claim-role ledger
  • Evidence boundary