Technical Analysis

Moving Averages Explained: Calculate SMA and EMA Without Signal Confusion

Periods, source prices, and initialization determine the indicator. Practice: calculate sma and update ema.

Smoothing changes the view. Periods, source prices, and initialization determine the indicator.
November 10, 2026 11 min read

Technical Analysis · Lesson 05 of 15 · Reviewed November 10, 2026

A moving average smooths a sequence of observations so the underlying variation is easier to inspect. The smoothing can help describe recent direction or distance from a reference, but it also delays the response to new information. A moving average is a calculation built from historical inputs, not a separate source of knowledge about what price must do next.

This lesson explains the simple moving average, the exponential moving average, and the settings that make two apparently identical chart lines differ. The dedicated worksheet calculates a complete SMA window and one transparent EMA update using a supplied prior EMA. Keeping the arithmetic visible is more useful than treating every line crossing as an automatic decision.

1. Define the observations and the period

A five-period average uses five observations, but the unit depends on the chart. On a daily chart it may represent five completed daily closes; on a five-minute chart it may represent five completed five-minute closes. “Five” alone does not describe the information horizon. Record the interval, session, source price, and completion status.

Closing prices are common inputs, but some platforms allow opens, typical prices, or other calculated sources. An average of closes and an average of high-low midpoints need not match. A learner comparing values should verify the input field before assuming the platform made an arithmetic mistake.

Historical adjustments matter too. An average calculated from split-adjusted closes can differ from an average built from unadjusted prices. The settings should remain consistent across the price series and its overlays. A discontinuity in the underlying data can distort the line long after the affected observation entered the window.

2. Calculate a simple moving average

The SMA is the sum of the selected observations divided by their number. For closes $48, $49, $50, $51, and $52, the sum is $250 and the five-period SMA is $50. Each observation has equal weight. The average is a summary of those five values, not necessarily a price at which any particular transaction occurred.

When a new close of $53 arrives, the five-period window drops $48 and adds $53. The new average is $51. The change can also be calculated as new observation minus dropped observation, divided by five: ($53 − $48) ÷ 5 = $1. This explains why an SMA can move partly because an old observation leaves the window.

A rising SMA does not require every included close to rise. It only requires the current average to exceed the prior average under the selected calculation. Likewise, price above an SMA says something about a relationship to a historical summary, not about intrinsic value or a guaranteed favorable return.

Smoothing changes the view. Worked chart and calculations using the fictional example in this lesson.
Original educational diagram. Fictional observations; calculation assumptions are explained in the lesson.

3. Calculate one exponential moving average update

A common EMA update uses alpha equal to 2 divided by period plus one. The new EMA equals alpha times the new observation plus one minus alpha times the prior EMA. A five-period EMA therefore uses alpha 2/6, or one third. If the prior EMA is $50 and the new close is $53, the updated EMA is $51.

This formula gives greater immediate weight to the newest observation than an equally sized SMA window, while carrying forward a declining influence from older observations through the prior EMA. It is not simply a weighted average of only the last five closes. The earlier history enters through the recursive state.

The worksheet requires a supplied prior EMA because one update is not the same as constructing an entire historical indicator. A chart platform must initialize the series somehow, often with a seed based on earlier data. Different seeds and history lengths can create initial differences. Those differences generally decay, but they should not be ignored when reconciling short samples.

4. Compare response and lag honestly

A shorter period generally responds more quickly to changing inputs and produces more frequent fluctuations. A longer period generally smooths more and responds more slowly. These are design tradeoffs, not a ranking of good and bad settings. The suitable comparison depends on the question and must be evaluated under a consistent test.

Suppose a stock has been near $50 for many observations and suddenly closes at $60. A short average rises more sharply than a long one. Neither line knew the jump would occur. The quick response happened after the new price entered the calculation. Describing that response as prediction confuses reaction with foresight.

Repeatedly shortening a period after missing a move can increase sensitivity to noise and transaction costs. Repeatedly lengthening it after whipsaws can delay later responses. A professional study records the selected settings in advance and evaluates alternatives without presenting the best historical setting as an established universal optimum.

5. Distinguish price crossings from average crossings

Price crossing an average compares a current or completed price with one summary line. A fast average crossing a slow average compares two summaries. Those events can occur at different times. An intrabar crossing may also disappear before the bar closes, so the rule must say whether it uses live observations or completed bars.

A crossover does not provide an execution price by itself. If a rule requires a completed close, a subsequent order needs a plausible timing and fill assumption. A backtest that observes the final closing signal and assumes an earlier favorable fill creates information leakage. The order timeline deserves as much attention as the indicator formula.

Moving averages and pivot structure can disagree because they summarize data differently. A pullback below a short SMA can occur while confirmed swing lows remain rising. Review trend structure and confirmation to keep these descriptions separate rather than forcing every method to display the same verdict.

6. Measure distance with explicit units

Distance from a reference average can be expressed in dollars or as a percentage of the average. If price is $53 and the SMA is $50, the dollar distance is $3 and the percentage distance is 6%. This is not the same as the stock’s return over the averaging period, because the denominator is the average rather than a starting price.

A 6% distance can be ordinary in one instrument and unusual in another. Volatility, liquidity, and market conditions matter. Calling price “overextended” requires a stated comparison or rule. It should not be a flexible label applied whenever a learner feels uncomfortable with the recent move.

An average can be used as a reference in a hypothesis about pullbacks or continuation, but historical contact with the line does not turn it into a physical barrier. If the line changes every bar, its future location is also uncertain until future observations arrive.

7. Use the moving-average worksheet

Open the Lesson 5 moving-average exercise. Enter closes 48, 49, 50, 51, 52 and period 5. The current SMA is $50. Enter prior EMA $50 and new close $53. With the same period, the one-step EMA update is $51 and alpha is one third.

