Weighted moving average
All indicators

LibraryTrend

Indicator

Weighted moving average

An average of recent prices in which the weight falls in a straight line from the newest bar to the oldest.

TrendOn the price2 inputsWMA

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

InputTypeDefaultRange or choices
LengthlengthWhole number20min 1, max 5000
SourcesourcePrice"close"close, open, high, low, hl2, hlc3, ohlc4, hlcc4

What it draws

LineDrawn as
WMALine

Used in

No strategy template reads it yet.

OrionQuant