Skip to content

ResearchEquity Strategy

Use Moving Averages Without Mistaking Lag for Foresight

Chapter 10 · Stock Research from First Principles

Report or archive date
Archive placement July 30, 2026
Reading time
21 min read
The New York Stock Exchange and the surrounding Wall Street streetscape.

Summary

A moving average compresses a sequence of prices into a smoother line. It can help describe direction and reduce the visual distraction of individual observations. It cannot know tomorrow's price, and the smoothing that makes it easier to read also creates delay.

A moving average compresses a sequence of prices into a smoother line. It can help describe direction and reduce the visual distraction of individual observations. It cannot know tomorrow's price, and the smoothing that makes it easier to read also creates delay.

Calculate a simple moving average and an exponential moving average, then compare how each responds when prices cross it repeatedly. The two historical charts use NVIDIA (NVDA) daily prices in U.S. dollars from July through October 2024, the same period used in Chapter 11.

1 What moves in a moving average

A five-period simple moving average, or SMA, is the arithmetic mean of the latest five observations. As a new observation arrives, the oldest leaves the window. “Period” can mean a day, week, hour, or another interval; the formula does not decide which.

Suppose five closing prices are 10, 11, 12, 11, and 14. Their sum is 58, so the five-period SMA at the fifth close is 58 ÷ 5 = 11.60. The next close is 13. The new window is 11, 12, 11, 14, and 13, totaling 61. The SMA becomes 12.20.

The average rose even though the latest price fell from 14 to 13. The reason is that 13 replaced the much lower oldest observation of 10. An average's movement depends on what enters and what leaves, not simply on whether today's close exceeded yesterday's.

New SMA = Prior SMA + (New observation − Dropped observation) ÷ Window length

For this example, 11.60 + (13 − 10) ÷ 5 = 12.20. The update formula is equivalent to recalculating the entire window. It also provides an intuitive explanation of the change.

Keep the window visible while learning the formula

Write the five observations in a row before calculating the first average. Then move the window by exactly one observation. This small practice prevents two common mistakes: retaining six prices while still dividing by five, and removing the previous day's price rather than the oldest price. The SMA summarizes the most recent complete window, not a running total of every price ever observed.

The update formula also provides a quick error check. If the incoming and outgoing prices are equal, the SMA must remain unchanged. If the incoming price is higher, the SMA must rise by their difference divided by the window length. The direction of the previous day's price change is irrelevant to this particular check.

Avoid naming a calculation “five-day” when it uses five calendar dates containing nontrading days filled with repeated values. This chapter's daily examples use eligible trading observations. A five-session calculation spanning a holiday is still five observations even though more than five calendar days may have elapsed. The label should match the data used.

2 Equal weights create a specific kind of memory

Each observation in a five-period SMA receives a weight of 20%. The oldest price has the same weight as the newest until it leaves the window, when its weight drops to zero. A large old observation can therefore affect the average's direction when it disappears.

A longer window includes more history and usually changes more slowly. That can reduce the effect of a single price spike, but it can also delay recognition of a new direction. There is no universally optimal window because the useful tradeoff depends on the question and the behavior of the series.

For a linearly rising sequence, a simple average sits below the current price because it includes older, lower observations. If prices rise exactly $1 each session, a 20-period SMA over a fully developed trend is $9.50 below the latest price. A 50-period SMA is $24.50 below. These gaps follow from the average ages of the observations: 9.5 and 24.5 periods.

The gaps are arithmetic properties of the constant-slope sequence. They do not show that the price must return to the average. Real prices do not move at a constant slope indefinitely.

A single unusual observation can affect two moments

Imagine a separate five-period sequence that is otherwise constant at 100 but includes one close of 120. When that close enters a full window containing four 100 values, the SMA becomes 104. As long as the 120 remains inside the five-observation window and the other observations remain 100, the SMA stays at 104. When 120 finally leaves and another 100 enters, the average returns to 100.

The second movement occurs even though the newest price has not changed from the recent 100 closes. It is the delayed effect of the old observation leaving the calculation. A chart reader who looks only at the latest candle might incorrectly invent fresh market information to explain the average's drop.

