Candlestick chart with blue and orange moving-average lines crossing beside the words SMA vs EMA Crossover

SMA vs EMA Crossover: Which Should You Use?

Originally Published: · Last Updated:

For an SMA vs EMA crossover, compare the trades each rule produces rather than picking the faster line. EMA gives recent prices more weight, which can help during a sustained move or send you out of the market just before a rebound. The example below uses the SPDR S&P 500 ETF Trust (SPY), an exchange-traded fund. EMA traded more often in some window pairs and less often in others. Even the return ranking changed when we changed the assumed trading cost.

What changes when you use EMA instead of SMA?

A simple moving average, or SMA, takes the average of the closes inside its window. Each close inside the window gets the same weight. An exponential moving average, or EMA, gives newer closes more weight while keeping a fading contribution from older prices.

Suppose prices fall sharply for three days, then recover. An EMA pair may signal a sale while the SMA pair stays invested. If the decline continues, that earlier sale can avoid further losses. If prices rebound, the EMA rule may miss the recovery and buy back at a higher price, paying for both trades.

The useful question is how much those earlier exits and entries gained or lost after costs. Counting how often they helped would miss the size of each gain or loss.

What changes when you switch from SMA to EMA

QuestionSMAEMA
Price weightsEqual weight for each close inside the windowMore weight for recent closes; older prices fade gradually
Response to a new moveMay change less at firstMay change more at first; a crossover is not always earlier
Number of tradesDepends on the pair and price pathCan be higher, lower, or the same
Better choiceCompare costs, returns, and losses under the same ruleUse the same test conditions; responsiveness alone is not a return advantage
Both averages summarize past prices using different weights.

This comparison covers daily rules that switch between a US equity ETF and cash. It does not test short selling, leverage, or intraday trading.

What the SPY comparison shows

The following test holds SPY when the fast average is above the slow average and holds cash otherwise. A signal from one day’s close takes effect at the next available open. The fast average uses the shorter span, and the slow average uses the longer one. A fast/slow pair lists those spans in trading days. The six pairs are shown together, with no single pair presented as the best setting.

Each move into or out of SPY is charged an assumed 25 basis points, or 0.25%. Cash earns nothing, and taxes are excluded. This is a cost scenario, not a measured quote for trading SPY today.

Data limit: the source file runs from January 4, 2010 through December 30, 2019. Its past price-adjustment treatment is not documented well enough to label these results clean raw-price returns or verified dividend-reinvested returns. The calculations use the file’s prices as supplied, without adding separate dividend payments. These figures compare disclosed rules on one pinned file; they do not estimate a verified dividend-reinvested investor return.

Compound annual growth rate (CAGR) expresses the change in portfolio value as a yearly compound rate. Each row starts when its slow average first becomes available, so buy-and-hold also has a different start date across rows. Compare SMA and EMA within the same row.

SPY file-based comparison: position changes and annualized returns

Fast/slow daysSMA changesEMA changesSMA returnEMA returnBuy-and-hold return
5/20145153−0.17%−0.26%13.84%
10/3081953.30%1.71%13.79%
20/5053355.54%6.88%13.24%
50/10019118.79%9.76%14.28%
50/200999.23%9.44%13.93%
100/200799.16%8.94%13.93%
CAGR is the annual compound growth rate. Strategies include an assumed 25 bp per position change and exclude taxes; buy-and-hold is a reference before trading costs. Each row has its own start date and ends at the December 30, 2019 open. Compare SMA with EMA within a row, not window pairs across rows.

EMA made more position changes in three pairs, fewer in two, and the same number in one. It also finished ahead of SMA in three rows and behind in three. Buy-and-hold had the higher CAGR in all six periods under these assumptions.

The 20/50 row gives a concrete comparison: EMA changed position 35 times against SMA’s 53 and earned 6.88% against 5.54% a year after the assumed costs. That tells us what these rules did on this file; it does not establish 20/50 EMA as a setting to trade.

Position changes count entries and exits, including an initial purchase when the rule starts invested. They are not completed round trips or measured whipsaws. The 50/200 rules each show nine changes: an initial entry, followed by eight switches, with the final position still invested.

