Forecast Oscillator

Calculate the Forecast Oscillator of a price series: how far the price lies from the Time Series Forecast made for it one period earlier, as a share of the price.

Chande’s Forecast Oscillator measures the error of the linear regression forecast: it is positive when the price comes in above the forecast of the previous period and negative when below it. A forecast that keeps being too low points to a trend that accelerates, and the oscillator crossing zero to a change in the direction of the error.

The formula is as follows:

\[\text{Time Series Forecast}(t - 1) = \text{the least-squares line over the} \;\text{window} \;\text{periods up to}\; t - 1,\;\; \text{extended to } t\] \[\text{Forecast Oscillator} = \frac{\text{Close} - \text{Time Series Forecast}(t - 1)}{\text{Close}}\]

Also known as: FOSC, Chande Forecast Oscillator, CFO, forecast error.

Example · AAPL, MSFT · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_forecast_oscillator:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["AAPL", "MSFT"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_forecast_oscillator()

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

How far did Apple and Microsoft trade from their linear regression forecasts in 2025?

Which returns:

Parameters

get_forecast_oscillator accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Options are: “intraday” (intraday prices), “daily” (daily prices), “weekly” (weekly prices), “monthly” (monthly prices), “quarterly” (quarterly prices), “yearly” (yearly prices). Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”."Close"
windowintThe number of periods the forecast line is fitted over, at least 2. Defaults to 5.20
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the Forecast Oscillator. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

  • Paper Chande, T.S. & Kroll, S. (1994). “The New Technical Trader.” Wiley.
  • Library Referenced against TA-Lib’s FOSC
  • Library Referenced against Tulip Indicators’ fosc
  • Library Shares similar logic as pandas-ta-classic’s fosc
  • Library Shares similar logic as pandas-ta-classic’s cfo
Share