Weighted Moving Average
systemic:core-wmaIndicatorsInputs
| Name | Type | Description |
|---|---|---|
| Window | Whole number | The number of bars included in each WMA value. |
| Price | Number series | The series of numbers to smooth, usually closing prices. |
Outputs
| Name | Type | Description |
|---|---|---|
| WMA | Number series | The weighted average of the last `window` bars at each bar, with linear weights that favor recent values. |
Cost
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.
With linear weights, : the oldest bar gets weight 1 and the most recent bar gets weight (the Window).
The Mathematics: Why Linear Weights?
Expanded Formula
For an -bar WMA, the formula expands to:
The denominator is the triangular number formula:
For example, a 5-bar WMA divides by .
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
| Position | Age | Weight | Percentage of Total |
|---|---|---|---|
| 1 | Oldest | 1 | 6.7% |
| 2 | 2 | 13.3% | |
| 3 | Middle | 3 | 20.0% |
| 4 | 4 | 26.7% | |
| 5 | Newest | 5 | 33.3% |
| Total | 15 | 100% |
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
| Day | Price | Weight | Price × Weight |
|---|---|---|---|
| 1 | $100 | 1 | $100 |
| 2 | $102 | 2 | $204 |
| 3 | $101 | 3 | $303 |
| 4 | $104 | 4 | $416 |
| 5 | $103 | 5 | $515 |
| Sum | 15 | $1,538 |
Compare to SMA:
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
| Aspect | SMA | WMA | EMA |
|---|---|---|---|
| Weight scheme | Equal (1/n each) | Linear (1, 2, ..., n) | Exponential decay |
| Responsiveness | Slowest | Moderate | Fastest |
| Smoothness | Highest | Moderate | Lowest |
| Memory | None beyond window | None beyond window | Infinite (decaying) |
| Best for | Long-term trends | Balanced analysis | Short-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 - 1bars that have a value are empty, because they do not have a full window behind them. Every later value is a fullwindow-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
| Window | Behavior | Typical Use |
|---|---|---|
| 5-10 | Very responsive, noisy | Scalping, intraday |
| 10-20 | Quick signals, some noise | Day trading, swing entries |
| 20-50 | Balanced trend following | Swing trading |
| 50-100 | Smooth, delayed signals | Position trading |
| 100-200 | Very smooth, significant lag | Long-term trend identification |
Choosing Your Window
Consider:
- Trading frequency — Shorter windows for more frequent signals
- Asset volatility — Higher volatility may need longer windows to reduce noise
- Clear vs. early signals — Longer windows give clearer but later signals
Trading Applications
1. Trend Identification
| Condition | Interpretation |
|---|---|
| Price > WMA | Bullish bias |
| Price < WMA | Bearish bias |
| WMA slope rising | Uptrend strengthening |
| WMA slope falling | Downtrend strengthening |
| WMA flattening | Trend 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
| Signal | Condition |
|---|---|
| Bullish | Short WMA crosses above Long WMA |
| Bearish | Short WMA crosses below Long WMA |
| Confirmation | Both 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:
- Calculate a 20-bar WMA on daily closes
- Track the difference between consecutive WMA values (WMA slope)
- When slope transitions from positive to near-zero after an uptrend, consider tightening stops
- 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
- Weighted Moving Average - Investopedia — Calculation and basic interpretation
- Weighted Moving Average - Fidelity — Practical applications
- Triangular Numbers - Wikipedia — The math behind the WMA denominator
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]
| Dimension | Stocks | Crypto | Notes |
|---|---|---|---|
| Popularity | 6/10 | 5/10 | Less popular than SMA and EMA; used by traders who want a balanced response |
| Reliability | 7/10 | 6.5/10 | Consistent across asset classes; linear weights behave predictably |
| Complexity | 3.5/10 | 3.5/10 | Simple idea (linear weights), slightly more complex than SMA |
| Versatility | 7/10 | 7/10 | Works on any period and asset; can be paired with other moving averages for crossover strategies |
| Recent Interest | 5/10 | 5/10 | Steady but modest interest; EMA often preferred for its infinite memory |