Follow-Through Index

All functions · nseries package

FTI

func (s Series) FTI(minPeriod, maxPeriod, halfLength, lookback int, beta, noiseCut float64) Series

FTI returns the Follow-Through Index at the optimal period for each bar. Khalsa’s FTI measures how strongly a market trends relative to its noise at each candidate cycle period. The optimal period is the local maximum (including endpoints) with the highest FTI value.

Defaults: minPeriod=5, maxPeriod=65, halfLength=40, lookback=100, beta=0.9, noiseCut=0.2.

minPeriod must be at least 3: the period-2 filter passes its input unchanged, so the channel width is 0 and the index would reflect only the floor. A smaller minPeriod is invalid and gives all zeros.

One bar costs about P*(lookback - halfLength)*(2*halfLength + 1) multiply-adds, where P = maxPeriod - minPeriod + 1 is the number of periods: about 300,000 at the defaults.

Memory is bounded by the input and a fixed budget whatever the period range: the periods’ filter coefficients are formed in batches of at most 2^20 values (one period at a time when its halfLength + 1 values are more), so a call allocates on the order of len(s) + lookback + halfLength + 2^20 floats. Releases before this change formed one table of P*(halfLength + 1) values, which for period ranges of the order of the input length could exceed memory (about 149 GiB for FTI(3, 199998, 99999, 100000, 0.9, 0.2) on 100,000 bars) or overflow an int and panic; every output is unchanged.

beta is the fractile, a fraction strictly between 0 and 1, and noiseCut is a fraction of the longest leg with 0 <= noiseCut < 1: a leg counts only if it is longer than noiseCut times the longest leg. The defaults are 0.9 and 0.2; beta 90, noiseCut 20 or a NaN for either gives all zeros (releases before this change accepted a NaN, and a NaN beta gave values that depended on the CPU). The warm-up reads 0, not NaN: bars 0 to lookback-2 are 0.

The channel width has a floor of 1e-5 times the absolute mean of the lookback window’s prices, so the index does not depend on the price unit: scaling the input by a power of 2 leaves every bar unchanged. Releases before this change added 1e-5 in price units, negligible at equity prices but material near 1 and below (8% low at a level of 0.01).

FTIAt

func (s Series) FTIAt(period, halfLength, lookback int, beta, noiseCut float64) Series

FTIAt returns the FTI at a specific fixed period.

period must be at least 3, as minPeriod in FTI; a smaller period is invalid and gives all zeros.

beta is a fraction strictly between 0 and 1 and noiseCut a fraction with 0 <= noiseCut < 1, as in FTI. The warm-up reads 0, not NaN: bars 0 to lookback-2 are 0.

The channel width’s floor is relative to the window’s mean price, as in FTI.

FTILog

func (s Series) FTILog(minPeriod, maxPeriod, halfLength, lookback int, beta, noiseCut float64) Series

FTILog is FTI on log prices, the form in which Aronson and Masters describe the source; its channel-width floor of 1e-5 log units is already scale-free. It is not FTI of the logged input, whose floor is relative to the window’s mean.

minPeriod must be at least 3, as in FTI; a smaller minPeriod is invalid and gives all zeros.

Cost and memory are as in FTI: memory is bounded by the input and a fixed budget whatever the period range.

beta is a fraction strictly between 0 and 1 and noiseCut a fraction with 0 <= noiseCut < 1, as in FTI. The warm-up reads 0, not NaN: bars 0 to lookback-2 are 0.

FTIPeriod

func (s Series) FTIPeriod(minPeriod, maxPeriod, halfLength, lookback int, beta, noiseCut float64) Series

FTIPeriod returns the optimal cycle period at each bar.

minPeriod must be at least 3, as in FTI; a smaller minPeriod is invalid and gives all zeros.

Cost and memory are as in FTI: memory is bounded by the input and a fixed budget whatever the period range.

beta is a fraction strictly between 0 and 1 and noiseCut a fraction with 0 <= noiseCut < 1, as in FTI. The warm-up reads 0, not NaN: bars 0 to lookback-2 are 0, which lies outside [minPeriod, maxPeriod], so it cannot be mistaken for a period.

The channel width’s floor is relative to the window’s mean price, as in FTI.