tripleEMA() function
The tripleEMA()
function calculates the exponential moving average of values in
the _value
column grouped into n
number of points, giving more weight to recent
data with less lag than
exponentialMovingAverage()
and doubleEMA()
.
Function type: Transformation
tripleEMA(n: 5)
Triple exponential moving average rules
- A triple exponential moving average is defined as
tripleEMA = (3 * EMA_1) - (3 * EMA_2) + EMA_3
.EMA_1
is the exponential moving average of the original data.EMA_2
is the exponential moving average ofEMA_1
.EMA_3
is the exponential moving average ofEMA_2
.
- A true triple exponential moving average requires at least requires at least
3 * n - 2
values. If not enough values exist to calculate the triple EMA, it returns aNaN
value. tripleEMA()
inherits all exponential moving average rules.
Parameters
n
The number of points to average.
Data type: Integer
Examples
Calculate a five point triple exponential moving average
from(bucket: "example-bucket"):
|> range(start: -12h)
|> tripleEMA(n: 5)
Function definition
tripleEMA = (n, tables=<-) =>
tables
|> exponentialMovingAverage(n:n)
|> duplicate(column:"_value", as:"ema1")
|> exponentialMovingAverage(n:n)
|> duplicate(column:"_value", as:"ema2")
|> exponentialMovingAverage(n:n)
|> map(fn: (r) => ({r with _value: 3.0 * r.ema1 - 3.0 * r.ema2 + r._value}))
|> drop(columns: ["ema1", "ema2"])
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, the following resources are available:
InfluxDB Cloud and InfluxDB Enterprise customers can contact InfluxData Support.