Gann HiLo Activator

Calculate the Gann HiLo Activator: a trailing stop drawn from a moving average of the lows in an uptrend and of the highs in a downtrend, which flips when the close crosses the other average.

The HiLo Activator is a trailing stop drawn from a moving average of the highs and one of the lows. A close above the previous average of the highs turns the trend up, after which the line follows the average of the lows beneath the price; a close below the previous average of the lows turns it down, after which the line follows the average of the highs above the price. A close between the two averages keeps the trend, so the line only flips side on a clear break.

The formula is as follows:

\[\text{High Average} = \operatorname{SMA}(\text{High},\; \text{High Window}),\;\; \text{Low Average} = \operatorname{SMA}(\text{Low},\; \text{Low Window})\] \[\operatorname{Trend}(t) = 1 \;\text{if Close}(t) > \text{High Average}(t-1),\;\; - 1 \;\text{if Close}(t) < \text{Low Average}(t-1),\;\; \text{otherwise Trend(t-1)}\] \[\text{HiLo Activator}(t) = \text{Low Average}(t) \;\text{when the trend is}\; 1,\;\; \text{High Average(} t \text{) when it is -1}\]

Also known as: HiLo, Gann HiLo, Gann HiLo Activator, HiLo Activator.

Example · AMD · 2021 to 2025

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

from financetoolkit import Toolkit

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

toolkit.technicals.get_gann_hilo_activator().xs("AMD", level=1, axis="columns")

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

Was AMD in an uptrend or a downtrend in 2025 according to the Gann HiLo Activator?

Which returns:

Parameters

get_gann_hilo_activator 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 high and low prices are adjusted for dividends in the same way."Close"
high_windowintThe number of periods of the average of the highs. Defaults to 13.13
low_windowintThe number of periods of the average of the lows. Defaults to 21.21
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 activator. 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 Krausz, R. (1998). “The New Gann Swing Chartist.” Technical Analysis of Stocks & Commodities, 16(2).
  • Library Shares similar logic as pandas-ta-classic’s hilo
Share