The S&P 500 (^GSPC -0.56%) is down 1% year to date, but that number doesn't tell the whole story. The index initially advanced 4% as investors anticipated deregulation and tax cuts under President Trump. Instead, the administration shocked Wall Street with aggressive trade policies and the stock market crashed.

Specifically, the S&P 500 began falling in February, when President Trump announced tariffs on imports from China, Canada, and Mexico. The losses persisted throughout March as the administration added new duties on steel and aluminum imports. And the decline reached a low point in early April after President Trump unveiled his "Liberation Day" tariffs.

In total, the S&P 500 on April 8 closed 19% below the record high it reached on Feb. 19. But the market has since staged one of its most impressive comebacks ever. The S&P 500 advanced 19.6% between April 8 and May 16, its 15th biggest gain over any 27-trading-day period in history. And history says that momentum could carry the stock market higher in the coming months.

History says the S&P 500 could soar 24% before the end of 2025

As mentioned, the S&P 500 advanced 19.6% during the 27 trading days between April 8 and May 16. The rebound began when President Trump paused country-specific reciprocal tariffs for 90 days, and the rally continued as the administration offered positive commentary on trade deals and took steps to defuse trade tensions with China.

Importantly, the S&P 500 has only performed better over any 27 trading days 14 times in history, and the index has always moved higher over the next six months, one year, and two years, according to Charlie Bilello at Creative Planning. The following chart provides specific dates and details.

A chart showing the 14 largest 27-trading-day rallies in the S&P 500.

Shown are the S&P 500's 14 largest 27-trading-day rallies throughout history.

As shown, following the 14 largest 27-day stock market rebounds in history, the S&P 500 returned an average of 21% over the next six months. That implies significant upside before the end of 2025.

Specifically, the S&P 500 closed at 5,958 on May 16. The index will advance 21% to 7,209 by Nov. 16 if its performance aligns with the historical average. That implies 24% upside from its current level of 5,800.

A confident-looking investor sits in front of several computers showing stock prices.

Image source: Getty Images.

The economic impact of President Trump's tariffs is still an unknown variable

Investors need to be careful with technical analysis. As shown in the chart, the S&P 500 notched its best 27-day returns on the heels of extreme economic uncertainty. The 1982 rallies followed three consecutive years in which CPI inflation topped 10% because of oil supply shocks and rising gasoline prices in the wake of the Iranian Revolution. But the market popped when prices began to stabilize.

Similarly, the late 2008 and early 2009 rallies followed the onset of the Great Recession, which itself was due to the collapse of the U.S. housing market and the failure or near-failure of several financial institutions. The market rebounded when the Federal Reserve lowered its benchmark interest rate to near zero and the government provided assistance in the form of bailouts and economic stimulus.

Finally, the 2020 rallies followed the onset of COVID-19, which derailed supply chains around the world by shuttering businesses and forcing people to work remotely. But the stock market recovered when the Federal Reserve reduced its benchmark interest rate to near zero and the government began cutting stimulus checks to help Americans make ends meet.

Today, the stock market once again finds itself steeped in economic uncertainty, except the current situation was not caused by external events like an oil supply shock or pandemic. Instead, the Trump administration has put the economy on edge with radical changes to trade policy. Tariffs imposed by the president have raised the average tax on U.S. imports to its highest level since the early 1900s. And the fallout is still unknown.

Consequently, investors should be cautiously optimistic. The S&P 500 may deliver strong returns in the coming months, but past performance is no guarantee of future results. So, the most prudent course of action is to maintain an above-average cash position and buy only high-conviction stocks, meaning companies whose earnings are virtually certain to be much higher five years from now.