How to backtest a simple momentum strategy in excel using free data sources

How to backtest a simple momentum strategy in excel using free data sources

I often get asked how to validate an investment idea without paying for fancy software or hiring a quant team. One of my favorite ways to do that is to backtest a straightforward momentum strategy in Excel using free data sources. It’s practical, transparent, and — crucially — reproducible. In this article I’ll walk you through the exact steps I use, including where to get data, how to structure your spreadsheet, the formulas to calculate signals and returns, and simple metrics to evaluate performance.

What I mean by a “simple momentum strategy”

When I say momentum, I’m referring to a rule that favors assets that have performed well over a recent lookback period. For this example we'll implement a long-only, monthly-rebalanced strategy that selects the top 3 out of 10 assets based on their 12-month total return (skip the most recent month to avoid short-term reversal). That’s a common, intuitive approach used in many academic papers and practitioner portfolios.

Free data sources I use

Here are reliable, free places I pull historical prices from:

  • Yahoo Finance — easy CSV downloads for stocks, ETFs, and indices.
  • Stooq — excellent for long histories (especially for non-US assets).
  • Alpha Vantage — offers an API with a free tier (you’ll need an API key).
  • Google Sheets — you can use the =GOOGLEFINANCE() function as a quick alternative (note: not recommended for very long histories or production work because it can be inconsistent).
  • For this tutorial I assume you downloaded monthly adjusted close prices from Yahoo Finance for each ticker (or used Stooq if you need older data). Save each asset’s price series into a single Excel sheet, aligned by date.

    Spreadsheet structure I use

    I like a clean layout so the logic is obvious and auditable. Here’s a minimal layout:

    Column ADate (month-end)
    Column B..KAdjusted Close for Asset 1..10
    Column L..U12-month momentum scores (calculated)
    Column VRank / Top-n flags
    Column WPortfolio weight per asset
    Column XMonthly portfolio return

    For clarity, label each asset column with ticker and source date. Freeze the top row so headings stay visible as you scroll.

    Step 1 — Calculate monthly returns

    Convert adjusted closes into monthly returns. If your prices are on a monthly frequency (month-end), use this formula in row 2 (assuming prices start in row 2):

    =(B3/B2)-1

    Drag across all asset columns and down. Keep one sheet with raw prices and a separate sheet with returns — I find that separation reduces mistakes.

    Step 2 — Compute the 12-month momentum signal

    We’ll calculate a 12-month cumulative return skipping the most recent month. That is, momentum = price(t-1) / price(t-13) - 1. If column B is prices for Asset A and row i is the current month:

    =B(i-1)/B(i-13)-1

    Put these momentum values in dedicated columns. If you prefer returns rather than cumulative price change, you can use the product of (1 + monthly return) over months t-12 to t-2 minus 1, but the simpler price ratio is fine for month-end data.

    Step 3 — Rank and select top assets

    Each rebalance date (monthly here), rank the assets by momentum descending and select the top 3. In Excel you can use RANK.EQ (or RANK) to get ranks. For example, assuming momentum values are in L2:L11 for a date:

    =RANK.EQ(L2,$L$2:$L$11,0)

    Create a flag column: if rank <= 3 then 1 else 0. That flag becomes your long position indicator.

    Step 4 — Assign weights

    I prefer equal-weighting across chosen assets. If you pick 3 assets, each gets 1/3 of the portfolio on the next day’s open (or month close depending on data). In Excel, compute weight as:

    =IF(flag=1,1/COUNTIF(flag_range,1),0)

    Put weights for each asset in the weight columns. This approach implicitly assumes you can hold fractional shares and that portfolio rebalancing occurs at the monthly bar.

    Step 5 — Compute portfolio returns including transaction costs

    Monthly portfolio return is the weighted sum of asset returns for the month. If returns are in row i and weights in row i (weights determined at previous month-end), then:

    =SUMPRODUCT(return_range,weight_range)

    Transaction costs: apply a round-trip cost per turnover event. One practical way is to estimate turnover as the sum of absolute difference in weights versus previous month divided by 2 (approximate traded value). Then cost = turnover * cost_per_unit. For example, with 50 bps round-trip cost (0.005):

    =turnover * 0.005

    Subtract that cost from the gross portfolio return.

    Step 6 — Performance metrics I calculate in Excel

    Once you have a monthly series of portfolio returns, compute:

  • CAGR: =(PRODUCT(1+monthly_returns)^(12/num_months))-1
  • Annualized volatility: =STDEV.P(monthly_returns)*SQRT(12)
  • Sharpe ratio (use a risk-free monthly rate r_month): =(AVERAGE(monthly_returns)-r_month)*SQRT(12)/STDEV.P(monthly_returns)
  • Max drawdown: create a cumulative equity curve column =starting_value * PRODUCT(1+returns up to date). Then compute running max and drawdown = (current equity / running_max)-1; max drawdown is MIN(drawdown column).
  • These formulas are standard and easy to implement in Excel. I also like to chart the equity curve and rolling 12-month return to visualize stability.

    Simple example table (skeleton)

    DateTICK1 PriceTICK1 MomTICK1 FlagTICK1 WeightPortfolio Return
    2020-01-311000.1210.33
    2020-02-291020.1010.330.014

    Practical checks and robustness tests I always run

    Backtests can be misleading if you don’t check a few things:

  • Survivorship bias — use tickers that were live during the entire period or explicitly include delisted assets.
  • Lookahead bias — ensure momentum uses only information available at the signal date (that’s why I skip the most recent month).
  • Transaction costs and slippage — test multiple cost assumptions (0, 25 bps, 50 bps) to see sensitivity.
  • Parameter sensitivity — test different lookback windows (6, 9, 12, 24 months) and number of holdings (top 1, 3, 5).
  • Subperiod analysis — check performance across bull and bear markets separately.
  • Common mistakes I avoid

    When I teach this to colleagues, these errors come up repeatedly:

  • Mixing price frequencies — if your signal is monthly, all calculations should use month-end prices.
  • Using adjusted close naively — adjusted close accounts for dividends and splits. Use it, but ensure consistency across sources.
  • Applying returns to the same month as signals — signals generated on month-end should apply to the next month’s returns.
  • Extensions you can try

    If you want to expand this simple framework, consider:

  • Introducing a volatility filter: reduce weights for high-volatility assets or use volatility-parity weighting.
  • Using excess momentum: momentum minus market return to control for broad beta exposure.
  • Combining momentum with value signals: create a composite score and backtest the hybrid.
  • Using VBA or Power Query to automate data downloads from Alpha Vantage or Yahoo Finance.
  • Backtesting a strategy in Excel is not glamorous, but it’s powerful. It forces you to be explicit about assumptions and makes debugging straightforward. For many investors and advisors, an Excel backtest is the best first step before committing capital or automating in a trading platform. If you want, I can export a template workbook skeleton (with example formulas and charts) you can use as a starting point — tell me which tickers you want to test and I’ll tailor it.


    You should also check the following news:

    Portfolio Strategies

    How to hedge a concentrated stock position using options without blowing up returns

    02/12/2025

    I’ve helped investors and real estate owners quantify risk and design practical hedges for years, and one of the most common problems I see is a...

    Read more...
    How to hedge a concentrated stock position using options without blowing up returns
    Personal Finance

    When to convert a traditional ira to a roth: a tax-savvy decision checklist

    02/12/2025

    I convert retirement accounts for the same reason I study market cycles: to tilt the odds in my favor while keeping downside controlled. A...

    Read more...
    When to convert a traditional ira to a roth: a tax-savvy decision checklist