Sequences of data tend to have noise in them. No every value is a signal. Analyzing data point after data point doesn't reveal overarching patterns. To detect trends, we take a subset (window) of the data, and average the values it contains. With every new data point obtained, we update the average by discarding the old value and adding the new one. Imagine getting the following sequence to analyze: $ \{ 1, 3, 15, 4, 1, 5, 7, 11, 20, 15 \} $ Let's say you pick the window size to be 3 elements. On day 3, you can start computing the moving average. $ \begin{align} \text{Day 3} = \frac{1 + 3 + 15}{3} = \frac{19}{3} &\approx 6.\overline{3} \\[3mm] \text{Day 4} = \frac{3 + 15 + 4}{3} = \frac{22}{3} &\approx 7.\overline{3} \\[3mm] \text{Day 5} = \frac{15 + 4 + 1}{3} = \frac{20}{3} &\approx 6.\overline{6} \\[3mm] \text{Day 6} = \frac{4+1+5}{3} = \frac{10}{3} &\approx 3.\overline{3} \\[3mm] \text{Day 7} = \frac{1+5+7}{3} = \frac{13}{3} &\approx 4.\overline{3} \\[3mm] \text{Day 8} = \frac{5+7+11}{3} = \frac{23}{3} &\approx 7.\overline{6} \\[3mm] \text{Day 9} = \frac{7+11+20}{3} = \frac{38}{3} &\approx 12.\overline{6} \\[3mm] \text{Day 10} = \frac{11+20+15}{3} = \frac{46}{3} &\approx 15.\overline{3} \end{align} $ It's now day 10. Today's value is $15$, but today's moving average is $15.\overline{3}$ Let's compare the evolution of values with the evolution of the moving average. ```tikz \begin{document} \begin{tikzpicture} \def\downScaleY{4} \definecolor{yellowDuck}{HTML}{FFBB00} \def\values{{1/1},{2/3},{3/15},{4/4},{5/1},{6/5},{7/7},{8/11},{9/20},{10/15}} \def\averages{{3/6.33},{4/7.33},{5/6.66},{6/3.33},{7/4.33},{8/7.66},{9/12.66},{10/15.33}} \draw[thick,->] (0,0) -- (0,20/\downScaleY) node[left=2mm] { Values }; \draw[thick,->] (0,0) -- (10,0) node[right=2mm] { Days }; \foreach \x/\y in \values { \draw[fill, red] (\x,\y/\downScaleY) circle (2pt); } \foreach \x/\y in \averages { \draw[fill, yellowDuck] (\x,\y/\downScaleY) circle (2pt); } \draw[fill, red] (-3,2) circle (.1) node[right=2mm] { Values }; \draw[fill, yellowDuck] (-3,1) circle (.1) node[right=2mm] { Averages }; \end{tikzpicture} \end{document} ``` It's almost a tautology, but you can clearly see there is less volatility in the averages sequence. They form a big picture of the underlying trends in the sequence's value. This means you need to determine how *big* the picture should be, which translates into how many values you need to pick for the moving average. See [[69a - The Moving Average Trade-off (Lag vs Noise)]]. A solution to this problem is to combine different window sizes, typically a fast one and a slow one. This is a [[69b - Moving Average Crossover Strategy]]