Systemicbeta

Simple Moving Average

systemic:core-smaIndicators

Inputs

NameTypeDescription
WindowWhole numberThe number of bars in each average (the look-back length).
PriceNumber seriesThe series of numbers that the moving average smooths.

Outputs

NameTypeDescription
SMANumber seriesThe smoothed average series, with one value for each input bar.

Cost

6
credits per run
1,000
bars

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.

SMAn=1n∑i=1nPiSMA_n = \frac{1}{n}\sum_{i=1}^{n} P_i

The formula is simple: divide the sum of the last nn prices by nn. Every price gets equal weight. With n=20n = 20, 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:

  1. The oldest price leaves the window
  2. The newest price enters the window
  3. 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 - 1 bars 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

WindowHorizonWhat Traders Watch For
10Short-termMomentum shifts, quick reactions
20Short-termSwing trading entries, mean reversion
50Medium-termInstitutional interest, trend confirmation
100Medium-termMajor trend health
200Long-termBull/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 ActionSignalInterpretation
Price crosses above SMABullishMomentum shifting upward
Price crosses below SMABearishMomentum shifting downward
Price bounces off SMA from aboveSupportUptrend intact
Price rejected at SMA from belowResistanceDowntrend intact

Golden Cross & Death Cross

The best-known SMA signals use two moving averages:

PatternDefinitionSignificance
Golden Cross50 SMA crosses above 200 SMAMajor bullish signal; often marks the start of a bull market
Death Cross50 SMA crosses below 200 SMAMajor 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:

PerspectiveLag Is A Problem When...Lag Is An Advantage When...
TradingYou need precise entry/exit timingYou want to filter out false moves
Trend FollowingTrends are short-livedTrends are long and sustained
VolatilityMarkets are choppyMarkets 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:

  1. Confirm the uptrend (price above 200 SMA)
  2. Wait for a pullback to the 20 or 50 SMA
  3. 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

CharacteristicSMAEMA
Weight distributionEqualExponentially decaying
ResponsivenessSlowerFaster
LagMoreLess
Noise filteringBetterWorse
Best forTrend definitionSignal timing

The SMA is simpler but not inferior. The choice depends on your goal.


Summary

AspectDetail
Full NameSimple Moving Average
PurposeSmooth price data to reveal underlying trend
FormulaSMAn=1n∑i=1nPiSMA_n = \frac{1}{n}\sum_{i=1}^{n} P_i
Key InsightEqual weighting = objective and stable
Classic SignalsPrice crossovers, Golden/Death Cross
StrengthNoise reduction, widely watched
WeaknessLagging, whipsaws in ranges
Common Windows10, 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]
DimensionStocks/MacroCryptoNotes
Popularity10/1010/10Probably the most widely used indicator; available on virtually every trading platform
Reliability7.5/106/10Good in trending markets; generates whipsaws in ranges. Crypto's higher volatility causes more false signals
Complexity1/101/10Simple arithmetic: sum and divide. The window is the only setting
Versatility9/108/10Works on any asset, any period. Crypto's 24/7 markets change what a "day" means slightly
Recent Interest7/107/10Steady 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.


Further Reading

Rendering diagrams...
© 2026 WanoLabs. All rights reservedBeta v0.1.5