Returns alone also leave out how far portfolio value fell along the way. Maximum drawdown measures the fall from a previous portfolio high to a later low.

Losses and time invested under the stated cost scenario

Fast/slow daysSMA maximum drawdownEMA maximum drawdownSMA time investedEMA time invested
5/20−35.87%−31.29%67.3%70.6%
10/30−18.66%−21.08%68.6%73.2%
20/50−24.73%−18.64%72.0%80.8%
50/100−22.07%−18.26%80.0%85.5%
50/200−19.54%−18.07%86.6%90.1%
100/200−19.81%−21.53%83.5%92.1%
Drawdown is the largest fall from a previous portfolio high, sampled at daily opens after each completed holding interval, including stated trading costs. It does not measure the deepest intraday loss. Invested means the share of open-to-open trading intervals held in SPY. Buy-and-hold drawdown rounds to −20.15% in each row’s period.

For 20/50, the SMA portfolio fell 24.73% from its previous high, while EMA fell 18.64% on the sampled open-price path. Both 5/20 rules lost more from peak to trough than buy-and-hold’s 20.15% drawdown in this sample, despite spending part of the period in cash.

Two settings can change which average finishes ahead

Trading cost can reverse a narrow return lead. Before costs, EMA has a small return lead in this pair. Its extra position changes erode that lead as the assumed cost rises.

SMA vs EMA: the cost of trading

5/20 SPY rules. CAGR on a shared scale from −0.5% to 4%.

0 bp per entry or exit
SMA3.56%
EMA3.67%
5 bp per entry or exit
SMA2.80%
EMA2.87%
10 bp per entry or exit
SMA2.05%
EMA2.08%
25 bp per entry or exit
SMA−0.17%
EMA−0.26%
Four assumed costs per entry or exit, with the signals and trade counts held fixed. February 2, 2010 through the December 30, 2019 open. Source: TheFinSense file-based reconstruction.
View the exact chart values.

5/20 pair: changing only the assumed trading cost

Cost per position changeSMA CAGREMA CAGR
0 bp3.56%3.67%
5 bp2.80%2.87%
10 bp2.05%2.08%
25 bp−0.17%−0.26%
Signals, dates, cash return and next-open execution stay fixed. One basis point is 0.01%; 25 bp is 0.25% per entry or exit, not per completed round trip.

EMA leads at zero, 5 and 10 bp; SMA leads at 25 bp. The signals have not changed, so neither have the trade counts. What changes is the money left after paying for them. Compare costs that fit your order size and execution rather than treating this article’s 25 bp assumption as a universal rate.

EMA calculation settings can change the ranking. Two platforms can display different EMA values if they use different calculation conventions. Here, changing only how the opening weights are handled reverses a small return lead. The main table uses recursive weights, while the alternative normalizes the weights of the available history.

50/200 pair: changing only the EMA weighting setting

CalculationCost-net CAGR
SMA9.23%
EMA: recursive weights9.44%
EMA: normalized weights9.21%
All three use the same October 19, 2010 start, final valuation and 25 bp cost assumption. In pandas, recursive and normalized weights use adjust=False and adjust=True, respectively. This is a settings sensitivity test.

With normalized weights, EMA’s small lead over SMA becomes a small shortfall. Neither version is a mistake just because it gives a different result; the platform and the test need to use the same convention.

More history before the evaluation period can reduce the influence of an EMA’s starting value. Match that preparation period as well as the indicator settings when comparing a chart with a backtest.

EMA calculation reference: pandas exponentially weighted calculations.

How to compare a rule you might use

Start with the outcome you want. If the aim is to reduce losses, look at drawdowns and time spent out of the market alongside returns. If the aim is higher returns, a smoother chart is not enough.

For example, take one row of the comparison above and test its SMA and EMA rules on the same dates, using the same price fields, cash return and next-open execution. Record gross returns first, then apply the same cost model to each. Inspect the trades and drawdowns instead of stopping at whichever CAGR is higher.

Test nearby window pairs to see whether a small setting change causes a large change in results. Then freeze the rule and assess it on a period you did not use to choose it. Once that later period influences another adjustment, it is no longer an untouched test.

