trima
Syntax
trima(X, window)
Please see TA-Lib Functions for the parameters and windowing logic.
Details
Calculate the Triangular Moving Average (trima) for X in a sliding window of the given length.
The formula is:
\(trima = sma(sma(x, w1), w2)\)
where w1 = (window + 1) / 2
(rounded up); w2 = (window + 1) / 2
(rounded down).
Examples
$ x=12.1 12.2 12.6 12.8 11.9 11.6 11.2
$ trima(x,3);
[,,12.274999999999998,18.625,18.662500000000001,15.225000000000001,11.59375]
$ x=matrix(12.1 12.2 12.6 12.8 11.9 11.6 11.2, 14 15 18 19 21 12 10)
$ trima(x,3);
col1 |
col2 |
---|---|
12.274999999999998 |
15.5 |
18.625 |
24.75 |
18.662500000000001 |
27 |
15.225000000000001 |
22.875 |
11.59375 |
14.875 |