The arithmetic average of the last N closing prices, weighted equally. The slowest of the standard moving averages, and the cleanest reference for long-horizon trend.
SMA(50) and SMA(200) on MES daily
What it measures
- Trend baseline. Where price has been on average over the lookback window — a stable reference that doesn't whip around.
- Equal-weight history. Unlike EMA, every bar inside the window contributes the same amount. A spike 50 bars ago counts the same as the most recent close.
- Long-horizon regime. SMA(200) on a daily chart is the textbook "is the market in a bull or bear regime" question.
Formula
How AlgoLift computes it
SMA[i] = (price[i] + price[i−1] + … + price[i−period+1]) / period
Every bar inside the window contributes 1/period of the result. There's no weighting, no decay, no smoothing constant. When a bar drops out of the window on the next tick, its influence vanishes completely — which is why SMA can "jump" slightly when a particularly high or low bar exits the lookback.
Inputs in AlgoLift
| Setting | Default | Range | Notes |
|---|---|---|---|
| Period | 20 | 1–500 | Lookback in bars. The most common values across strategies are 20, 50, 100, and 200. |
Recommended periods
- 20: Short-term trend on intraday charts. Roughly one trading day's worth of 30-minute bars.
- 50: Medium-term trend. The de-facto "intermediate trend" line on daily charts.
- 200: Long-term regime. The classic "bull market = above 200-SMA, bear market = below" filter for equities and equity index futures.
Outputs in AlgoLift
| Handle | Type | Plotted | Notes |
|---|---|---|---|
| SMA Value | Numeric | Always | The SMA line. Comparable directly to price. |
| Slope | Numeric | On select | Bar-over-bar change in SMA. Cleaner than the EMA slope because the underlying line is itself smoother. |
SMA node — default state
How to read it
- Price above SMA: Average of recent closes is below current price. Up-state.
- Price below SMA: Down-state.
- Rising SMA slope: Average is climbing — trend continues.
- Falling SMA slope: Average is dropping — trend is fading or reversing.
- Price crossing SMA: Less informative on its own than an EMA crossover because the SMA is too slow to react in real time. Best used with confirmation.
The most useful comparison is SMA vs. EMA at the same period. The EMA leads; the SMA lags. When they diverge significantly, the market is moving fast in one direction. When they're stacked tightly, the market is going sideways.
Use SMA when you want a stable reference, not a fast one. Long-period SMAs are the cleanest regime filter in trading. Short-period SMAs are usually outperformed by EMA at the same length.
Best in / worst in
Best in regime classification (price above/below SMA(200)), high-noise instruments where you need the smoothing, and as a baseline for Bollinger Bands — which are built on SMA + standard deviation by default.
Worst in fast intraday execution. SMA's equal weighting means it lags real changes by roughly half the period. A 50-SMA on 5m bars is reacting to what happened 2 hours ago.
Three setups
1. Trend regime filter
Use SMA(200) as the highest-level switch. Strategies only fire in the direction of the long-term trend.
- Long-only mode: Price > SMA(200) — strategy is permitted to take long entries.
- Short-only mode: Price < SMA(200) — strategy is permitted to take short entries.
- Flat: Price within 0.5% of SMA(200) — no entries either direction.
This single filter dramatically reduces drawdowns on trend-following strategies in mainstream instruments.
SMA(200) as a long-only / short-only regime gate
2. Golden cross / death cross
Long-term trend change signal using SMA(50) crossing SMA(200) on a daily chart.
- Golden cross: SMA(50) crosses above SMA(200) — bullish regime begins.
- Death cross: SMA(50) crosses below SMA(200) — bearish regime begins.
These fire ~once or twice per year on major indices. Not a trading signal, a regime-shift detector.
3. Mean-reversion target
Price stretched far from a slow SMA tends to revert. A common pattern:
- Enter long when price closes more than 2 standard deviations below SMA(50) — also known as crossing the lower Bollinger Band.
- Target the SMA(50) value itself as the exit. Stop below the recent swing low.
The setup works best on range-bound instruments and fails badly during trend extensions.
Advanced patterns in AlgoLift
SMA(200) as a hard kill-switch for trend-following strategies. Connect an SMA(200) comparison directly into your strategy's entry condition AND gate. A bear-regime hard-stop on a momentum strategy can prevent most of the catastrophic drawdowns these strategies suffer during extended downturns. See risk management.
SMA on a higher timeframe with EMA execution. Use SMA(50) on a 1h or daily timeframe as the regime filter, and use a faster EMA on a 5m execution chart for entries. The slow stability of SMA pairs naturally with the responsiveness of EMA. Wire both as separate data series in the Visual Builder.
SMA(50) on daily gating EMA(20) crossover on 5m
Common mistakes
- Using a short SMA for fast decisions. A 5-period SMA on 1m bars is responding to the average of the last 5 minutes — it's never going to feel "fast." Pick the right tool: EMA, DEMA, or HMA all react quicker at the same period.
- Treating golden/death crosses as entry triggers. They're regime markers, not signals. The actual entries should come from a faster system that respects the regime.
- Ignoring the equal-weight property. A single huge bar 49 days ago still pulls SMA(50) until it falls out of the window. Some chop near the SMA is sometimes just an old extreme dropping off.