SMA
A simple moving average (SMA) is the arithmetic mean of the last N values of a series, usually closing prices, recomputed on every bar. SMA, also known as simple moving average, is a Trend concept. The Library holds 3 implementations, each one ready to run on Vela.
Top SMA indicators
The top custom implementations, built on the original standard SMA formula.
3 total
See the top SMA implementation below on Vela, our next-generation charting platform, then ask Quant to turn it into a strategy you can backtest.
The standard SMA indicator
SMA exactly as classically defined: the faithful reference build of the original formula, free to run in Quant.
What is an SMA?
A simple moving average (SMA) is the arithmetic mean of the last N values of a series, usually closing prices, recomputed on every bar. Each of the N bars carries identical weight, one part in N, so the line smooths bar-to-bar noise into a single trend estimate. The cost of that smoothing is lag: on a steadily trending series the SMA runs roughly half its window length behind price.
Equal weighting gives the SMA one quirk worth knowing: the drop-off effect. The oldest bar exits the window on every new bar, so a single extreme value from N bars ago can move today's average even while current price sits still. Equal weighting is also what the rest of the moving-average lineage exists to change: the EMA shifts weight toward recent bars, and faster designs such as the HMA push further, each trading noise suppression against lag differently.
The SMA matters because it is the reference smoother of technical analysis. The 200-day SMA is among the most watched trend benchmarks in any market, the golden cross and death cross are defined on SMA pairs, and Bollinger Bands build on a 20-period SMA basis. Because so many participants watch the same lines, widely used SMAs can behave like self-reinforcing reference levels, though nothing obliges price to respect them.
How to calculate an SMA
The calculation is a rolling arithmetic mean. Every charting platform automates it, but the mechanics matter for reading the line correctly.
- 1Choose a source and a length. Close is the standard source; common lengths are 20 for short-term work, 50 for intermediate, and 200 for long-term context.
- 2Sum the last N source values and divide by N. That quotient is the SMA value plotted on the current bar.
- 3Advance one bar: the newest value enters the window, the oldest drops out, and the mean is recomputed. The plotted line connects these rolling means.
- 4Read it through slope and position: price holding above a rising SMA is trend-following evidence for longs, price below a falling SMA is the mirror case, and a flat SMA with price whipping across it marks a range where the average carries little information.
How it's calculated
The equal-weighted arithmetic mean of the last n prices, recomputed each bar.
Every bar carries the same weight 1/n, so on a steady trend the SMA lags price by about (n - 1) / 2 bars.
It is defined only once n bars exist; platforms leave earlier bars empty or average the shorter window.
Close is the standard input, but any series can be averaged (open, median price, even another indicator).
How traders use it
- As a trend filter: price above or below a long SMA (the 200-day is the classic) gates which direction a system is allowed to trade, the same role a higher-timeframe trend filter plays across timeframes.
- As a crossover engine: a fast SMA crossing a slow one defines moving average crossovers, including the 50/200 golden and death crosses used as slow regime signals.
- As dynamic support and resistance: widely watched SMAs often see reactions on a first touch (dynamic S/R via MA), though a touched average holds only as often as the trend behind it does.
- As a building block: the 20-period SMA is the default basis of Bollinger Bands, and SMAs at stepped lengths form MA ribbons and envelopes that read trend alignment at a glance.
SMA vs neighboring averages
EMA: Both smooth price, but the EMA applies exponentially decaying weights, so it hugs recent price and turns earlier. The SMA weights all bars equally, which makes it smoother, slower, and subject to old bars dropping out of the window.
WMA: The WMA weights bars linearly, newest heaviest and oldest lightest, so recent action dominates and the line turns sooner than an equal-length SMA. The SMA is the flat-weight special case and the slowest of the family to reflect the newest bar.
VWMA: The VWMA weights each bar by its volume rather than its recency, so heavy-volume bars pull the average toward their price. The SMA treats a quiet bar and a climactic bar identically.
LSMA: The LSMA fits a linear regression through the window and plots its endpoint, an estimate of where the trend says price should be now. The SMA plots the window's mean, which sits near the middle of a trending window rather than its leading edge.
SMA FAQ
Turn SMA into a trading strategy.
Open the top 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
.png&w=3840&q=75)

