Returns a four-bar symmetrically weighted moving average with fixed weights 1, 2, 2 and 1 from oldest to newest.
ta.swma takes the last four values of source and computes x[3] / 6 + x[2] * 2 / 6 + x[1] * 2 / 6 + x[0] / 6. The two middle bars count double, which gives a smooth curve with little lag for its size.
There is no length argument. The first value appears on bar number 4, and an na among the last four values makes the result na.
Syntax
ta.swma(source: series int/float) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source | series int/ | required | Series of values to average. |
Returns
series float: the weighted average of the last four values of source, or na on the first three bars.
Remarks
- Use it as a quick smoother before a comparison, for example to take noise out of an oscillator.
Example
//@version=6
indicator("SWMA", overlay = true)
plot(close, "Close", color = color.new(color.gray, 60))
plot(ta.swma(close), "SWMA", color = color.red, linewidth = 2)See also
Runs on Sidechair