WMA
Source
https://github.com/quadcode-tech/quadcodescript-library/blob/master/averages/ma_wma.lua
Syntax Format
wma(series, period)
Overview
WMA (Weighted moving Average) assigns more weight to more recent price movements. This makes the WMA quicker to react to recent price changes and suitable for short-term strategies.
Parameters
| Parameter | Type | Purpose |
|---|---|---|
| source | series | Input series, taken into calculation |
| period | numeric | Moving Average period |
Returns: series.
Example
instrument { name = "Weighted Moving Average", short_name = "WMA", overlay = true, icon="indicators:MA" }
period = input (9, "period", input.integer, 1)
source = input (1, "source", input.string_selection, inputs.titles_overlay)
input_group {
"WMA Line",
color = input { default = "#56CEFF", type = input.color },
width = input { default = 1, type = input.line_width}
}
local sourceSeries = inputs [source]
plot (wma (sourceSeries, period), "WMA", color, width)
Formula
The formula for calculating WMA is:

In the WMA formula, more recent price changes are given more weight, the “freshest” price value is assigned with a higher i value, reducing it gradually to less recent price changes.