ta.wma() - Pine Script Function
ta.wma()
Section titled “ta.wma()”Overview
Section titled “Overview”The wma function returns weighted moving average of source for length bars back. In wma weighting factors decrease in arithmetical progression.
Syntax
Section titled “Syntax”ta.wma(source, length) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| source | series int/float | Series of values to process. |
Returns
Section titled “Returns”Weighted moving average of source for length bars back.
Remarks
Section titled “Remarks”- na values in the source series are ignored.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("ta.wma")plot(ta.wma(close, 15))// same on pine, but much less efficientpine_wma(x, y) => norm = 0.0 sum = 0.0for i = 0 to y - 1 weight = (y - i) * y norm := norm + weight sum := sum + x[i] * weight sum / normplot(pine_wma(close, 15))