Systemicbeta

Weighted Moving Average

systemic:core-wmaIndicators

Inputs

NameTypeDescription
WindowWhole numberThe number of bars included in each WMA value.
PriceNumber seriesThe series of numbers to smooth, usually closing prices.

Outputs

NameTypeDescription
WMANumber seriesThe weighted average of the last `window` bars at each bar, with linear weights that favor recent values.

Cost

6
credits per run
1,000
bars

0.2 + 0.00569·n credits for n bars, rounded up. The marks are each plan's limit of bars.

The Weighted Moving Average fixes one limit of the Simple Moving Average, which treats all bars equally. Recent prices often say more about current market conditions than older ones. WMA gives each bar a linearly increasing weight, so the most recent price has the highest weight.

WMA=∑i=1n(wi×Pi)∑i=1nwiWMA = \frac{\sum_{i=1}^{n} (w_i \times P_i)}{\sum_{i=1}^{n} w_i}

With linear weights, wi=iw_i = i: the oldest bar gets weight 1 and the most recent bar gets weight nn (the Window).


The Mathematics: Why Linear Weights?

Expanded Formula

For an nn-bar WMA, the formula expands to:

WMAn=1⋅P1+2⋅P2+3⋅P3+⋯+n⋅Pn1+2+3+⋯+nWMA_n = \frac{1 \cdot P_1 + 2 \cdot P_2 + 3 \cdot P_3 + \cdots + n \cdot P_n}{1 + 2 + 3 + \cdots + n}

The denominator is the triangular number formula:

∑i=1ni=n(n+1)2\sum_{i=1}^{n} i = \frac{n(n+1)}{2}

For example, a 5-bar WMA divides by 5×62=15\frac{5 \times 6}{2} = 15.

Why Linear (Not Arbitrary)?

With linear weights, importance falls at a constant rate. Each step back in time lowers the weight by the same amount. This gives:

  • Predictable behavior — You know exactly how much weight each bar has
  • Symmetry — The weight distribution forms a simple triangle
  • Balance — More responsive than SMA, but not as jumpy as exponential weighting

Weight Distribution Visualization

flowchart LR
    subgraph Window["5-Bar WMA"]
        P1["Day 1<br/>Weight: 1<br/>(6.7%)"]
        P2["Day 2<br/>Weight: 2<br/>(13.3%)"]
        P3["Day 3<br/>Weight: 3<br/>(20%)"]
        P4["Day 4<br/>Weight: 4<br/>(26.7%)"]
        P5["Day 5<br/>Weight: 5<br/>(33.3%)"]
    end
    
    subgraph Calc["Calculation"]
        SUM["Σ(Price × Weight)"]
        DIV["÷ 15"]
        WMA["WMA Value"]
    end
    
    P1 --> SUM
    P2 --> SUM
    P3 --> SUM
    P4 --> SUM
    P5 --> SUM
    SUM --> DIV --> WMA

Weight Distribution Table

PositionAgeWeightPercentage of Total
1Oldest16.7%
2213.3%
3Middle320.0%
4426.7%
5Newest533.3%
Total15100%

The most recent price counts 5× more in the average than the oldest price.


Worked Example

Given 5 daily closing prices: $100, $102, $101, $104, $103

DayPriceWeightPrice × Weight
1$1001$100
2$1022$204
3$1013$303
4$1044$416
5$1035$515
Sum15$1,538
WMA=153815=102.53WMA = \frac{1538}{15} = 102.53

Compare to SMA: 100+102+101+104+1035=102.00\frac{100 + 102 + 101 + 104 + 103}{5} = 102.00

The WMA is slightly higher because the recent, higher prices have more weight.


Moving Average Comparison

flowchart TD
    subgraph Types["Moving Average Types"]
        SMA["SMA<br/>Equal weights<br/>All bars = 1/n"]
        WMA["WMA<br/>Linear weights<br/>Recent = n, Oldest = 1"]
        EMA["EMA<br/>Exponential decay<br/>Recent heavily weighted"]
    end
    
    subgraph Response["Price Responsiveness"]
        SLOW["Slowest response<br/>Most lag"]
        MED["Balanced response<br/>Moderate lag"]
        FAST["Fastest response<br/>Least lag"]
    end
    
    SMA --> SLOW
    WMA --> MED
    EMA --> FAST
AspectSMAWMAEMA
Weight schemeEqual (1/n each)Linear (1, 2, ..., n)Exponential decay
ResponsivenessSlowestModerateFastest
SmoothnessHighestModerateLowest
MemoryNone beyond windowNone beyond windowInfinite (decaying)
Best forLong-term trendsBalanced analysisShort-term signals

