Or try with a sample dataset:

A moving average smooths a time series by replacing each observation with the average of the surrounding window of w observations, reducing short-term noise and making the underlying trend more visible. The most common type is the simple moving average (SMA): the mean of the w most recent observations, all weighted equally. The exponential moving average (EMA) applies geometrically decreasing weights to older observations, giving more influence to recent values — it reacts faster to new trends than the SMA of the same nominal window. The weighted moving average (WMA) applies explicit custom weights (typically linearly decreasing) that the user specifies. Each type makes a different tradeoff between lag (how quickly the average tracks the true signal) and smoothness (how much short-term noise is suppressed).
Moving averages are the foundation of a wide range of analytical workflows. In trend analysis, a long-window SMA (e.g. 200-day) defines the primary direction of a time series — values consistently above the SMA indicate an uptrend; below indicates a downtrend. In crossover analysis, two moving averages of different window lengths signal trend reversals: when a fast SMA crosses above a slow SMA (a golden cross), the short-term momentum is accelerating relative to the long-term trend; when the fast crosses below (a death cross), momentum is decelerating. In deseasonalization, a 12-month SMA applied to monthly data exactly removes annual seasonality, leaving a cleaner trend signal. In epidemiology, 7-day moving averages smooth out day-of-week reporting patterns in daily case counts.
The window size is the critical parameter: a small window (e.g. SMA-5) tracks the data closely but retains much noise; a large window (e.g. SMA-50) is smooth but lags behind genuine trend changes by roughly w/2 periods. The deviation oscillator — the difference between the raw series and its moving average — separates the trend from the short-term fluctuations, showing how far above or below the average the current value is. Values consistently above the moving average indicate a bullish or above-trend environment; values persistently below indicate weakness.
| Column | Description | Example |
|---|---|---|
date | Date or time index | 2020-01-01, 2020-01, Jan 2020 |
value | Numeric time series | 245.3, 312.1, 198.8 |
Any column names work — describe them in your prompt. For financial OHLC data, specify which column to smooth (close price, volume, etc.).
| Output | What it means |
|---|---|
| SMA(w) | Mean of the w most recent observations — equal weight to all; lags by w/2 periods |
| EMA(span) | Exponentially weighted mean — recent observations weighted more; lower lag than SMA |
| WMA(w) | Linearly weighted mean — most recent observation gets weight w, second most recent w−1, etc. |
| Golden cross | Fast MA crosses above slow MA — short-term momentum accelerating upward |
| Death cross | Fast MA crosses below slow MA — short-term momentum decelerating |
| Deviation oscillator | Raw − SMA — positive = above trend, negative = below trend |
| Lag | The moving average trails real changes by approximately (w−1)/2 periods |
| Window size tradeoff | Larger w = smoother but more lag; smaller w = reactive but noisy |
| Scenario | What to type |
|---|---|
| Basic smoothing | SMA(7) and SMA(30) overlaid on daily data; which window best shows the underlying trend? |
| EMA vs SMA comparison | compare SMA(20) and EMA(20) on the same chart; annotate where EMA reacts faster to the trend reversal |
| Crossover signals | SMA(5) and SMA(20) crossover signals; annotate golden and death crosses; table of crossover dates |
| Deseasonalization | 12-month SMA to remove annual seasonality from monthly data; plot deseasonalized series |
| Multiple windows | SMA(3), SMA(7), SMA(14), SMA(30) overlaid; which window loses the least detail while still smoothing? |
| Deviation analysis | SMA(20); plot deviation oscillator (raw − SMA); flag months where deviation > 2 standard deviations |
adjust=False for standard exponential smoothing behaviorUse the Moving Median Filter when your data contains isolated spike outliers that would distort the mean — the median is more robust to extreme values. Use the Time Series Decomposition tool when you want to formally separate trend, seasonal, and residual components rather than just smoothing. Use the Trendline Calculator to fit a parametric (linear or exponential) trend curve rather than a nonparametric moving average. Use the Seasonality Analysis tool to analyze the seasonal pattern that a 12-month moving average removes.
What is the difference between SMA, EMA, and WMA?SMA (simple moving average) gives equal weight to all w observations in the window — it is straightforward but lags true changes by (w−1)/2 periods. EMA (exponential moving average) uses geometrically decaying weights so recent observations matter more; for a given nominal window size, the EMA reacts roughly twice as fast as the SMA to new data. WMA (weighted moving average) applies explicit linear weights (most recent = w, previous = w−1, …, oldest = 1) — a middle ground between SMA and EMA. In practice, SMA is the standard for trend identification and deseasonalization; EMA is preferred when faster reaction to recent data is important; WMA is less common but useful when you want a specific weight decay profile.
How do I choose the right window size? The window size should match the timescale of the noise you want to remove. For daily data with a weekly reporting cycle, a 7-day window removes day-of-week effects. For monthly data with an annual seasonal pattern, a 12-month window deseasonalizes. For identifying long-run trends, use a window equal to roughly one-third to one-half of the data span. A practical approach: plot the series with several window sizes (5, 10, 20, 50) and choose the smallest window that produces a visually smooth trend — the smallest window minimizes lag while achieving your smoothing goal.
What is a golden cross and should I trust it as a trading signal? A golden cross occurs when a short-window moving average (e.g. SMA-50) crosses above a long-window moving average (e.g. SMA-200), signaling that recent momentum is stronger than the long-run average. A death cross is the reverse. These are widely followed technical indicators in financial markets, but they are lagging signals — they confirm a trend that has already started rather than predicting it, and they generate many false signals in sideways markets. For scientific and business data, crossover signals are most useful as a simple visual marker for regime changes, not as predictive indicators. Always validate against domain knowledge.
Why does my moving average look flat or have a gap at the start?
Flat values at the start occur when the rolling window uses min_periods=w (requires a full window before computing) — the first w−1 positions are NaN. Set min_periods=1 to start computing from the first observation using partial windows, or accept the NaN gap. The partial-window averages at the start have lower effective sample sizes and are less reliable — plot them in a lighter color or omit them from analysis. For EMA, no gap occurs because the calculation is recursive from the first point.