fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Trend Smoothing

24 algorithms in Technical Indicators · 24 with asserted arithmetic.

In this family#

  1. Simple Moving Average (SMA) verified

    Arithmetic mean of the last window observations, emitted at every position where a complete window is available.

    calculateSma(values, window)
  2. Exponential Moving Average (EMA) verified

    Exponentially weighted mean seeded with the simple mean of the first span observations, so the series is reproducible rather than dependent on where the data starts.

    calculateEma(values, span)
  3. Weighted Moving Average (WMA) verified

    Linearly weighted mean over window observations: the most recent observation carries weight window, the oldest weight 1.

    calculateWma(values, window)
  4. Wilder RMA verified

    Wilder's smoothing — an exponential mean with decay 1 / period rather than 2 / (period + 1). This is the smoother RSI, ATR and ADX are defined against, and substituting a standard EMA changes their published values.

    calculateRma(values, period)
  5. Double Exponential Moving Average (DEMA) verified

    Double exponential moving average: 2 × EMA − EMA(EMA). Subtracting the second smoothing pass cancels most of the lag a single EMA introduces, at the cost of overshooting sharp reversals.

    calculateDemaComponents(values, span)
  6. Triple Exponential Moving Average (TEMA) verified

    Triple exponential moving average: 3 × EMA − 3 × EMA(EMA) + EMA(EMA(EMA)). More lag cancellation than DEMA, and correspondingly more overshoot.

    calculateTemaComponents(values, span)
  7. Hull MA verified

    Hull moving average: a weighted combination of two WMAs de-lagged against each other, then re-smoothed over sqrt(window). Far more responsive than an SMA of the same length, at the cost of overshoot.

    calculateHullMa(values, window)
  8. Kaufman Adaptive Moving Average (KAMA) verified

    Kaufman adaptive moving average. The smoothing constant moves between a fast and a slow bound according to an efficiency ratio — directional travel divided by total travel — so the average tightens in a trend and loosens in noise.

    calculateKama(values, efficiencyPeriod, fastPeriod, slowPeriod)
  9. MESA Adaptive Moving Average (MAMA) verified

    MESA adaptive moving average. A Hilbert transform estimates the dominant cycle period of the series, and the smoothing rate follows the rate of phase change — so the average adapts to cycle length rather than to a fixed window.

    mama(values, fastLimit, slowLimit)
  10. Triangular Moving Average (TRIMA) verified

    Smooths close twice with simple moving averages, an inner window of floor((period + 1) / 2) followed by an outer window of floor(period / 2) + 1, giving the triangular weighting its name.

    triangularMovingAverageTrima(input)
  11. Tillson T3 Moving Average verified

    Chains six exponential moving averages of the same period over close and combines the third through sixth with the Tillson volume-factor coefficients, trading warm-up length for a smoother, less laggy curve.

    tillsonT3MovingAverage(input)
  12. Following Adaptive Moving Average (FAMA) verified

    Runs an efficiency-ratio adaptive average over close and its slower follower: net movement across period bars divided by the summed absolute bar-to-bar movement sets the smoothing constant, and FAMA tracks MAMA at half that constant.

    followingAdaptiveMovingAverageFama(input)
  13. Arnaud Legoux Moving Average (ALMA) verified

    Averages close under a Gaussian weight curve whose peak sits at offset * (period - 1) within the window and whose width is period / sigma, so pushing the offset toward 1 favours recent bars.

    arnaudLegouxMovingAverageAlma(input)
  14. Fractal Adaptive Moving Average (FRAMA) verified

    Estimates the fractal dimension of each period-bar close window by comparing the ranges of its two halves against the range of the whole, then smooths close with exp(-4.6 * (dimension - 1)) as the adaptive constant.

    fractalAdaptiveMovingAverageFrama(input)
  15. Zero-Lag Exponential Moving Average (ZLEMA) verified

    Removes most of the EMA's lag by first de-lagging close into 2 * close[t] - close[t - lag], where lag is floor((period - 1) / 2), and then running an ordinary EMA of period over that adjusted series.

    zeroLagExponentialMovingAverageZlema(input)
  16. Least-Squares Moving Average (LSMA) verified

    Fits an ordinary least-squares line to each period-bar window of close and reports the value of that line at the window's last bar, so the curve follows the local trend rather than its average.

    leastSquaresMovingAverageLsma(input)
  17. Variable Index Dynamic Average (VIDYA) verified

    Scales the EMA constant 2 / (period + 1) by the absolute Chande momentum oscillator of the last period one-bar changes, so the average speeds up in one-sided moves and nearly freezes when gains and losses balance.

    variableIndexDynamicAverageVidya(input)
  18. McGinley Dynamic verified

    Tracks close with McGinley's self-adjusting recursion, dividing the step toward the new close by k * period * (close / previous) ** 4 so the line accelerates when price runs away from it and coasts when price is near.

    mcginleyDynamic(input)
  19. Jurik-Style Moving Average Design verified

    Demonstrates the Jurik design idea without the proprietary internals: the current absolute bar-to-bar change is scored against its own period-bar average, and that score stretches a base smoothing constant between a floor and a ceiling before the average is applied to close.

    jurikStyleMovingAverageDesign(input)
  20. Volume-Weighted Moving Average (VWMA) verified

    Averages close over a rolling period-bar window using each bar's volume as its weight, so heavily traded bars pull the line further than quiet ones.

    volumeWeightedMovingAverageVwma(input)
  21. Quadratic-Weighted Moving Average verified

    Averages close over a rolling period-bar window with weights that grow as the square of a bar's position, 1, 4, 9 and so on, front-loading recency harder than the linear weights of a WMA.

    quadraticWeightedMovingAverage(input)
  22. Gaussian Moving Average verified

    Averages close under a Gaussian weight curve centred at offset * (period - 1) with width period / sigma. The default offset of 0.5 puts the peak in the middle of the window, which is what separates this from ALMA's recency-shifted variant of the same kernel.

    gaussianMovingAverage(input)
  23. Ehlers Super Smoother Filter verified

    Applies Ehlers' two-pole Butterworth recursion to the two-bar mean of close, with feedback coefficients derived from period via exp(-sqrt(2) * pi / period), suppressing high-frequency noise with far less lag than a moving average of the same length.

    ehlersSuperSmootherFilter(input)
  24. Ehlers Instantaneous Trendline verified

    Splits close into a smoothed centre line and what is left over: the trendline is an EMA of max(4, period) and the detrended series is the bar's close minus that trendline.

    ehlersInstantaneousTrendline(input)

What they share#

Every topic here is a series-transform, so once you have called one the rest follow the same shape. Import paths differ only in the final segment:

ts
import { calculateSma } from "fintech-algorithms/technical-indicators/trend-smoothing/sma";
import { calculateEma } from "fintech-algorithms/technical-indicators/trend-smoothing/ema";

Read them in the order above — the sequence is pedagogical, not alphabetical.

Where this sits#

Technical Indicators collects 137 algorithms across 9 families. For the concept behind this family rather than the call signatures, see the concept guides.