wma
Weighted Moving Average
wma(source, periods)
Parameters
| Name | Type | Description |
|---|---|---|
source |
source | Data series to average - price field (close, high, low, open) or indicator output |
periods |
int | Number of periods for the WMA calculation (must be > 0) |
Formula
```
WMA = (P1 * n + P2 * (n-1) + ... + Pn * 1) / (n + (n-1) + ... + 1)
where n = periods, P1 = most recent price, Pn = oldest price
```
The most recent value has weight n, the previous has weight n-1, and so on.
Examples
x = wma(close, 10); # 10-period WMA of closing prices
y = wma(high, 20); # 20-period WMA of highs
close > wma(close, 50); # Price above 50-period WMA
Returns
Float value representing the weighted moving average ## References - TradingView: `ta.wma(source, length)` - More responsive to recent changes than SMA but less than EMA