Skip to main content

exponentialMovingAverage

Introduced in: v21.11.0 Calculates the exponential moving average of values for the determined time. Each value corresponds to the determinate timeunit. The half-life x is the time lag at which the exponential weights decay by one-half. The function returns a weighted average: the older the time point, the less weight the corresponding value is considered to be. Syntax
Parameters Arguments
  • value — Value. (U)Int* or Float* or Decimal
  • timeunit — Timeunit. Timeunit is not timestamp (seconds), it’s an index of the time interval. Can be calculated using intDiv. (U)Int* or Float* or Decimal
Returned value Returns an exponentially smoothed moving average of the values for the past x time at the latest point of time. Float64 Examples Basic exponential moving average
Query
Response
Example with the bar function
Query
Response
Window function usage with time-based calculation
Query
Response
Last modified on June 19, 2026