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 of EMA_1.
    • EMA_3 is the exponential moving average of EMA_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 a NaN value.
  • tripleEMA() inherits all exponential moving average rules.



The number of points to average.

Data type: Integer


Calculate a five point triple exponential moving average

from(bucket: "example-bucket"):
  |> range(start: -12h)
  |> tripleEMA(n: 5)

Function definition

tripleEMA = (n, 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"])

Set your InfluxDB URL

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.