This example explains one difference between the SMA's fixed window and the EMA's decaying memory. It is an arithmetic sequence with a deliberately constant rate. Real historical charts in this chapter retain the uneven observations actually recorded, including gaps and reversals, rather than being replaced by this deliberately simple sequence.

3 An exponential average gives more weight to recent data

An exponential moving average, or EMA, updates the previous average by incorporating a fraction of the difference between the latest price and that previous value. A common smoothing factor for an N-period EMA is alpha = 2 ÷ (N + 1).

New EMA = Prior EMA + Alpha × (New price − Prior EMA)

For a five-period EMA, alpha is 2 ÷ (5 + 1) = one-third. In this example, initialize the EMA at observation 5 with the first five-price SMA of $11.60. At observation 6, the new close is $13, so the next EMA is 11.60 + (13 − 11.60) ÷ 3 ≈ $12.0667. The corresponding SMA is $12.20. The EMA result is rounded for display; the calculation retains full precision.

An EMA does not always lie above or below an SMA. Their relationship depends on the sequence and initialization. The EMA's defining property is its weighting structure, not a guaranteed position relative to another line.

The newest observation receives alpha's weight; older influence decays by repeated multiplication by 1 − alpha. Unlike an SMA, old observations do not abruptly disappear after a fixed count. Their remaining influence becomes progressively smaller.

Read the two updates separately. The SMA removes the oldest $10 close and adds the new $13 close, raising the five-price total from $58 to $61 and the average from $11.60 to $12.20. The latest close falls from $14 to $13, but the SMA rises because the incoming $13 is higher than the outgoing $10. The EMA uses its prior value and the new close; it does not remove an old observation from a fixed five-price window.

The diagram shows no SMA before observation 5 because five closes are required for the first complete window. It also starts the EMA at observation 5 because this example uses that first SMA as the EMA seed. Both therefore begin at $11.60. This is an explicit initialization choice, not a missing part of the calculation.

Hypothetical five-period moving-average update. Six closes are 10, 11, 12, 11, 14, and 13 dollars. Removing 10 and adding 13 raises SMA from 11.60 to 12.20 even though the latest close falls from 14 to 13. EMA starts at the first SMA of 11.60, uses weight one-third, and updates to approximately 12.0667.

Continue the six-price example without changing its seed

For practice beyond the diagram, add a seventh close of $12. The five-price SMA window becomes 12, 11, 14, 13, and 12, totaling 62 and producing $12.40. Using the full-precision prior EMA of 12.066666... and alpha of one-third produces a new EMA of approximately $12.0444. The SMA rises while the EMA falls because their memory structures differ.

Add an eighth close of $15. The SMA window becomes 11, 14, 13, 12, and 15, totaling 65 and producing $13.00. The EMA becomes approximately $13.0296. These additional observations are a text exercise; the original six-observation diagram correctly ends at observation 6 and is not missing these later values.

Do not round the seventh EMA to $12.04 before calculating the eighth if the goal is to reproduce the full-precision result. Keep the internal value and round only the displayed answer. Nor should you reseed the EMA with a new SMA whenever the lines cross. Initialization occurs at the defined beginning, after which the update rule continues consistently.

4 Initialization and warm-up affect reproducibility

An EMA needs a starting value. Common implementations use the first observation or an initial SMA. These choices can produce different early values even when later prices and the nominal period are identical. The difference decays over time but should not be ignored near the start of a chart.

If two five-period EMA calculations begin one dollar apart and then receive the same prices, their difference after ten updates is $1 × (2/3)^10, approximately $0.0173. The smoothing factor determines how quickly the initial difference fades.

State the seed, data interval, adjustment basis, and number of prior observations used. A chart that begins at a selected date may still calculate its indicators using earlier data. Displaying only the visible range does not necessarily describe the calculation history.

For the actual-history charts, retain daily observations beginning January 3, 2023, while displaying July 1 through October 31, 2024. The displayed range contains 87 trading sessions, preceded by 374 observations. Each plotted SMA uses its complete 20-session or 50-session window, including closes before the visible left edge. An SMA needs a complete window rather than an EMA seed; the separate six-price EMA example above uses its stated initial SMA.

