How it is calculated
Over the last length bars the newest price weighs length, the one before length minus 1, down to 1 for the oldest. The weighted sum is divided by the sum of the weights, length times (length + 1) / 2. Prices older than the window drop out completely. The first value comes once length bars are in, as TA-Lib's WMA.
Reference: TA-Lib WMA
How to read it
It turns sooner than an SMA or EMA of the same length, its average lag being about a third of the window instead of a half. Slope and the side price is on give the trend; like every average it lags and whipsaws in a range.
In a strategy
A quicker trend line or crossover partner: the close against ctx.ind("wma", length=20), or a cross of a short and a long WMA as entry signal.
Inputs
| Input | Type | Default | Range or choices |
|---|---|---|---|
Lengthlength | Whole number | 20 | min 1, max 5000 |
Sourcesource | Price | "close" | close, open, high, low, hl2, hlc3, ohlc4, hlcc4 |
What it draws
| Line | Drawn as |
|---|---|
| WMA | Line |
Used in
No strategy template reads it yet.