Calculate the McClellan Oscillator for a given price series.

The McClellan Oscillator is a breadth indicator that measures the difference between the exponential moving average of advancing stocks and the exponential moving average of declining stocks.

The formula is as follows:

\[\text{McClellan Oscillator} = \operatorname{EMA}(\text{Advancers}) - \operatorname{EMA}(\text{Decliners})\]

Also known as: McClellan oscillator, market breadth.

McClellan Oscillator in Python

get_mcclellan_oscillator is part of the Technicals module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_mcclellan_oscillator as shown below.

from financetoolkit import Toolkit

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

toolkit.technicals.get_mcclellan_oscillator()

Which returns:

Date AAPL MSFT Benchmark
2026-06-18 5.1473 -4.4405 9.1566
2026-06-22 4.8047 -6.079 8.7467
2026-06-23 4.3522 -7.1196 7.8119
2026-06-24 3.8826 -8.3976 6.9567
2026-06-25 2.5652 -10.0799 6.2436
2026-06-26 1.8575 -10.4608 5.3373
2026-06-29 1.1411 -10.9542 5.1361
2026-06-30 0.9039 -11.0988 5.227
2026-07-01 0.9476 -10.6039 5.228
2026-07-02 1.6926 -9.8173 5.1538

Parameters

get_mcclellan_oscillator 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 name of the column containing the close prices. Defaults to “Adj Close”.
  • short_ema_window (int, optional): The window size for the short-term EMA. Defaults to 19.
  • long_ema_window (int, optional): The window size for the long-term EMA. Defaults to 39.
  • 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