The historical prices use consistent post-split share units and are not adjusted for cash dividends. Each candle records the actual daily open, high, low, and close; its color compares the close with the open. Dates advance by trading session. Weekends and exchange holidays are omitted, and no missing days are filled with prices. The moving averages use closing prices rather than candle highs, lows, or midpoints.

5 Compare the 20-period and 50-period averages

Start with the same dates in both averages. On July 1, NVDA closed at $124.30; its 20-session SMA was $124.5747 and its 50-session SMA was $105.4136. The longer window contained more of the earlier, lower closes. The separation describes those different samples of past prices.

The relationship changes as the window rolls forward. By August 30, the close was $119.37, the 20-session SMA was $118.0100, and the 50-session SMA was $120.0692. The shorter average was now below the longer average. Read the close, the direction of each line, and the relationship between the two lines as separate observations.

DateClose ($)20-session SMA ($)50-session SMA ($)
2024-07-01124.30124.5747105.4136
2024-07-31117.02121.7555119.8703
2024-08-30119.37118.0100120.0692
2024-09-03108.00118.3875119.6978
2024-09-30121.44115.0550115.9168
2024-10-21143.71129.0890122.3698
2024-10-31132.76136.5395125.2206

September 3 provides a concrete example of a rising average on a falling-price day. The close fell from the prior session's $119.37 to $108.00, but the 20-session SMA increased from $118.0100 to $118.3875. The rolling window dropped the August 5 close of $100.45 and added $108.00. Because the incoming observation exceeded the outgoing observation, the average rose even though the latest close was lower than the previous close.

The update is $118.0100 + ($108.00 − $100.45) ÷ 20 = $118.3875. The average increased by $0.3775 while the stock's close fell by $11.37. Those two changes answer different questions. Always identify which observations are being compared before treating them as a contradiction.

On October 31, the close of $132.76 was below the 20-session SMA of $136.5395 but above the 50-session SMA of $125.2206. A single statement such as “above the moving average” would therefore be incomplete. Specify the window and date, and keep full precision in calculations. Historical moving averages are displayed to four decimal places, with exact halfway values rounded up; the unrounded values determine the crossings.

The historical chart includes gaps, declines, recoveries, and reversals of different sizes. Its 20-session and 50-session averages are calculated from those same actual closes. The smoother lines preserve memory of earlier observations; they do not make the underlying price path smooth or predictable.

Actual NVDA daily OHLC from July 1 through October 31, 2024, with 20-session and 50-session simple moving averages. On September 3, the close fell to $108.00 while SMA 20 rose from $118.0100 to $118.3875 because $108.00 replaced $100.45 in the window.

Describe three separate relationships

A complete moving-average observation can distinguish the close relative to each average, each average's slope, and the shorter average relative to the longer one. These relationships can disagree without any calculation being wrong. A close below the shorter average can coexist with a shorter average still above the longer average, because the two lines retain different portions of earlier prices.

Use the October 31 values to practice that description. The close is below the 20-session average and above the 50-session average. The 20-session average is itself above the 50-session average. Those facts describe the relative levels on that date. Establishing whether either average rose or fell that day requires comparing its value with the previous session, not inferring slope from its position above or below the close.

Similarly, a wide gap between averages describes separation between two historical samples. It is not a measured probability of an imminent reversal. A percentage distance can help compare differently priced securities, but it still requires a defined denominator. “Five dollars above average” and “five percent above average” are different statements, and neither proves that the stock is overvalued on business fundamentals.

6 Crossovers define events, not guaranteed outcomes

A price crossover occurs when price moves from one side of an average to the other under a specified rule. A two-average crossover compares a shorter average with a longer one. Define whether equality counts, whether only closing observations qualify, and when the resulting decision can be executed.

A precise closing rule might require today's close to exceed today's SMA after the prior close was at or below the prior SMA. The signal is known only after the closing data needed for that calculation becomes available. Assuming a purchase at an earlier price in the same session introduces information that was not yet known.

An average crossover can describe a shift in the recent price pattern. It does not identify why the shift occurred or whether it will persist. A business event, a temporary liquidity imbalance, or ordinary noise can all produce a crossing.

Before testing a rule, specify the security universe, data basis, signal condition, execution delay, transaction costs, and treatment of dividends. Without those details, two people can claim to test the same crossover and produce materially different results.

