TTM Trend

Calculate Carter’s TTM Trend: whether the close lies above the average midpoint of the previous bars (1) or not (-1), which shows the direction of the trend.

The TTM Trend of John Carter colours each bar by the short-term trend: up (1) when the close is above the average midpoint, (High + Low) / 2, of the previous six bars, and down (-1) when it is not. Carter uses it to stay in a trade while the bars keep their colour and to avoid trading against it; two bars of the opposite colour in a row signal that the trend has turned.

The formula is as follows:

\[\text{Average Midpoint} = \operatorname{SMA}\left(\frac{\text{High} + \text{Low}}{2},\; \text{window}\right) \;\text{over the} \;\text{window} \;\text{bars before the current one}\] \[\text{TTM Trend} = 1 \;\text{if Close} > \text{Average Midpoint},\;\; \text{else -1}\]

Also known as: TTM Trend, TTM_TRND.

Example · AAPL, MSFT · 2024 to 2025

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

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

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

Were Apple and Microsoft in an uptrend or a downtrend in 2025 according to the TTM Trend?

Which returns:

Parameters

get_ttm_trend 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 earlier bars of the average midpoint. Defaults to 6.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 TTM Trend. 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 Carter, J.F. (2005). “Mastering the Trade: Proven Techniques for Profiting from Intraday and Swing Trading Setups.” McGraw-Hill.
  • Library Referenced against pandas-ta-classic’s ttm_trend
Share