Functions
talib.ema()
The ema function returns the exponentially weighted moving average. In ema weighting factors decrease exponentially. It calculates by using a formula: EMA = alpha * source + (1 - alpha) * EMA[1], where alpha = 2 / (length + 1).
Syntax
talib.ema(series float source, series int length) → series float
Arguments
source required series float Series of values to process. length required series int Number of bars (length). Return Type
series float Example
indicator("EMA Example", overlay=true)
// Define input source and period
src = close
length = 20
// Compute EMA
ema_line = talib.ema(src, length)
// Plot the EMA
plot(ema_line, title="EMA 20", color=color.blue)