7 Repeated crossings can reverse quickly

Examine the shorter interval from September 9 through September 27, 2024. The chart retains the same fully calculated 20-session SMA rather than restarting its window on September 9. The second panel subtracts that day's SMA from that day's close. Positive bars mean the close is above the average; negative bars mean it is below. Both panels use the same 15 trading sessions.

Count an upward closing crossing only when today's close-minus-SMA difference is positive and the prior session's difference was zero or negative. Count a downward crossing only when today's difference is negative and the prior difference was zero or positive. A close exactly on the average is not, by itself, a new crossing. Use the unrounded values to apply this rule.

Closing dateClose ($)SMA 20 ($)Close minus SMA ($)Crossing
2024-09-12119.14118.92500.2150Above
2024-09-16116.78118.3470-1.5670Below
2024-09-19117.87116.40101.4690Above
2024-09-20116.00116.0140-0.0140Below
2024-09-23116.26115.35850.9015Above

These five closing crossings do not represent five completed trades. The sequence moves above the average on September 12, below it on September 16, above it on September 19, below it on September 20, and above it again on September 23. A particular trading rule would still need an initial position, a feasible execution time, order instructions, position size, and costs before any profit or loss could be calculated.

September 20 is especially useful for checking precision. The close was $116.00 and SMA 20 was $116.0140, leaving a difference of −$0.0140. The difference is small but negative. Rounding both inputs to one decimal place would hide the distinction. The chart uses the full values, so this negative bar is almost invisible at the selected dollar scale rather than being enlarged to resemble a stronger move.

A signal that reverses shortly afterward can create whipsaw for a trend-following rule. That possibility is different from claiming that the whole interval was range-bound or that every crossing lost money. In this sample, the price later moved higher. The chart records changes in the close's position relative to an average; it does not establish the profitability of acting on them.

Keep transaction-cost arithmetic separate from the historical observations. In this example, six completed round trips at $4 each consume $24 before trading gains or losses. Those six trips are not derived from the five closing crossings in the chart. Combining a historical signal count with an unrelated assumed cost count would imply a backtest that has not been performed.

Adding a waiting period or requiring a larger distance above the average may reduce some false signals, but it also delays entry and can miss genuine moves. Every filter changes the tradeoff. Do not describe a modification as a free improvement without testing what it gives up.

Actual NVDA daily candles and SMA 20 from September 9–27, 2024, with close-minus-average bars on a separate linear dollar scale. The close crosses above on September 12, below on September 16, above on September 19, below on September 20, and above on September 23. The September 20 difference is minus $0.0140, with no artificial bar enlargement.

Distinguish an event rule from a position rule

An upward crossing is an event occurring when a relationship changes. A rule to remain invested whenever the close is above an average describes a position condition that can persist across many sessions. Counting every above-average day as a new purchase would confuse the persistent condition with the transition that first established it.

To turn a crossover into a paper strategy, specify the starting state. Is the account initially in cash, already holding shares, or excluded until the first complete signal? Then define what an upward crossing changes, what a downward crossing changes, and whether repeated signals can add to a position. These choices affect exposure, turnover, and measured returns even when the indicator values are identical.

A pending order adds another layer. If a signal occurs at the close but the order does not fill next session, the portfolio has not automatically adopted the desired position. A realistic record distinguishes signal, order, fill, and holding. The historical crossing table in this chapter deliberately stops at the first of those stages. It does not hide an assumed trading strategy inside a descriptive chart.

8 Support and resistance are areas to investigate

Traders sometimes describe a moving average as support or resistance. This means price has tended to find buying or selling interest near it in the observed sample. The average itself does not create a contractual floor or ceiling.

If a company releases materially adverse information, price can move through a familiar average without pausing. A historical association should therefore be described as a possible area of interest rather than a barrier the market must respect.

Specify how the area is defined. A line drawn after observing every reversal can look more precise than a rule available in advance. If the method allows a tolerance band, define the band before inspecting the outcome. Otherwise, nearly any nearby movement can be counted as confirmation.

Business valuation and chart context answer different questions. A price near an average says little about the cash-generating value of the company. It can help describe trading conditions while leaving the fundamental thesis unchanged.

9 Parameter selection can overfit the past

