Calculate the Ultimate Oscillator for a given price series.

The Ultimate Oscillator is a momentum oscillator that combines short-term, mid-term, and long-term price momentum into a single value.

The formula is as follows:

\[\operatorname{Average}(i) = \operatorname{Sum}(\text{Buying Pressure},\; \text{window}_{i}) / \operatorname{Sum}(\text{True Range},\; \text{window}_{i})\] \[\text{Ultimate Oscillator} = 100 \cdot \left[(4 \cdot \text{Average}_{1}) + (2 \cdot \text{Average}_{2}) + \text{Average}_{3}\right] / 7\]

Also known as: UO, ultimate momentum oscillator. See momentum_model.get_ultimate_oscillator for the Buying Pressure and True Range definitions.

Ultimate Oscillator in Python

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_ultimate_oscillator as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(tickers=["AAPL", "MSFT"])

toolkit.technicals.get_ultimate_oscillator()

Which returns:

Date AAPL MSFT Benchmark
2026-06-18 5.7264 1.4313 5.7432
2026-06-22 5.7478 0.3073 5.6389
2026-06-23 4.1905 1.5815 3.88
2026-06-24 3.6773 1.0805 2.8505
2026-06-25 0.392 -0.874 1.6945
2026-06-26 1.0483 0.9805 2.1519
2026-06-29 1.9469 2.2386 4.6356
2026-06-30 3.0712 3.2361 5.7923
2026-07-01 4.2231 4.5312 6.0908
2026-07-02 5.615 5.5004 6.4095

Parameters

The function accepts the following parameters:

  • period (str, optional): The time period to consider for historical data. Can be “daily”, “weekly”, “quarterly”, or “yearly”. Defaults to “daily”.
  • close_column (str, optional): The column in the historical data that represents the closing prices. Defaults to “Adj Close”.
  • window_1 (int, optional): The number of periods for the first short-term window. Defaults to 7.
  • window_2 (int, optional): The number of periods for the second mid-term window. Defaults to 14.
  • window_3 (int, optional): The number of periods for the third long-term window. Defaults to 28.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
  • growth (bool, optional): Whether to calculate the growth of the indicator values. Defaults to False.
  • lag (int | list[int], optional): The lag to use for the growth calculation.
  • standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. Defaults to 1.
Share