Moving Average Calculator
Calculate simple moving averages (SMA) and exponential moving averages (EMA) from time series data. Moving averages smooth out short-term noise to reveal underlying trends, and are widely used in finance, economics, and quality control.
A simple moving average (SMA) is the unweighted mean of the previous n data points. For each new period, the oldest value drops out and the newest value enters the calculation: SMA = (V1 + V2 + ... + Vn) / n. This gives equal weight to all values in the window.
An exponential moving average (EMA) applies more weight to recent observations using a smoothing factor k = 2 / (n + 1). The formula is EMA_today = Value_today * k + EMA_yesterday * (1 - k). This makes the EMA more responsive to recent changes than the SMA, which is why traders often prefer it for short-term analysis.
Choosing the right window size is a trade-off. Shorter windows (e.g., 3-5 periods) respond quickly to changes but may amplify noise. Longer windows (e.g., 20-50 periods) provide smoother curves but lag behind actual trends. In stock trading, the 50-day and 200-day moving averages are classic benchmarks.