Swing Index

Calculate Wilder’s Swing Index and Accumulative Swing Index: the strength of each period’s move compared with the previous period, and its running total, which shows the real direction of the prices.

The Swing Index of Wilder (1978) weighs the change of the close against the previous period’s open and close and against the range of the current period, to measure the real direction of a period’s move. Wilder accumulates it into the Accumulative Swing Index, a line that follows the price but filters out the moves that the open, high and low do not confirm: a breakout of the ASI through a previous high or low swing point confirms a breakout of the price.

The formula is as follows:

\[A = \left|\text{High} - \operatorname{Close}(t - 1)\right|,\;\; B = \left|\text{Low} - \operatorname{Close}(t - 1)\right|,\;\; C = \left|\text{High} - \text{Low}\right|,\;\; D = \left|\operatorname{Close}(t - 1) - \operatorname{Open}(t - 1)\right|\] \[R = A - 0.5 \cdot B + 0.25 \cdot D \;\text{when}\; A \;\text{is the largest of}\; A,\;\; B \text{ and } C\] \[R = B - 0.5 \cdot A + 0.25 \cdot D \;\text{when}\; B \;\text{is the largest},\;\; \text{else}\;\; R = C + 0.25 \cdot D\] \[K = \max(A,\; B)\] \[N = (\text{Close} - \operatorname{Close}(t - 1)) + 0.5 \cdot (\text{Close} - \text{Open}) + 0.25 \cdot (\operatorname{Close}(t - 1) - \operatorname{Open}(t - 1))\] \[\text{Swing Index} = 50 \cdot \frac{N}{R} \cdot \frac{K}{\text{limit\_move}}\] \[\text{Accumulative Swing Index} = \text{Sum of the Swing Index since the first period}\]

The limit move is the largest move a futures contract may make in one period. A stock has none, so limit_move is a scale in price units: the Swing Index stays within -100 and 100 only for moves within it, and only the shape of the ASI, not its level, carries meaning.

Also known as: SI, ASI, Wilder Swing Index, Accumulation Swing Index.

Example · AAPL, MSFT · 2024 to 2025

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

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_swing_index().xs("AAPL", level=1, axis="columns")

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

How did Apple's Swing Index and Accumulative Swing Index develop in 2025?

Which returns:

Parameters

get_swing_index 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”, in which case the open, high and low prices are adjusted for dividends in the same way."Close"
limit_movefloatThe limit move that scales the index, in price units. Defaults to 3.0, TA-Lib’s default.
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 Swing Index and Accumulative Swing Index. 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 Wilder, J.W. Jr. (1978). “New Concepts in Technical Trading Systems.” Trend Research, section VIII “The Swing Index.”
  • Library Referenced against TA-Lib’s SI
  • Library Referenced against TA-Lib’s ASI
Share