For the past 17 months, investors have enjoyed a historic rally. Since bottoming out on March 23, 2020, the broad-based S&P 500 (^GSPC 0.02%) has doubled in value. While we've witnessed some healthy bounce-back rallies from a bear-market bottom throughout history, we've never seen the benchmark index double from its lows in such a short time frame.

But such rapid gains in the wake of such economic uncertainty also raise the question: Is a stock market crash coming?

Although no one knows with any certainty, we can turn to an abundance of data to get a better idea of what might lie ahead for the S&P 500 and your portfolio.

A twenty dollar paper airplane that's crashed and crumpled into a financial newspaper.

Image source: Getty Images.

A confluence of data suggests a crash or steep correction is growing more likely

Perhaps the most concerning indicator that a significant decline might await the stock market can be found by closely examining the S&P 500's Shiller price-to-earnings ratio. The Shiller P/E takes into account inflation-adjusted earnings over the past 10 years.

On Monday, Aug. 16, the S&P 500's Shiller P/E hit a nearly two-decade high of 38.91. For some added context, the average Shiller P/E dating back 151 years is 16.84.

Understandably, the democratization of financial data with the advent of the internet has helped to expand earnings multiples considerably over the past two decades. Nevertheless, the previous four instances where the S&P 500's Shiller P/E surpassed and held above 30 haven't ended well. In each of these instances, the index subsequently lost at least 20% of its value.

Examining the way the S&P 500 bounces back from bear market bottoms is also telling. Excluding the coronavirus crash, there have been eight bear markets since the beginning of 1960. Every single one of these bear markets featured at least one pullback of 10% (or greater) within three years of reaching its bottom.

In fact, five of these eight bear markets endured two double-digit percentage pullbacks within three years of hitting a trough. The point being that bouncing back from a bear-market bottom rarely results in a straight line higher, as we've predominantly experienced over the past 17 months. Historical data would suggest that the market is due for some potentially significant downside.

A quick look at historic crash and correction data for the S&P 500 paints a similar picture. Since 1950, the S&P 500 has undergone 38 double-digit percentage declines, according to figures from market analytics company Yardeni Research. That's a crash or correction, on average, every 1.87 years. While it's important to note that the stock market doesn't adhere to averages, it's still worthwhile to observe the frequency by which the S&P 500 pulls back by 10% (or more).

In other words, crashes and steep corrections are a perfectly normal part of the investing cycle. Based on the above data, it shouldn't surprise investors if a stock market crash is coming.

A smiling young woman holding a financial newspaper and looking off into the distance.

Image source: Getty Images.

But wait: There's another side to this story

Another side to this data needs to be told.

Although stock market crashes and corrections are common, historic data also very clearly shows there are advantages to staying the course as a long-term investor and buying great companies on any weakness.

For example, the investing landscape technically offers no guarantees. Yet each and every crash or correction in history has eventually been erased by a bull market rally. That means long-term investors in the S&P 500 would be 38-for-38 if they bought during a crash or correction, or simply held an S&P 500 tracking index since the beginning of 1950.

What's more, Crestmont Research examined the rolling 20-year returns of the S&P 500 between 1919 and 2020 (a 102-year period) and found that the total returns, including dividends, for any end-year in this stretch would have yielded investors a positive return. Only two of these 102 end years (1948 and 1949) produced an average annual total return of 5% or less. Meanwhile, more than 40 end years in this time frame yielded at least a 10% average annual total return.

Essentially, when you buy into the S&P 500 is far less important than how long you hold. If you held your position for at least 20 years between 1919 and 2020, your initial investment grew.

It also doesn't hurt that the S&P 500 is comprised of 500 of the largest companies in the world. Its components tend to be profitable, time-tested businesses that are able to take advantage of the disproportionately long period of time the U.S. and global economies spend expanding, relative to contracting.

Lastly, take note that while crashes and corrections occur often, they usually don't last very long. The average double-digit correction since 1950 has lasted 188 calendar days (about six months), whereas the average modern-era correction (i.e., since computers became mainstream on Wall Street in the mid-1980s) is only 155 calendar days (roughly five months). Comparatively, bull markets are measured in years.

Buying great companies and staying the course is a proven path to building wealth.

A person typing on a laptop while sitting on a couch.

Image source: Getty Images.

Three stocks to buy if a market crash does occur

Speaking of great companies, if a stock market crash does rear its head sometime in the foreseeable future, the following three stocks would be perfect for patient investors to add to their portfolios.

Visa

First, consider picking up shares of payment processor Visa (V 0.33%). It's a company that benefits immensely from the steady expansion of U.S. and global gross domestic product. Since periods of expansion last considerably longer than recessions, Visa is able to take advantage of increased spending from consumers and businesses.

It's also important to understand that Visa isn't a lender. It strictly sticks to its role as the leading provider of payment network services in the U.S. and globally. Since it doesn't lend, Visa won't have to set aside cash if credit card delinquencies rise during a contraction or recession. This is a big reason Visa's profit margin is consistently above 50%, and why it bounces back much faster than other financial service stocks.

A surgeon holding a one dollar bill with surgical forceps.

Image source: Getty Images.

Intuitive Surgical

A second no-brainer buy during a stock market crash is robotic-assisted surgical system developer Intuitive Surgical (ISRG -0.55%). Since we don't get to choose when we get sick or what ailment(s) we develop, there's steady demand for healthcare stocks offering drugs, devices, and operating systems.

What makes Intuitive Surgical so special is its dominance of the assisted surgical space and its growing operating margins. As for the former, none of its competitors even comes close to its installed base of 6,335 da Vinci surgical systems. Between the high cost of these systems ($500,000 to $2.5 million) and the hours of training given to surgeons, da Vinci buyers are likely to remain long-term clients.

When it comes to operating margins, Intuitive Surgical's are primed to expand over time. That's because selling instruments and accessories with each procedure, as well as servicing its robotic systems, generates juicier margins than actually selling the da Vinci surgical system. As its installed base grows, so will its operating margins.

An electrical tower next to three wind turbines at sunrise.

Image source: Getty Images.

Duke Energy

Lastly, investors can confidently buy shares of electric utility stock Duke Energy (DUK 0.77%) if volatility picks up and the broader market heads lower.

The beauty of utility stocks is the transparency of their cash flow and outlooks. This is to say that demand for electricity doesn't change much from one year to the next, which is what leads to predictable profits and market-topping dividend yields. In the case of Duke Energy, investors are pocketing a healthy 3.7% yield.

What truly makes Duke Energy an intriguing investment is the $58 billion to $60 billion the company is spending on new infrastructure projects between 2020 and 2024. The vast majority of this spending will be on renewable energy, which will lower the company's electric generation costs and lift its growth rate. As the U.S. goes green to fight climate change, Duke's transition to cleaner forms of energy will benefit its shareholders.