Suppose an analyst tries dozens of window lengths and reports only the pair with the best historical return. The selected result benefits from repeated searching. Some apparent success may arise from chance rather than a stable relationship.

Separate rule development from evaluation. Reserve data or periods not used to choose the parameters, and assess behavior across different conditions. Even then, a favorable result is evidence to examine, not proof of future performance. Structural changes and practical execution can alter outcomes.

Look for stability rather than a single sharp optimum. If a rule works only at one exact parameter but nearby choices fail badly, investigate whether the result depends on a handful of observations. Economic reasoning should accompany statistical evaluation.

Compare against an appropriate simple benchmark using the same cash-flow treatment, costs, and dates. A strategy that reduces time invested may show lower volatility partly because it holds cash. That exposure difference should be visible rather than credited entirely to forecasting skill.

Test a filter by recording what it sacrifices

Suppose a rule requires a close at least 1% above a moving average rather than merely above it. With an average of $100, the threshold is $101. A close of $100.50 satisfies the simple above-average condition but not the 1% condition. If the price then advances to $105 before the next eligible decision, waiting has changed the available entry price.

In another sequence, the $100.50 close might reverse below $100 immediately. The same filter would have avoided a short-lived signal. Both possibilities belong in the evaluation. Reporting only the avoided false crossing would overstate the benefit; reporting only the missed advance would ignore its intended purpose.

Define the band relative to a clear reference value and use data known at the decision time. Do not choose the percentage separately for each episode after inspecting its outcome. Evaluate how the modification changes signal frequency, delay, exposure, and costs across a held-out period. A modification is useful when its tradeoffs suit the research objective, not merely because its chart looks cleaner.

10 Exercises

A. Calculate the four-period SMA of 20, 22, 21, and 25. Update it when the next observation is 24.

B. For a nine-period EMA, calculate alpha. If the prior EMA is 50 and the new close is 55, calculate the updated EMA.

C. Explain how an SMA can rise on a day when the latest close falls.

D. In a fully developed sequence rising exactly $2 each period, how far below the current price is a five-period SMA?

E. A crossover uses today's final close, but a backtest buys at today's opening price. Identify the problem.

F. Why might a longer average keep rising after prices enter a sideways range?

G. Eight round trips cost $3 each. Gross trading profit is $18. Calculate net profit before taxes and explain the implication.

H. Two platforms show different early EMAs using the same period. List three settings to compare before assuming an error.

I. Using the September 3 historical case, update the prior 20-session SMA of $118.0100 when the $100.45 close leaves and the $108.00 close enters. Explain why the average rises while the stock closes lower.

11 Worked answers

A. The initial sum is 88, so the SMA is 22. The new window is 22, 21, 25, and 24, totaling 92, giving 23. The update shortcut is 22 + (24 − 20) ÷ 4 = 23.

B. Alpha is 2 ÷ (9 + 1) = 0.2. The updated value is 50 + 0.2 × (55 − 50) = 51. The EMA moves partway toward the new price rather than replacing its history with that price.

C. The average changes according to the new observation compared with the observation leaving the window. If today's lower close is still above the dropped value, the average can rise. Comparing only today's and yesterday's closes overlooks the window replacement.

D. The observations are current price minus 8, minus 6, minus 4, minus 2, and current price. Their average is $4 below the current price. That equals the $2 slope multiplied by the average observation age of two periods.

E. The rule uses information unavailable at the assumed execution time. A valid test needs a feasible later execution assumption, such as the next session under specified order conditions, and must account for any price gap and costs.

F. Lower historical values may still be leaving the long window while newer range-bound prices are higher. The average's rise describes replacement within its history, not necessarily continued upward movement in current prices.

G. Costs total $24. Net profit is $18 − $24 = −$6. The result shows why a gross trading edge cannot be evaluated without turnover and execution costs. It does not establish what any other strategy would earn.

H. Compare initialization, pre-chart history, price adjustment basis, interval, session coverage, and the chosen price field. Matching only the nominal period is insufficient to establish identical calculations.

I. The update is $118.0100 + ($108.00 − $100.45) ÷ 20 = $118.3875, a rise of $0.3775. The incoming close exceeds the outgoing close even though it is below the prior session's $119.37 close. The average's window replacement and the stock's one-session price change use different comparisons.

