Inflation appears to be moderating. Unemployment levels remain low. Interest rates could be coming down. As a result of these and other factors, many economists now predict that the U.S. will be able to avoid a recession in the new year. But not all of them.

Raymond James' base case is that a mild recession is on the way. RBC Global Asset Management thinks there's a 70% chance of a recession in the first half of the year. UBS predicts a midyear recession.

Should you buy stocks if a recession is coming in 2024? Here's what history shows.

A person with a facial expression of frustration looking at a laptop.

Image source: Getty Images.

How the stock market typically fares during recessions

Let's start with the bad news. The overall stock market typically fares poorly during recessions. Dismally is probably the better adverb to use.

The S&P 500 index is often used as a proxy for the entire stock market for good reason. There's a strong correlation between the overall market performance and the performance of stocks of the 500 largest U.S. corporations. Take a look at how the S&P 500 performed during the last 10 U.S. recessions:

Recession Period Maximum S&P 500 Decline
Aug. 1957-April 1958 (21.6%)
April 1960-Feb. 1961 (5.2%)
Dec. 1969-Nov. 1970 (36.1%)
Nov. 1973-March 1975 (48.2%)
Jan. 1980-July 1980 (17.1%)
July 1981-Nov. 1982 (27.1%)
July 1990-March 1991 (19.9%)
March 2001-Nov. 2001 (49.1%)
Dec. 2007-June 2009 (56.8%)
Feb. 2020-April 2020 (33.9%)

Data sources: Bloomberg, National Bureau of Economic Research.

On average, the S&P 500 has plunged 31.5% during the last 10 recessions. However, averages can sometimes be misleading because of big outliers. Some prefer to use medians instead. Unfortunately, that doesn't help much in this case. The median S&P 500 decline in the last 10 recessions was 30.5%.

One compelling reason to buy stocks during a recession

With such gloomy historical precedents, you might think that the smartest move to make is to avoid stocks altogether during a recession. However, there's one compelling reason to buy stocks during an economic downturn: You get more bang for the buck.

Recessions don't last forever. The average length of a U.S. recession since World War II is only 10 months. Wise investors will view recessions as opportunities.

Stocks tend to rebound strongly after a recession. As a case in point, look at how the S&P 500 has performed since the short recession caused by the COVID-19 pandemic.

^SPX Chart

^SPX data by YCharts

Buying stocks at lower prices during the accompanying sell-offs makes a lot of sense for investors with a long-term (or even not-so-long-term) perspective. Dollar-cost averaging is an especially good strategy to use since you won't know at any given point in time if stocks will decline further or rebound.

Another important consideration

That leads to another important consideration for investors to keep in mind. There's no way to know for sure if a recession is coming. Holding off buying stocks because of fears of a recession can cost you money.

One year ago, 60% of the economists surveyed by Reuters and 65% of economists surveyed by Bloomberg predicted that there would be a U.S. recession in 2023. Those economists were wrong. The U.S. avoided a recession, and the S&P 500 soared close to 25%. Had you not bought stocks (or even worse, sold stocks), you would have missed out on a major rally.

The best thing for investors to do in 2024 or any other year is to think long-term. Buy the stocks of, to use Warren Buffett's phrase, "wonderful compan[ies] at fair price[s]."If you want to keep it even simpler, buy low-cost index exchange-traded funds (ETFs) that include a diversified basket of stocks. Whether a recession comes or not, you should make money over the long haul.