A rule can also be hard to follow despite acceptable numbers. Consider whether you would stay with it through repeated sell-and-buy signals, a long spell in cash, or years of lagging buy-and-hold.

For taxable accounts, assess taxes separately from trading costs. Realized gains, holding periods and tax lots matter; selling at a loss and repurchasing the same ETF soon afterward can also affect whether the loss is deductible. Those effects cannot be represented by one annual fee.

Before using either rule, make sure your chart displays the same data adjustments and EMA settings as the test. The TradingView settings guide explains where platform choices enter the comparison, while the backtest guide covers rule selection and untouched-data testing.

Common questions about SMA and EMA crossovers

Does EMA always cross before SMA?

EMA gives recent prices more weight, but a crossover depends on both the fast and slow averages. Their relative positions and the price path can change which pair crosses first.

Do fewer trades mean fewer whipsaws?

Fewer trades mean fewer entries and exits to pay for. To measure whipsaws, first define what counts as one, such as a losing round trip closed within a stated number of days. This test reports changes in position without classifying those trades as whipsaws.

Which is easier for a beginner to understand?

SMA is easier to calculate by hand because each close inside the window has equal weight. That makes its calculation easier to explain, but does not make the trading rule more profitable or safer. Start with a rule you can reproduce before deciding whether to use it.

Data and calculation details

This revision reconstructs the earlier version’s table and matches its rounded returns and position-change counts. The historical script and a dated record of parameter selection were not available. The six pairs should therefore be treated as disclosed illustration choices, without a claim that they were registered before the results were known.

Open the calculation assumptions

Source: 2,515 daily observations in the fixed-commit SPY CSV. Rows are used in date order; integrity checks found no missing values or duplicate dates. No extra distributions are credited.

Averages: SMA is the mean of N closes. EMA uses a smoothing weight of 2 / (N + 1), starts from the first close, and uses adjust=False in the main comparison. Each average becomes eligible after N observations; this availability threshold is not a separate pre-sample warm-up.

Waiting for 200 observations does not erase EMA’s initial-value influence. In the recursive 200-day calculation here, the first price still has a coefficient of about 13.67% after 199 updates. That coefficient describes the initial price’s weight; it does not mean the EMA price is wrong by 13.67%. More history before the evaluation period can reduce this dependence.

Starts: 5/20 begins February 2, 2010; 10/30 February 17; 20/50 March 17; 50/100 May 27; and both 200-day pairs October 19. Each starts at the open following the first complete slow-average close. The portfolio starts with cash and buys immediately if that prior-close state is bullish; it need not wait for a new cross.

Position: the prior close’s fast average must be strictly above its slow average to hold SPY. Equality means cash. A sale takes place at the next open, so an existing holding retains the intervening overnight gain or loss.

Wealth: for each open-to-next-open interval, let p be 0 for cash or 1 for SPY, r the file’s open-to-open return, and d the absolute position change from the prior interval. Multiply wealth by 1 + p × r − d × 0.0025. The initial position is zero, so the first purchase is charged.

Cost convention: this reconstruction subtracts cost in the interval’s return factor. Charging it multiplicatively before the interval is a different convention, although both reproduce the published rounded CAGRs on this file. The 25 bp assumption represents a combined trading-cost scenario; no extra slippage charge or tax is added.

Finish: value the existing portfolio at the December 30, 2019 open, before a new rebalance. Do not execute a final-open signal or force liquidation. The final day’s close is outside the return calculation.

Annualization: years equal calendar days between the first execution open and final valuation open, divided by 365.25. CAGR equals (final wealth / initial wealth)^(1 / years) − 1.

Risk: include initial wealth when finding prior peaks; sample wealth at each following open. Drawdown is wealth divided by its highest prior sampled value, minus one. Exposure is the number of invested open-to-open intervals divided by all evaluated intervals, not a calendar-time fraction.

Benchmark: buy-and-hold uses the same row’s first and final opens, with no entry cost or liquidation charge. Its return is before trading costs. It is not a tax-adjusted comparison.

Run the calculation in Python

