Savitzky-Golay Filter
A Savitzky-Golay filter smooths a series by fitting a low-degree polynomial, by least squares, to a sliding window of points and taking the fitted value at the window's center. Savitzky-Golay Filter, also known as SG filter, Savitzky-Golay smoothing, polynomial smoothing filter, is a Trend concept. The Library holds 1 implementation, ready to run on Vela.
Top Savitzky-Golay Filter indicator
The top custom implementation, built on the original standard Savitzky-Golay Filter formula.
1 total
Want to trade Savitzky-Golay Filter? Put the implementation below on a live chart in Vela, and Quant will help you build a strategy on it and backtest it.
What is a Savitzky-Golay Filter?
A Savitzky-Golay filter smooths a series by fitting a low-degree polynomial, by least squares, to a sliding window of points and taking the fitted value at the window's center. Abraham Savitzky and Marcel Golay published it in Analytical Chemistry in 1964 to clean noisy spectra. Their key observation was that, for evenly spaced data, the fit collapses into a fixed set of weights: the filter is a weighted moving average whose coefficients depend only on the window length and the polynomial degree.
That is the source of its reputation for preserving peaks. A centered SMA is the degree-zero (and degree-one) case and flattens every peak it spans; a quadratic or quartic fit can bend with the data, so turning points keep more of their height and width at the same window length, at the cost of passing more noise. On a price chart the centered form needs bars on both sides, so its newest values are provisional and revise as bars arrive, the end-point problem it shares with LOESS and the Whittaker–Henderson smoother.
How it's calculated
A centered least-squares polynomial fit, equivalent to a fixed weighted average over the window.
Degrees 2 and 3 give identical center weights, as do degrees 0 and 1 (the plain centered average).
The centered form uses m future bars, so the newest m values revise; evaluating the fit at the newest bar of a trailing window is causal, and with degree 1 that endpoint fit is the LSMA.
Other weight sets from the same fit return smoothed first and second derivatives.
How traders use it
- As a peak-preserving smoother for analysis, where the height and timing of past swings matter, such as cycle studies and swing labeling.
- As a derivative estimator: smoothed slope and curvature from the same fit feed momentum and trend acceleration reads with less noise than raw differences.
- As an oscillator pre-filter: a short, low-degree window removes jitter while keeping turning points near where they occurred, provided the end-point revisions are handled.
Savitzky-Golay filter vs related smoothers
LSMA: The LSMA fits a straight line to a trailing window and plots its endpoint. Savitzky-Golay usually fits a curve and plots the center; its causal endpoint form with degree one is the LSMA.
LOESS Smoothing: LOESS refits a distance-weighted local polynomial at every point, which suits uneven spacing and, in its robust form, outliers. Savitzky-Golay uses an unweighted fit on evenly spaced data, which collapses into one fixed set of coefficients.
Windowed FIR Smoothing: Both are fixed-weight symmetric FIR filters. Tapered windows keep every weight positive and smooth harder; from degree 2 up, Savitzky-Golay weights turn negative near the edges, which is what lets them preserve peaks.
Savitzky-Golay Filter FAQ
Turn Savitzky-Golay Filter into a trading strategy.
Open the implementation from this page in Vela. Quant, our coding agent, builds the strategy with you and backtests it on real data.
Browse this familyTrend104 concepts mapped · 104 in the Library
- Adaptive-lookback MA
- ADX / DMI System
- Alligator
- ALMA
- Anchored MA
- Andrews' Pitchfork
- Aroon
- ATR Trailing Regime
- Bessel Filter
- Breakout
- Butterworth Filter
- Chande Kroll Stop
- Chandelier Stop
- Chebyshev Filters
- Climactic Moves
- Continuation
- Coral Trend
- Correlation Trend Indicator
- Death Cross
- DEMA
- Displaced MA
- Donchian Trend Rules
- Dynamic S/R Via MA
- Ehlers Instantaneous Trendline
- Ehlers SuperSmoother
- Elastic Volume-weighted MA
- Elliptic Filter
- EMA
- Fan Principle
- FRAMA
- Gann Box
- Gann Fan & Angles
- Gann HiLo Activator
- Gann Method
- Gann Square of 9
- Gaussian Filter
- Geometric MA
- Golden Cross
- Guppy GMMA
- Halftrend
- Harmonic MA
- Higher-timeframe Trend Filter
- HMA
- Ichimoku Signals
- Ichimoku System
- Ichimoku Theories
- JMA
- KAMA
- Kaufman Efficiency Ratio
- Laguerre Filter
- Linear-regression Channel
- LSMA
- MA Envelope
- MA of MA
- MA Ribbon
- MA Slope Filter
- MAMA/FAMA
- McGinley Dynamic
- MLMA
- Moving Average Crossovers
- NRTR
- Order-statistic Filters
- Parabolic SAR
- Parallel Channel
- Polynomial Regression Band
- Pullback
- R-squared Trend Fit
- Rainbow MA Stack
- Random Walk Index
- Range Filter
- Retest
- Reversal
- RMA
- Savitzky-Golay Filter
- Sine-weighted MA
- SMA
- Speed Resistance Lines
- Standard-error Channel
- Supertrend
- Swiss Army Knife Filter
- SWMA
- T3
- TEMA
- TRAMA
- Trend Acceleration/inflection
- Trend Exhaustion
- Trend Intensity Index
- Trend Magic
- Trend Regime Label
- Trend-quality Composites
- Trendline
- Triangular MA
- UHL Adaptive MA
- Ultimate Smoother
- Vertical Horizontal Filter
- VIDYA
- Volume-adjusted MA
- Vortex
- VWMA
- Weinstein Stage Analysis
- Whittaker–Henderson Smoother
- Windowed FIR Smoothing
- WMA
- ZLEMA