Additional workshop: reconstruct the weights

In a separate nine-period EMA example, alpha is 0.2. Starting from a prior EMA of 50, a close of 55 produces 51. If the next close is also 55, the updated EMA is 51 + 0.2 × 4 = 51.8. A third close of 55 produces 52.44. The EMA moves toward the repeated price but does not instantly become 55.

The distance from 55 shrinks by 0.8 each update: from 5 to 4, then 3.2, then 2.56. This offers an independent check on the arithmetic. It also explains why a longer-memory calculation can continue changing after prices become temporarily flat. The line is digesting the difference between its inherited state and the new observations.

Now compare that mechanism with an SMA. The SMA's behavior after the same three prices depends on the particular older observations leaving its window. Knowing only the prior SMA is insufficient unless the outgoing values are also known. By contrast, the stated EMA update requires the prior EMA and the new price. Neither method is inherently more truthful; they summarize history through different weighting rules.

Distinguish smoothing from shifting the line in time

A trailing moving average at today's date uses the latest available window. A centered moving average assigns a window to its midpoint and therefore uses later observations when describing that midpoint. Centering can help a retrospective statistical example, but it cannot be treated as information available at the historical midpoint in a trading rule.

For example, a centered five-observation average placed at observation 3 uses observations 1 through 5. Observations 4 and 5 were not yet known at observation 3. A trailing five-observation average first placed at observation 5 uses the same five values but respects their availability. The numerical average can be identical while the timing interpretation differs fundamentally.

Likewise, shifting a trailing line left on a chart to make it align better with turning points does not eliminate its lag. It changes the display. A historical test must use the value at the time it became available, not its cosmetically shifted position. The drawings in this course retain the stated observation timing so that a visual intersection does not imply foresight.

Separate window choice from the investment horizon

A twenty-session average describes a specific recent window. It does not automatically make a twenty-session holding period appropriate, and a fifty-session average does not guarantee that a signal remains useful for fifty future sessions. The lookback controls the history summarized, while a strategy's holding or review period controls a separate decision rule.

Choosing a longer lookback can make a chart less responsive to individual observations, but that may be useful or harmful depending on the task. A researcher describing broad price context may prefer a slower summary. A study of rapid execution conditions may need different information entirely. The proper choice follows the question, then is evaluated with its limitations visible.

Explain a difference before changing the settings

If two calculations disagree, begin with the simplest possible cause: do they use the same security, date range, interval, and closing-price field? Then compare corporate-action adjustments, pre-chart history, complete-window requirements, and EMA initialization. Only after those inputs agree should a difference be attributed to a formula or software problem.

Keep a small hand-calculated example alongside the historical record. The six-price example provides that anchor: the first SMA is $11.60, the next SMA is $12.20, and the stated EMA seed produces approximately $12.0667 at observation 6. A program that cannot reproduce those values should not be trusted merely because its historical lines look smooth.

The comparison should end with an explanation, not with settings altered until the pictures happen to resemble each other. Matching appearance without matching definitions can conceal an error that reappears in another security or time interval. A reliable method makes both the numbers and the timing reproducible.

12 Record the rule in complete sentences

Before using an average in a paper study, write what it measures, why the rule might be useful, when it can fail, and exactly when an action becomes possible. Chapter 11 combines two exponential averages into MACD while preserving the same requirement for transparent calculations.

ResearchEquity Strategy

Learn Price Charts, Volume, and Adjusted Data

A price chart is a record produced from data choices. Its appearance depends on the trading interval, the price field, the scale, and the treatment of corporate actions. Before interpreting a pattern, establish what the chart actually measures.

ResearchEquity Strategy

MACD: Calculation, Interpretation, and False Signals

MACD transforms two exponential moving averages into a measure of their separation. A second smoothing step creates a signal line, and a subtraction creates the histogram. Understanding those three operations is more useful than memorizing a list of bullish and bearish shapes.

ResearchEquity Strategy

Read Earnings and Industry Events Without Chasing Headlines

A headline tells you that something happened. Research asks what changed, who benefits economically, how much was already expected, and whether the evidence alters a valuation. Those questions are especially important when a popular industry attracts companies with very different products and financial models.