Schaff Trend Cycle (STC)

Calculate the Schaff Trend Cycle (STC): a stochastic of the MACD, applied twice, from 0 to 100, which shows the turns of a trend faster than the MACD.

The Schaff Trend Cycle of Schaff (2002, 2008) applies a smoothed stochastic twice to the MACD line: it measures where the MACD sits within its range over the last cycle, smooths that, and does the same again. The result moves between 0 and 100 and turns earlier than the MACD, as it follows the MACD’s cycle rather than its level. A turn up from below 25 is read as bullish and a turn down from above 75 as bearish.

The formula is as follows:

\[\text{MACD} = \operatorname{EMA}(\text{Close},\; \text{short\_window}) - \operatorname{EMA}(\text{Close},\; \text{long\_window})\] \[\text{Fraction}\; 1 = \frac{100 \cdot (\text{MACD} - \min(\text{MACD},\; \text{cycle\_window}))}{\max(\text{MACD},\; \text{cycle\_window}) - \min(\text{MACD},\; \text{cycle\_window})}\] \[\operatorname{PF}(t) = \operatorname{PF}(t - 1) + \text{factor} \cdot (\text{Fraction} \;1(t) - \operatorname{PF}(t - 1))\] \[\text{Fraction}\; 2 = \frac{100 \cdot (\text{PF} - \min(\text{PF},\; \text{cycle\_window}))}{\max(\text{PF},\; \text{cycle\_window}) - \min(\text{PF},\; \text{cycle\_window})}\] \[\operatorname{STC}(t) = \operatorname{STC}(t - 1) + \text{factor} \cdot (\text{Fraction} \;2(t) - \operatorname{STC}(t - 1))\]

A fraction over a window without a range keeps its previous value and each smoothing starts on its first input, as in Schaff (2008). Schaff uses 23, 50 and 10 with a factor of 0.5.

Also known as: STC, Schaff Trend Cycle indicator.

Example · AAPL, MSFT · 2024 to 2025

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

from financetoolkit import Toolkit

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

toolkit.technicals.get_schaff_trend_cycle()

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

How did the Schaff Trend Cycle of Apple and Microsoft move in 2025?

Which returns:

Parameters

get_schaff_trend_cycle 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"
short_windowintThe number of periods of the short EMA of the MACD. Defaults to 23.23
long_windowintThe number of periods of the long EMA of the MACD. Defaults to 50.50
cycle_windowintThe number of periods of the range of each stochastic. Defaults to 10.10
factorfloatThe smoothing factor of each stochastic. Defaults to 0.5.0.5
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 STC. 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 Schaff, D. (2008). “Releasing the Code to the Schaff Trend Cycle.” FX-Strategy.com.
  • Paper Schaff, D. (2002). “Catching Currency Moves with the Schaff Trend Cycle Indicator.” Chartpoint, July/August 2002.
  • Library Referenced against TA-Lib’s STC
  • Library Shares similar logic as pandas-ta-classic’s stc
  • Library Shares similar logic as ta’s STCIndicator
  • Library Shares similar logic as finta’s STC
Share