2024 isn't over yet, but the S&P 500 (^GSPC -1.11%) is set to cap off a banner year.

Even though most Wall Street experts had expected only modest returns at the beginning of the year, the S&P 500 is up 28% year to date through Dec. 4, on track for one of its best years in history. The artificial intelligence (AI) boom, interest rate cuts, a resilient economy, and excitement around the incoming Trump administration have all combined to send stocks soaring for the second year in a row.

This year's performance comes after strong results in 2023 when it jumped 24%, and there's another sign that 2024 is one of the most bullish years on record for the stock market.

Through Dec. 4, the S&P 500 has closed at an all-time high 56 times. While it could add to that mark by the end of the year, that is still the fifth best showing since 1929.

The words market data under a magnifying glass in a newspaper.

Image source: Getty Images.

What the surge in record highs tells investors

We're not even two years into a new bull market, but already some investors seem to smell a bubble. Warren Buffett's Berkshire Hathaway has been a net seller of stocks every quarter this year as it stockpiles cash, and it even declined to repurchase its own stock for the first time in six years. Other investors have questioned the billions being poured into AI infrastructure, suggesting the consumer end market doesn't justify it.

Stock valuations are also high by historical levels, as the S&P 500's price-to-earnings ratio has reached 30.3, according to some measurements, showing that stocks are expensive compared to historical averages.

So how does 2024 compare to previous years with even more all-time highs? The table below shows the five years with the highest number of days when the S&P 500 reached a new all-time high.

Year Annual Gain
for S&P 500

# of Days S&P 500
Hit All-Time High

1964 13% 65
1995 34% 77
2017 22% 62
2021 29% 70
2024 YTD 28% 56

Data source: Bilello.blog and others. YTD = year to date.

In two of the four years above, 1964 and 1995, the S&P 500 gained the following year. In 1965, the S&P 500 climbed another 9%. However, it fell 13% in 1966 as the bull run of the previous few years got overheated

Meanwhile, in 1995, the dot-com boom was just beginning, and the stock market wouldn't peak until 2000.

But for 2017 and 2021, the momentum didn't last. In 2018, the S&P 500 finished down 6% due to rising interest rates, fears of trade war with China, and the threat of a federal government shutdown. And in 2022, stocks fell 18% as the pandemic-era bull market left valuations inflated, and growth in the tech sector slowed significantly as the economy fully reopened.

What it means for investors

There are no ironclad rules in stock investing, but looking back at history can help inform your understanding and decision-making in the current market.

While the sample size above is limited, there is some indication that a surge in new all-time highs one year can lead to a pullback in the near term.

While it's impossible to know how the stock market will perform in 2025, investors should be prepared for the current momentum to temper itself, given current valuations. However, a lot can change in a year, especially with a new administration taking control of the White House and ongoing developments in AI.

There's another lesson here as well. Over a longer time horizon, the stock market has consistently climbed to fresh all-time highs, even after a bear market -- and often sooner than you might think. By 2019, the S&P 500 was back to a record, and this year's results show why buying in 2022 paid off as well.

In other words, betting on the S&P 500 over the long term comes with volatility, but it's also a tried-and-true way to build wealth. That's worth remembering no matter what happens in the stock market next year.