The macroeconomic environment of the past few years has been unprecedented for many investors. Pandemic-era business closures pushed lawmakers to spend trillions of dollars on stimulus programs, while forcing the Federal Reserve kept interest rates near historic lows to prevent the economy from capsizing. But business closures also disrupted supply chains, creating a situation in which too much money was chasing too few goods.

As a result, inflation soared to its highest level in four decades as the effects of the pandemic faded, prompting the Federal Reserve to raise interest rates at their fastest pace since the early 1980s. Those headwinds sent the S&P 500 (^GSPC 1.02%) tumbling into a bear market, and the benchmark index is still down 8%. But many experts (including members of the Federal Open Market Committee) believe the abrupt tightening of credit conditions will ultimately result in a mild recession. For instance, JPMorgan Chase analysts put the odds of a U.S. recession at greater than 50% before the end of the year.

Deutsche Bank analysts echoed that sentiment in a report published last week, but with much more conviction. They believe the odds of U.S. recession during the next year are "near 100%," and the group's chief economist David Folkerts-Landau noted that it would be "historically unprecedented" to avoid a downturn given the current economic headwinds.

Here's what investors should know.

Investor reading the newspaper and looking thoughtful.

Image source: Getty Images.

History has a clear message for investors

The U.S. has suffered eight recessions during the last five decades, and in all but one the S&P 500 started climbing toward new highs well before economic activity reached a trough. In fact, during those eight recessions, the index produced a median return of 30% between the time it hit bottom and gross domestic product (GDP) hit bottom. In other words, stock market rebounds are usually well underway by the time recessions end.

That happens because investors are forward looking, meaning they react to events before they happen. For instance, the S&P 500 slipped into a bear market in January 2022 because investors were worried about an economic slowdown. However, GDP rose 2.1% in 2022, slightly above the long-term trend of 2%, meaning the economy expanded at a healthy pace. But investors saw the writing on the wall. They knew the Federal Reserve would have to raise interest rates to deal with inflation, and that doing so could potentially cause a recession.

The smartest thing investors can do is stay invested (and keep investing)

Market timing strategies tend to fail because no one actually knows the future. It may seem prudent to sell stocks right now given that Deutsche Bank (and many other authorities) expect a recession in the next year, but investors that follow that path will probably get burned. As discussed, the S&P 500 tends to rebound well before recessions end.

Additionally, missing just a few of the stock market's best days can do lasting damage to a portfolio, and many of those days occur during bear markets. According to Hartford Funds, 42% of the S&P 500 index's best days in the last 20 years took place during a bear market, and another 34% occurred during the first two months of a new bull market (i.e., before it was clear the bear market had ended).

So what? An investment of $10,000 in the S&P 500 in 1993 would have grown into $158,434 by the end of 2022. But if the 10 best days are eliminated from the equation, the total return is cut in half. The initial investment of $10,000 would have grown into just $72,584. That means investors have historically paid a high price for attempting to time the market, and anyone that sits on the sidelines today for fear of a recession is walking into that trap.

Where to invest right now

One evergreen investment option is an S&P 500 index fund like the Vanguard S&P 500 ETF (VOO 1.00%). Indeed, Warren Buffett has often recommended buying an S&P 500 index on a regular basis. That strategy allows investors to diversify their capital across 500 blue chip American businesses, and it has been a consistent moneymaker throughout history.

 Since its inception in 1957, the S&P 500 has produced a positive return during every rolling 20-year period. Better yet, the index returned a total of 1,660% over the last 30 years, or 10% annually, despite weathering several recessions. At that pace, $110 invested weekly in an S&P 500 index fund would be worth $1 million three decades from today.