Simple Moving Average
systemic:core-smaIndicatorsInputs
| Name | Type | Description |
|---|---|---|
| Window | Whole number | The number of bars in each average (the look-back length). |
| Price | Number series | The series of numbers that the moving average smooths. |
Outputs
| Name | Type | Description |
|---|---|---|
| SMA | Number series | The smoothed average series, with one value for each input bar. |
Cost
0.201 + 0.00566·n credits for n bars, rounded up. The marks are each plan's limit of bars.
The Art of Smoothing
In 1833, the Bank of England had a problem: how to report its bullion reserves without showing the daily swings that might alarm the public. Its solution was to average the numbers over time. This technique is the moving average.
Nearly two centuries later, the same principle is used on trading charts everywhere: the average shows the trend that noise hides.
The formula is simple: divide the sum of the last prices by . Every price gets equal weight. With , the latest price matters exactly as much as the price from 19 bars earlier.
Why Equal Weight Matters
The SMA treats all values in its window as equally important. This is a deliberate choice, not a limitation:
- Equal weight = stable memory. The SMA does not favor recent values over older ones. This gives stability but adds lag.
- No weighting choices. Everyone calculates the same SMA from the same data.
- The 200-day SMA as consensus. When many traders watch the same line, it becomes a self-fulfilling reference point.
This is why the 50-day and 200-day SMAs are standards: not because they are mathematically optimal, but because so many traders watch them.
The Rolling Window
flowchart LR
subgraph Window["Rolling Window (n bars)"]
direction TB
P1["P₁"]
P2["P₂"]
Dots["···"]
Pn["Pₙ"]
end
Window --> Sum["Sum"] --> Divide["÷ n"] --> SMA["SMA Value"]
On each new bar:
- The oldest price leaves the window
- The newest price enters the window
- A new average is calculated
This creates the typical "lag": the SMA always trails the price because it averages past data.
Missing Data
A window of N bars means N bars that have a value. A bar with no data (for example a weekend on a stock series) is skipped when the window is built. Friday and Monday count as neighboring bars; the gap is never treated as zero or as a repeated value.
- Gaps are skipped: the window always holds N real values. A gap does not shrink the window and is not averaged as if it were a real bar.
- Warm-up is empty: the first
window - 1bars that have a value give no SMA. The module never returns an average of fewer bars than the window. - Gap bars stay empty: a bar with no input value gives no SMA. No value is filled in.
- Enough bars are required: the run fails if the window is larger than the number of input bars.
Standard Windows and Their Meanings
| Window | Horizon | What Traders Watch For |
|---|---|---|
| 10 | Short-term | Momentum shifts, quick reactions |
| 20 | Short-term | Swing trading entries, mean reversion |
| 50 | Medium-term | Institutional interest, trend confirmation |
| 100 | Medium-term | Major trend health |
| 200 | Long-term | Bull/bear market definition, major support/resistance |
💡 The 200-day SMA is one of the most watched lines in finance. Many define a bull market as price above the 200 SMA and a bear market as price below it.
Trading Signals
Price Crossovers
| Price Action | Signal | Interpretation |
|---|---|---|
| Price crosses above SMA | Bullish | Momentum shifting upward |
| Price crosses below SMA | Bearish | Momentum shifting downward |
| Price bounces off SMA from above | Support | Uptrend intact |
| Price rejected at SMA from below | Resistance | Downtrend intact |
Golden Cross & Death Cross
The best-known SMA signals use two moving averages:
| Pattern | Definition | Significance |
|---|---|---|
| Golden Cross | 50 SMA crosses above 200 SMA | Major bullish signal; often marks the start of a bull market |
| Death Cross | 50 SMA crosses below 200 SMA | Major bearish signal; often marks the start of a bear market |
flowchart LR
subgraph GoldenCross["🟢 Golden Cross"]
G1["50 SMA rising"]
G2["Crosses above 200 SMA"]
end
subgraph DeathCross["🔴 Death Cross"]
D1["50 SMA falling"]
D2["Crosses below 200 SMA"]
end
G1 --> G2
D1 --> D2
⚠️ Caveat: These crosses lag. When a Golden Cross appears, much of the move may already be priced in. Use them for trend confirmation, not timing.
The Lag Problem—Or Is It?
Critics often dismiss the SMA because it "lags." But lag is part of its purpose:
| Perspective | Lag Is A Problem When... | Lag Is An Advantage When... |
|---|---|---|
| Trading | You need precise entry/exit timing | You want to filter out false moves |
| Trend Following | Trends are short-lived | Trends are long and sustained |
| Volatility | Markets are choppy | Markets are trending cleanly |
The SMA is not designed for timing. It is designed for trend identification and noise reduction. If you need faster signals, consider the EMA or another weighted average.
Multiple SMA Systems
Traders often combine several SMAs so that signals confirm each other:
The "Perfect Order" Setup:
- Price > 20 SMA > 50 SMA > 200 SMA = Strong uptrend
- Price < 20 SMA < 50 SMA < 200 SMA = Strong downtrend
Pullback Trading:
- Confirm the uptrend (price above 200 SMA)
- Wait for a pullback to the 20 or 50 SMA
- A bounce in the direction of the trend is the entry signal
When It Excels
- Strong trending markets — The SMA keeps you on the right side
- Long periods — Daily and weekly bars, where noise matters less
- Widely followed stocks — Where many participants watch the same levels
- Confirming other signals — As a filter for entry and exit signals from other indicators
When It Struggles
- Sideways or choppy markets — Generates whipsaws and false signals
- Fast-moving markets — Lag means late entry and exit signals
- Short periods — Too much noise relative to trend
- Volatile assets — May never provide clean signals
A Brief Note on SMA vs. EMA
| Characteristic | SMA | EMA |
|---|---|---|
| Weight distribution | Equal | Exponentially decaying |
| Responsiveness | Slower | Faster |
| Lag | More | Less |
| Noise filtering | Better | Worse |
| Best for | Trend definition | Signal timing |
The SMA is simpler but not inferior. The choice depends on your goal.
Summary
| Aspect | Detail |
|---|---|
| Full Name | Simple Moving Average |
| Purpose | Smooth price data to reveal underlying trend |
| Formula | |
| Key Insight | Equal weighting = objective and stable |
| Classic Signals | Price crossovers, Golden/Death Cross |
| Strength | Noise reduction, widely watched |
| Weakness | Lagging, whipsaws in ranges |
| Common Windows | 10, 20, 50, 100, 200 (depends on context) |
Indicator Assessment
%%{init: {"quadrantChart": {"titleFontSize": 16}}}%%
quadrantChart
title SMA Indicator Assessment
x-axis Low Complexity --> High Complexity
y-axis Low Reliability --> High Reliability
quadrant-1 Complex but Reliable
quadrant-2 Simple and Reliable
quadrant-3 Simple but Unreliable
quadrant-4 Complex and Unreliable
SMA - Stocks: [0.15, 0.75]
SMA - Crypto: [0.15, 0.60]
| Dimension | Stocks/Macro | Crypto | Notes |
|---|---|---|---|
| Popularity | 10/10 | 10/10 | Probably the most widely used indicator; available on virtually every trading platform |
| Reliability | 7.5/10 | 6/10 | Good in trending markets; generates whipsaws in ranges. Crypto's higher volatility causes more false signals |
| Complexity | 1/10 | 1/10 | Simple arithmetic: sum and divide. The window is the only setting |
| Versatility | 9/10 | 8/10 | Works on any asset, any period. Crypto's 24/7 markets change what a "day" means slightly |
| Recent Interest | 7/10 | 7/10 | Steady interest. Not trendy but never obsolete |
Assessment Rationale
Popularity (10/10): The SMA is one of the oldest technical indicators. It predates modern computing, appears on every charting platform and is the base of other indicators (Bollinger Bands, envelopes).
Reliability (7.5/10 Stocks, 6/10 Crypto): In trending markets, the SMA keeps traders on the right side of major moves. The 200-day SMA has long been used to separate bull and bear markets. In ranging or choppy conditions, it generates many whipsaws. Crypto markets, with higher volatility and more frequent regime changes, see more false signals.
Complexity (1/10): This is as simple as indicators get. The formula needs only addition and division: no smoothing factors, no weights, no multi-step calculation.
Versatility (9/10 Stocks, 8/10 Crypto): The SMA works on any asset class and any period: equities, forex, commodities and cryptocurrencies. The score is slightly lower for crypto because 24/7 trading changes what a "daily" bar means.
Recent Interest (7/10): Interest in the SMA is steady. It is neither trendy nor obsolete: every generation of traders learns it and uses it.