ta.swma()
Symmetrically Weighted Moving Average
Computes the symmetrically weighted moving average (SWMA) using a fixed 4-bar triangular weight pattern (1:2:2:1). There is no length parameter—the window and weights are defined by the function.
Syntax
ta.swma(source) → series floatArguments
| Parameter | Type | Description |
|---|---|---|
| source | series int/float | Series of values to process. |
Returns
Symmetrically weighted moving average.
Remarks
na values in the source series are included in calculations and will produce an na result.
Code Examples
//@version=6
indicator("ta.swma")
plot(ta.swma(close))
// same on pine, but less efficient
pine_swma(x) =>
x[3] * 1 / 6 + x[2] * 2 / 6 + x[1] * 2 / 6 + x[0] * 1 / 6
plot(pine_swma(close))Trading Applications
Apply symmetric weighting for balanced smoothing
Use as a component in more complex indicator calculations
Reduce noise in price data with fixed 4-bar window
Build custom oscillators with symmetric smoothing
Frequently Asked Questions
Generate ta.swma() Code with AI
Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.swma() and other built-in functions instantly.
Related Pine Script Functions
ta.sma() - Simple Moving Average
Learn how to use ta.sma() in Pine Script. Syntax, parameters, code examples, and trading applications for the Simple Moving Average function.
ta.ema() - Exponential Moving Average
Learn how to use ta.ema() in Pine Script. Syntax, parameters, code examples, and trading applications for the Exponential Moving Average function.
ta.wma() - Weighted Moving Average
Learn how to use ta.wma() in Pine Script. Syntax, parameters, code examples, and trading applications for the Weighted Moving Average function.
ta.vwma() - Volume Weighted Moving Average
Learn how to use ta.vwma() in Pine Script. Syntax, parameters, code examples for the Volume Weighted Moving Average.
ta.alma() - Arnaud Legoux Moving Average
Learn how to use ta.alma() in Pine Script. Syntax, parameters including offset and sigma, code examples for ALMA.