Historical data is a guiding light for investors during uncertain times. The S&P 500 (^GSPC 1.02%) index was established in 1957, so its 66 years of performance history can be helpful in predicting the stock market's next move.

For example, the S&P 500 suffered a brutal drop in 2022, but the odds were in favor of a comeback in 2023 because consecutive annual losses are incredibly rare. True to form, the index closed the year with a gain of more than 26% (including dividends).

So what does history say could happen next?

A piggy bank next to piles of coins in ascending order supporting blocks spelling 2024.

Image source: Getty Images.

Years like 2024 have always been positive

We'll start with a market quirk. Since 1957, the S&P 500 has delivered a positive annual return 77% of the time, so the odds are always in favor of upside going into any given year. But 2023 set the stage for a more exciting scenario.

The first positive year after a loss is always followed by another positive year -- it has a one hundred percent strike rate based on 11 instances since 1957. In this case, 2023 is the first positive year after a loss (2022), so 2024 will bring further gains if history is any guide.

Of course, past performance alone doesn't predict future results. You wouldn't buy a stock in January just because it went up in December. However, I think the market will go from strength to strength in 2024. Here's why.

Inflation is doing something it hasn't done since 2009 and 1982

The Consumer Price Index (CPI) is the core measure of inflation, and it soared to a 40-year high of 8% in 2022. That was far above the U.S. Federal Reserve's 2% target, which prompted the central bank to rapidly increase interest rates. Therefore, not only were consumers and businesses dealing with surging prices on everyday goods and services, but their debt repayments also headed north.

So far, the Fed's policy response has worked. CPI is on track to finish 2023 at just 3.5% (pending the December data), and while that remains above the Fed's target, it would mark a 4.5 percentage-point drop year over year.

The last time CPI fell more than 4 percentage points in one year was in 2009, when it fell into deflationary territory amid the global financial crisis. The Fed rapidly slashed interest rates, which helped the S&P 500 to a 26% gain for the year. But that's not all; 2009 sparked the beginning of a nine-year winning streak for the stock market as inflation and interest rates remained subdued.

A similar scenario played out in the 1980s. CPI hit 10.3% in 1981, which contributed to a recession, sending the S&P 500 tumbling that year. But inflation fell more than 4 percentage points in 1982, and that was also the beginning of an eight-year bull market for stocks.

No two economic scenarios are the same, and the U.S. economy isn't dealing with a crisis or a recession at this stage. However, the decline in inflation is undoubtedly good for consumers, businesses, and the stock market.

A big drop in interest rates might be on the horizon

Interest rates help investors decide where to put their money. When rates were at historic lows in 2020 and 2021, investors didn't want to hold cash, because it yielded practically no return. Therefore, they piled into the stock market even in the face of uncertainty from the COVID-19 pandemic.

Lower interest rates also make it easier for companies to access capital. Their borrowing costs go down, so they can afford to take on more debt to grow and expand their operations. That leads to higher revenue and more profit -- which investors love -- so it's another great reason to own stocks.

The Fed recently ended its most aggressive campaign to hike interest rates in its history. It lifted the benchmark federal funds rate from a historic low of 0.25% to 5.50% in just 18 months to fight the soaring inflation I talked about above.

But Wall Street is forecasting six interest rate cuts in 2024 thanks to the steep decline in CPI, and that's another sign the stock market will probably continue moving higher.

Here's the return the S&P 500 could deliver in 2024

As I mentioned earlier, the setup for 2024 has occurred 11 times before. The S&P 500 delivered an average gain of 15.5% in those instances, but that's based solely on the historical data, which shouldn't be relied upon on its own.

A number of factors could influence the stock market's performance this year. The S&P 500 could underperform the historical data if inflation turns higher once again, because that means interest rates won't fall as quickly as expected. Plus, the world is entering 2024 with geopolitical flare-ups in the Middle East and in Europe, and those unfortunate situations can be unpredictable.

On the flip side, the S&P 500 could exceed a 15.5% gain if interest rates fall more quickly than expected, as long as the U.S. economy avoids a recession in the process. If inflation remains subdued, there is a possibility 2023 marked the beginning of a multi-year bull run similar to 2009 and 1982. The S&P 500 gained 15% in 2010 and 22.5% in 1983, which would technically be the years equivalent to 2024 in that scenario.

These stocks could do especially well in 2024

Warren Buffett's investment company Berkshire Hathaway has doubled the average annual return of the S&P 500 since 1965, so it's always a great place to invest. Buffett's portfolio is increasingly exposed to artificial intelligence (AI), which could drive even stronger gains going forward.

Speaking of AI, the best performers in that sector in 2023 will likely carry their momentum into the new year. Nvidia, Microsoft, and Amazon are among the highest-quality stocks in the industry.

But here's an under-the-radar pick for 2024: Redfin. The real estate technology stock has more than doubled in the last two months because investors have grown confident that interest rates will fall. Six cuts in 2024 could light a fire under the real estate market, and send Redfin stock even higher from here.