ta.swma() - Pine Script Function
ta.swma()
Section titled “ta.swma()”Overview
Section titled “Overview”Symmetrically weighted moving average with fixed length: 4. Weights: [1/6, 2/6, 2/6, 1/6].
Syntax
Section titled “Syntax”ta.swma(source) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| source | series int/float | Source series. |
Returns
Section titled “Returns”Symmetrically weighted moving average.
Remarks
Section titled “Remarks”- na values in the source series are included in calculations and will produce an na result.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("ta.swma")plot(ta.swma(close))// same on pine, but less efficientpine_swma(x) => x[3] * 1 / 6 + x[2] * 2 / 6 + x[1] * 2 / 6 + x[0] * 1 / 6plot(pine_swma(close))