The S&P 500 (^GSPC 1.02%) hit a new all-time high in January, officially pulling us out of the bear market that began at the start of 2022. Stocks have been on a tear since the start of November (when the Federal Reserve paused rate hikes), and then they moved higher again in December when the Fed indicated it would start cutting rates in 2024.

Since that November Fed meeting, the S&P 500 has rallied more than 15%.

Some investors might be wary of investing in a market that's making new highs. After a stellar run, are stocks due for a pullback? At the very least, they should show slower-than-average growth, right?

It's in these instances that history can provide some guidance on the best way to invest as the market makes a new all-time high.

A silhouette of a bull in front of a sunrise.

Image source: Getty Images.

The message from the data

We have experienced 11 bear markets since 1950. Sometimes the declines were slow, and sometimes the market crashed. Sometimes the recovery came quickly, and other times it took years before the market would make new highs again.

But stocks, as a group, have always recovered to set new all-time highs. What's most interesting is what happens after they reach that all-time high following a bear market.

In all but one instance, the S&P 500 closed even higher one year after reaching a new high. And not just a little higher: On average, stocks were 16.2% higher one year after reaching a new high following a bear market.

For reference, the average return for the S&P 500 in any given year since 1950 is 9.3%, and the compound annual growth rate for the index is 7.9% (10.2% if you factor in dividends).

In other words, the environment that pushed stocks to a new all-time peak typically persists and leads them to keep growing at an above-average pace. That makes it a prime opportunity to invest in stocks right now.

Here's the best way to invest right now

Investing amid a bull market can be just as challenging as investing in a bear market, if not more so. Finding stocks trading at or below their fair value becomes more difficult when stock prices increase across the board.

That said, there are still plenty of great stocks to buy right now that are arguably trading below their intrinsic value. But the best way for most investors to take advantage of the strength of this market is to buy a simple index fund.

An S&P 500 index fund like the Vanguard S&P 500 ETF (VOO 1.00%) is the simplest and most effective way to gain exposure to the momentum of the stock market. Warren Buffett recommends an S&P 500 index fund more than any other investment for most people.

There's no value in trying to time the market and wait for another correction before putting money into an index fund. As famed investor Peter Lynch said: "Corrections are unpredictable. By selling stocks to avoid pain, you can miss the next gain."

Sure, no one wants to be the sucker who bought shares as they peak in price. But with history as a guide, and the understanding that timing market corrections is impossible, investors should be confident that investing today is a smart move.

Even if we are headed for another correction or bear market, long-term investors can take solace in the fact that stocks have always recovered to reach new all-time highs, and there's no reason to think that won't happen again.