Skip to content
Algo Trade Analytics Docs

ta.wma() - Pine Script Function

The wma function returns weighted moving average of source for length bars back. In wma weighting factors decrease in arithmetical progression.

ta.wma(source, length) → series float
NameTypeDescription
sourceseries int/floatSeries of values to process.

Weighted moving average of source for length bars back.

  • na values in the source series are ignored.
//@version=6
indicator("ta.wma")
plot(ta.wma(close, 15))// same on pine, but much less efficientpine_wma(x, y) => norm = 0.0 sum = 0.0
for i = 0 to y - 1 weight = (y - i) * y norm := norm + weight sum := sum + x[i] * weight sum / norm
plot(pine_wma(close, 15))