Missing Data

window counts bars that have a value. An empty bar (weekend, holiday or data gap) is never filled and never replaced by an old value or by zero.

  • Gaps are skipped: the window uses only the bars that have data. A 5-bar WMA across a weekend weights the five most recent trading days. Friday and the following Monday are neighbours, as on a chart.
  • Empty bars stay empty: an empty input bar gives an empty output at the same bar.
  • Warm-up is empty, not zero: the first window - 1 bars that have a value are empty, because they do not have a full window behind them. Every later value is a full window-bar weighted average.

Minimum Data Requirement

If the input has fewer bars than the window, the run fails with an error. If it has enough bars but too few of them have a value, the output stays empty until window bars with a value exist.


Parameter Selection

WindowBehaviorTypical Use
5-10Very responsive, noisyScalping, intraday
10-20Quick signals, some noiseDay trading, swing entries
20-50Balanced trend followingSwing trading
50-100Smooth, delayed signalsPosition trading
100-200Very smooth, significant lagLong-term trend identification

Choosing Your Window

Consider:

  1. Trading frequency — Shorter windows for more frequent signals
  2. Asset volatility — Higher volatility may need longer windows to reduce noise
  3. Clear vs. early signals — Longer windows give clearer but later signals

Trading Applications

1. Trend Identification

ConditionInterpretation
Price > WMABullish bias
Price < WMABearish bias
WMA slope risingUptrend strengthening
WMA slope fallingDowntrend strengthening
WMA flatteningTrend exhaustion or consolidation

2. Dynamic Support/Resistance

In trending markets, the WMA often acts as a dynamic level:

  • Uptrend: Price pulls back to WMA, then bounces (support)
  • Downtrend: Price rallies to WMA, then reverses (resistance)

3. Crossover Strategies

SignalCondition
BullishShort WMA crosses above Long WMA
BearishShort WMA crosses below Long WMA
ConfirmationBoth WMAs sloping in same direction after cross

Real-World Applications

1. Momentum Transition Detection

Linear weighting makes WMA useful for detecting early momentum shifts. When price behavior changes, the WMA responds faster than an SMA.

Application: Watch the WMA slope (rate of change). A WMA that flattens after a long trend often comes before a reversal, before the price itself shows it.

Strategy concept:

  1. Calculate a 20-bar WMA on daily closes
  2. Track the difference between consecutive WMA values (WMA slope)
  3. When slope transitions from positive to near-zero after an uptrend, consider tightening stops
  4. Combine with volume analysis for confirmation

2. Paired WMA for Entry Timing

Two WMAs with different windows balance speed and noise reduction.

Classic pairing: 10-bar WMA (fast) with 30-bar WMA (slow)

Why WMA over SMA for this?: With linear weights, both averages respond more to recent price changes than an SMA of the same window.


Advantages

  • Recent price emphasis — Newer data influences the average more
  • Predictable weighting — Linear weights are intuitive and transparent
  • Balanced response — Faster than an SMA of the same window
  • Works widely — Any asset class and period

Limitations

  • Still lags — All moving averages lag price; WMA lags less than SMA
  • Arbitrary weights — Linear weights do not come from market theory
  • Window dependency — Signals change a lot with the window
  • No infinite memory — Unlike EMA, data beyond the window has zero influence

Further Reading


Indicator Assessment

%%{init: {'theme': 'base', 'themeVariables': { 'cScale0': '#2563eb', 'cScale1': '#7c3aed'}}}%%
quadrantChart
    title WMA Indicator Assessment
    x-axis Low Complexity --> High Complexity
    y-axis Low Reliability --> High Reliability
    quadrant-1 High Value
    quadrant-2 Specialized
    quadrant-3 Limited Use
    quadrant-4 Accessible
    Stocks: [0.35, 0.70]
    Crypto: [0.35, 0.65]
DimensionStocksCryptoNotes
Popularity6/105/10Less popular than SMA and EMA; used by traders who want a balanced response
Reliability7/106.5/10Consistent across asset classes; linear weights behave predictably
Complexity3.5/103.5/10Simple idea (linear weights), slightly more complex than SMA
Versatility7/107/10Works on any period and asset; can be paired with other moving averages for crossover strategies
Recent Interest5/105/10Steady but modest interest; EMA often preferred for its infinite memory
Rendering diagrams...
© 2026 WanoLabs. All rights reservedBeta v0.1.5