Correlation Trend Indicator (CTI)

Calculate the Correlation Trend Indicator (CTI) of a price series: the Pearson correlation of the prices over the window with a straight line rising over time.

Ehlers (2020) measures the trend by how closely the prices follow an upward-sloping line: +1 when they rise in a straight line, -1 when they fall in one, and around 0 when they move sideways or in a cycle. Ehlers reads values above 0 as an uptrend and below 0 as a downtrend, with the indicator crossing zero as the switch between them. Unlike the slope it is bounded and does not depend on the price level, so it compares across securities.

The formula is as follows:

\[\text{CTI} = \operatorname{Correlation}(\text{Close},\; x,\; \text{window}),\;\; \text{with}\;\; \text{time}\; x = 0,\; \ldots,\; \text{window} - 1 \;\text{from the oldest price of the window to the latest}\]

Also known as: CTI, correlation trend, Ehlers correlation trend indicator.

Example · AAPL, MSFT · 2021 to 2025

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

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_correlation_trend_indicator()

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

How strongly did the prices of Apple and Microsoft trend in 2025, according to the Correlation Trend Indicator?

Which returns:

Parameters

get_correlation_trend_indicator 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, at least 2. Defaults to 20.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 CTI. 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 Ehlers, J.F. (2020). “Correlation As A Trend Indicator.” Technical Analysis of Stocks & Commodities, 38(5), 24-27.
  • Library Referenced against TA-Lib’s CTI
  • Library Referenced against pandas-ta-classic’s cti
Share