Calculate the Supertrend indicator for a given price series.

The Supertrend indicator plots a single trailing line that flips between sitting below price (in an uptrend) and above price (in a downtrend). The line is built from two bands offset from the median price ((High + Low) / 2) by a multiple of the Average True Range, which are then “ratcheted” period over period - each band can only move in the direction that tightens around price - so that the active band only flips to the other side once the closing price actually crosses it. This makes Supertrend both a trend filter (the flip direction signals a trend change) and a trailing stop-loss level.

The formula is as follows:

\[\text{Basic Upper Band} = (\text{High} + \text{Low}) / 2 + \text{multiplier} \cdot \operatorname{ATR}(\text{window})\] \[\text{Basic Lower Band} = (\text{High} + \text{Low}) / 2 - \text{multiplier} \cdot \operatorname{ATR}(\text{window})\] \[\text{Final Upper Band} (t) = \text{Basic Upper Band} (t) \text{if Basic Upper Band} (t) < \text{Final Upper Band} (t-1) \text{or Close} (t-1) > \text{Final Upper Band} (t-1),\;\; \text{else Final Upper Band(t-1)}\] \[\text{Final Lower Band} (t) = \text{Basic Lower Band} (t) \text{if Basic Lower Band} (t) > \text{Final Lower Band} (t-1) \text{or Close} (t-1) < \text{Final Lower Band} (t-1),\;\; \text{else Final Lower Band(t-1)}\] \[\text{While in an uptrend},\;\; \text{Supertrend} = \text{Final Lower Band},\;\; \text{until Close crosses below it},\;\; \text{at which point the trend flips to}\; a \;\text{downtrend and Supertrend} = \text{Final Upper Band} (\text{and vice versa})\]

Also known as: Supertrend, SuperTrend.

Supertrend in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_supertrend as shown below.

from financetoolkit import Toolkit

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

toolkit.technicals.get_supertrend().xs("SHOP", level=1, axis="columns").tail(5)

Or, after setting up the Finance Toolkit MCP, ask:

Where was Shopify's Supertrend level and which way did its trend point from 24 to 31 December 2025, based on prices from the start of 2025?

Which returns:

Date Supertrend Trend Direction
2025-12-24 150.646 1
2025-12-26 151.942 1
2025-12-29 152.113 1
2025-12-30 152.113 1
2025-12-31 152.113 1

Parameters

get_supertrend accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Can be “intraday”, “daily”, “weekly”, “monthly”, “quarterly” or “yearly”. Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”, in which case the open, high and low prices are adjusted for dividends in the same way."Close"
windowintNumber of periods for the underlying Average True Range calculation. Defaults to 10.20
multiplierfloatMultiplier applied to the Average True Range to determine how far the bands sit from the median price. Defaults to 3.0.2.0
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 Supertrend and Trend Direction values. 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
Share