Save the linked pinned CSV as spy.csv beside this script. This reconstruction was run with pandas 2.2.3 and NumPy 2.3.5. It prints the comparison, risk measures and sensitivity results; returns are percentages.

"""Run with pandas 2.2.3 and numpy 2.3.5; save pinned CSV as spy.csv."""
from pathlib import Path
import hashlib
import numpy as np
import pandas as pd

expected_hash = (
    "f1682f176f9db69ab654405b0126b5c9840"
    "f272ee12c6c5bd5c0fec2345fd6f0"
)
assert hashlib.sha256(Path("spy.csv").read_bytes()).hexdigest() == expected_hash
df = pd.read_csv("spy.csv", parse_dates=["date"])

def test(fast, slow, method, bp=25, adjust=False):
    close = df.close
    def average(n):
        if method == "SMA":
            return close.rolling(n, min_periods=n).mean()
        return close.ewm(span=n, adjust=adjust, min_periods=n).mean()
    p = (average(fast) > average(slow)).astype(float)
    p = p.shift(1).iloc[slow:-1].to_numpy()
    r = (df.open.shift(-1) / df.open - 1).iloc[slow:-1].to_numpy()
    d = np.abs(np.diff(np.r_[0., p]))
    wealth = np.r_[1., np.cumprod(1 + p * r - d * bp / 10000)]
    benchmark = df.open.iloc[-1] / df.open.iloc[slow]
    years = (df.date.iloc[-1] - df.date.iloc[slow]).days / 365.25
    cagr = (wealth[-1] ** (1 / years) - 1) * 100
    drawdown = np.min(wealth / np.maximum.accumulate(wealth) - 1) * 100
    bh = (benchmark ** (1 / years) - 1) * 100
    return [int(d.sum()), cagr, drawdown, p.mean() * 100, bh]

pairs = [(5, 20), (10, 30), (20, 50), (50, 100), (50, 200), (100, 200)]
print("pair, method, changes, CAGR%, drawdown%, invested%, benchmark%")
for pair in pairs:
    for method in ["SMA", "EMA"]:
        result = test(*pair, method)
        print(pair, method, [round(float(x), 6) for x in result])
print("5/20 cost sensitivity: bp, method, CAGR%")
for bp in [0, 5, 10, 25]:
    for method in ["SMA", "EMA"]:
        print(bp, method, round(test(5, 20, method, bp)[1], 6))
print("50/200 normalized EMA CAGR%:", test(50, 200, "EMA", adjust=True)[1])

The linked backtest guide reports a different 50/200 SMA return on the same file because its test includes the opening cash period and uses close-based return intervals. Different start dates and valuation rules can produce different results without either table being a transcription error.

These tests use one ETF and one historical sample, with zero cash interest and no untouched evaluation period. They do not establish a profitable live strategy. A broader test would need reliable adjustment provenance, additional market periods, a declared evaluation design and an execution model suited to the account.

Which should you use?

If you want an average whose calculation is easy to inspect, SMA is a reasonable starting point. If you want recent prices to carry more weight, EMA provides that weighting. For a trading decision, compare the resulting entries, exits, costs and losses before committing money.

An SMA vs EMA crossover comparison is useful only when the test conditions stay the same. A small return lead that disappears under another plausible cost or EMA setting is weak evidence for choosing a rule.

YOUR TURN

When you compare the same rule before and after your trading costs, does its return advantage survive, and what drawdown would you have had to accept?

Editorial transparency: AI-assisted tools supported source comparison, code execution, and drafting. The publication decision and responsibility for the final article remain with Danny Hwang.

Disclosure: No broker, fund issuer, or charting platform paid for this analysis. Examples are educational and are not personalized investment advice.

Update history

  • v3.02026-10-01UPDATE

    Added trading-cost and EMA-setting sensitivity results, open-sampled drawdowns, a cost comparison chart and executable reconstruction code. Clarified valuation dates and data limits, and streamlined the comparison.

  • v2.0 2026-07-22 CORRECTION

    Replaced the unsupported universal turnover-drag projection with a measurement-correct reading of Barber and Odean and a reproducible SMA-versus-EMA comparison.

  • v1.0 2026-05-08 PUBLISH

    Original publication.