October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
The Finance Base
The Money Desk · Blog
Re:

How to Forecast Stock Prices With Linear Regression in Excel

Use Excel’s FORECAST.LINEAR or TREND to extend a fitted line through historical stock-price data—and understand why the result is not a validated price prediction.
From TheFinanceBase Team4 min to read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Excel can fit a straight line to historical stock-price observations and extend that line to later dates. Use FORECAST.LINEAR or TREND to calculate the projection, then chart it to see the result. Treat it as a mathematical extrapolation—not a reliable prediction of a stock’s future price or investment return.

What linear regression does—and what it cannot tell you

Linear regression fits a straight line to paired x- and y-values. For a simple stock-price example, x is a number assigned to each trading session and y is the chosen price measure for that session. Excel’s documented model is a + bx: the fitted intercept plus the slope multiplied by x. Microsoft describes FORECAST.LINEAR as estimating a value from known x- and y-values using linear regression.

The resulting line summarizes the relationship in the observations you supply. Extending it past the last observation assumes that the historical straight-line pattern continues. A fitted line, a high fit statistic, or a precise-looking projected price does not establish that this assumption is valid or that the estimate will predict future prices accurately. The Microsoft function documentation explains Excel’s mechanics; it does not establish a stock-price forecasting success rate.

Prepare the stock-price data

  1. Choose the price series. Decide whether y will be closing price, adjusted closing price, or another measure. State the data source and date range when sharing an analysis. The Microsoft function documentation does not prescribe a price series or its treatment of stock splits and dividends.
  2. Assign an x-value to each observation. For equally spaced trading-session observations, use sequential numbers such as 1, 2, 3. A sequence avoids treating calendar days without trading as observations. Keep the numbering consistent when assigning future x-values.
  3. Keep the columns aligned. Put each x-value beside its corresponding y-value and check that the ranges contain the same number of observations. For example, column A can hold session numbers and column B the selected prices.

Illustrative layout: place historical x-values in A2:A101, their matching y-values in B2:B101, and the future x-value to estimate in E2. These cell references demonstrate formula syntax; they are not a stock example or a tested forecast.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Calculate a projected price with FORECAST.LINEAR

Enter this formula in a result cell:

=FORECAST.LINEAR(E2,B2:B101,A2:A101)

The argument order is FORECAST.LINEAR(x, known_y's, known_x's). Here, E2 is the x-value to estimate; the y-range contains historical prices; and the x-range contains their corresponding session numbers. Copy the formula down if you have several future x-values, making sure the x inputs advance by the intended number of trading sessions.

Microsoft says FORECAST remains available for backward compatibility, but it was replaced by FORECAST.LINEAR in Excel 2016; Microsoft recommends the latter for current use. The function documentation lists applicability to Microsoft 365 and Excel 2024, 2021, 2019, and 2016. Check Microsoft’s function reference for syntax and compatibility details.

Use TREND for a series of fitted or future values

TREND fits a straight line by least squares and can return estimates for new x-values. Its syntax is TREND(known_y's,[known_x's],[new_x's],[const]). For example, with prices in B2:B101 and session numbers in A2:A101, a formula can specify both ranges and a range of new session numbers to calculate multiple projected values. Microsoft documents the optional x-values and least-squares behavior of TREND.

Use FORECAST.LINEAR when you want an estimate for a particular x-value; use TREND when you want a set of fitted or new values from the same linear relationship. These functions provide calculations, not evidence that a projection is suitable for an investment decision.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Plot the observations and the projection

A chart makes it easier to see how the fitted line relates to the historical observations. Excel supports trendlines on several two-dimensional chart types, including stock charts and XY scatter charts. A trendline can be extended beyond observed data, but that extended segment is extrapolation—not confirmation of future performance. Microsoft explains how to add and extend chart trendlines.

Linear regression and Excel’s Forecast Worksheet are different methods

Excel’s Forecast Worksheet is not a linear-regression alternative with a different label: Microsoft documents it as using the AAA version of exponential smoothing (ETS). It expects a time-based timeline and corresponding values at consistent intervals, and its settings include the forecast horizon, confidence interval, seasonality, and treatment of missing points. Linear regression instead fits a straight line to paired x- and y-values through functions such as FORECAST.LINEAR and TREND.

Approach Model Input structure Seasonality and setup
FORECAST.LINEAR or TREND Straight-line least-squares relationship Paired known x- and y-values; new x-values can be supplied for estimates The basic linear fit does not offer the Forecast Worksheet’s seasonality setting. Formula arguments are explicit. Microsoft function reference and TREND reference.
Forecast Worksheet AAA exponential smoothing (ETS) Time-based timeline and corresponding values with consistent intervals Offers seasonality, confidence-interval, forecast-horizon, and missing-point settings in the worksheet workflow. Microsoft’s Forecast Worksheet instructions and forecasting-functions reference.

These are differences in calculation and workflow, not evidence that either method predicts stock prices well. Microsoft also documents LINEST for returning regression statistics; a statistic describing the fit to supplied data should not be mistaken for out-of-sample forecasting accuracy. See Microsoft’s overview of projecting values with FORECAST, TREND, and LINEST.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check common formula errors

  • #N/A: Check for empty ranges or mismatched lengths between the known x- and y-ranges.
  • #DIV/0!: The known x-values have zero variance, so Excel cannot fit the line.
  • #VALUE!: Check whether an x-value is nonnumeric.

These error conditions are described in Microsoft’s FORECAST and FORECAST.LINEAR reference. Correcting an input error makes the formula usable; it does not validate the forecast.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to interpret the result responsibly

Report a linear-regression estimate as the output of a specified model, dataset, price measure, and time range—not as a promised future price. The Excel documentation establishes how the functions calculate values, but supplies no empirical stock-price accuracy rate. Assessing predictive performance would require a disclosed dataset and an out-of-sample evaluation; a chart extension or in-sample fit alone cannot provide that evidence.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

More post from the Money Desk

  1. The Money DeskBlogTheFinanceBase09 OCT 267 minMortgage Escrow FAQs: Taxes, Insurance, Shortages, and Refunds
  2. The Money DeskBlogTheFinanceBase09 OCT 265 minHow Mortgage Escrow Accounts Work and What Homeowners Pay For
  3. The Money DeskBlogTheFinanceBase09 OCT 265 minHow to Read a Stock Chart, Volume and Market-Cap Data
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.