Change the period to 3. The SMA now uses the last three supplied closes, $50, $51, and $52, giving $51. The EMA alpha becomes one half, and the supplied-state update becomes $51.50. These outputs demonstrate different operations; the tool does not pretend that the entered prior EMA was recalculated from the displayed close list.

Try a period larger than the number of supplied closes. The worksheet should reject an insufficient SMA sample. Then enter a single malformed item in the list. The tool should identify the invalid input rather than quietly discard it. Clean data and explicit conventions are part of understanding the calculation.

8. Read the visual result without overinterpreting it

The exercise plots the supplied closing sequence and its rolling SMA where enough observations exist. A gap at the start of the SMA series reflects insufficient earlier observations, not missing evidence of a hidden signal. The single EMA update is displayed numerically because a supplied prior state does not define an entire EMA history.

Compare a steadily rising list with a list that alternates above and below the same mean. Both can end with similar averages while having different paths. Smoothing intentionally removes information. A useful analysis inspects the underlying observations as well as the smoother rather than assuming the smoother contains everything important.

The later MACD lesson uses differences between EMAs and an additional signal average. Understanding this basic update makes those components easier to audit and helps explain why several price-derived indicators can overlap.

9. Test a moving-average rule as an experiment

Specify the instrument universe, timeframe, source price, periods, completion rule, entry timing, exit rule, costs, and treatment of missing data. A statement such as “buy above the 20-day average” omits enough detail to produce many different historical results. The rule is not ready for comparison until those details are fixed.

Retain rejected and failed cases. If several period combinations are tested, record how many were considered and reserve genuinely unseen observations for later evaluation. Reusing the same data to choose, revise, and validate a rule makes the reported result more optimistic than an independent test.

Compare against an appropriate baseline and examine drawdown, turnover, exposure, and net results. A smoother can produce appealing chart annotations while creating costly repeated trades in a range. The course’s backtesting lesson explains why a positive historical calculation alone does not establish a durable advantage.

10. Know what you have learned

You should be able to calculate an SMA window, explain the dropped-observation effect, calculate alpha, and update an EMA from a prior state. You should also be able to explain why two platforms can differ and why a crossover needs a separate execution rule.

The strongest use of a moving average is as a clearly defined component of a broader question. Its value comes from consistent measurement and careful evaluation. A line becomes less mysterious when you can reproduce the arithmetic, identify the assumptions, and describe the uncertainty that smoothing leaves unresolved.

Case review: an average moves when an old value leaves

Suppose a five-close window is 40, 50, 50, 50, 50. Its SMA is $48. The next close is also $50, replacing the old $40 observation. The new SMA becomes $50 even though the latest price did not rise relative to the immediately preceding close. The average’s increase reflects a change in window membership.

A chart observer who reports that buyers suddenly became more aggressive solely because the average rose is adding a causal story the calculation does not establish. The input change is enough to explain the arithmetic. Market interpretation requires a separate question.

Repeat the experiment with an unusually high old observation leaving the window. The SMA can decline while the newest close remains unchanged. Compare this with the EMA update, where earlier observations decay through the prior state rather than disappearing at one fixed boundary. These examples make lag and smoothing concrete. They also show why reading the source series and window is essential before interpreting the slope of a polished overlay.

A repeatable practice and review protocol

Before changing the example, write down the question you expect the calculation to answer. Copy the input values, units, chronological order where relevant, and the observation time. State whether the values are fictional, historical, or current. The exercises in this course begin with fictional data so the arithmetic can be studied without implying that a real security offers a particular opportunity. A calculator result is only as meaningful as its input definitions.

Predict the direction of one change before pressing the calculation button. Change one input at a time, explain which part of the formula it affects, and compare the result with your prediction. This controlled approach is more informative than changing several fields until an attractive number appears. If the result surprises you, return to the definition and denominator before looking for a market explanation. Arithmetic mistakes and interpretation mistakes require different corrections.

Then test an ordinary alternative and an edge case. An ordinary alternative checks whether you understand the relationship away from the default example. An edge case checks whether a ratio becomes undefined, a sample becomes insufficient, or an input ordering becomes impossible. A clear validation message is a useful result. Do not work around it by entering an unrelated value merely to make the screen produce an answer. First understand which assumption the rejected value violated.

Save a short review with four parts: the observation, the calculation, the interpretation, and the unresolved limitation. Keep those parts separate. The observation records what the supplied data says; the calculation shows how the number was obtained; the interpretation is a conditional hypothesis; the limitation identifies information the exercise does not provide. This structure makes the note understandable to another beginner and makes later revisions easier to audit.

If you extend the example into a paper-trading study, define signal time, decision time, order assumptions, quantity, costs, and review horizon before checking the outcome. Preserve the original version. Record unfavorable cases and skipped cases under the same rules as favorable ones. A chart image can support the record, but it should not replace the actual values and definitions. A successful-looking historical picture is not a substitute for a complete sample.

Finish by explaining the result in plain language without using a pattern name as the explanation. Identify what changed, what stayed fixed, and what the exercise still cannot establish. You have completed the practice when you can reproduce the important arithmetic, recognize an invalid comparison, and describe an alternative outcome. Repeating this process across the course builds a consistent analytical habit while keeping the different formulas and their limitations distinct.

Sources and calculation notes

Primary educational background provides additional context for the topic. The fictional examples, teaching cases, diagrams, and worksheets here are original educational illustrations. Calculation conventions and missing information are stated explicitly; indicator readings do not establish future returns.

Stay Ahead of the Market

Get daily AI insights, market updates, and trade opportunities delivered to your inbox.