The S&P 500 is still 14% below its all-time high, and the Nasdaq remains down 22% from its peak as of this writing. It's been about a year and a half since the stock market peaked, and it may seem like this downturn will last forever. But that's not likely to be the case.

The stock market has fallen into bear markets dozens of times in our history, and all of the bear markets, recessions, and market crashes we've ever seen have one thing in common: They end. But figuring out the timetable is the tricky part.

Man looking confusedly at laptop.

Image source: Getty Images.

What does history tell us?

As mentioned, the good news is that the stock market is almost certain to recover. While I won't go through every single market downturn and crash, here's a brief history of the last few bear markets and how long it took the S&P 500 to reach new all-time highs.

  • Dot-com bubble: The S&P 500 reached the peak of the dot-com era in March 2000 and fell sharply in the couple of years that followed, fueled by the bursting of the tech bubble and the Sept. 11 attacks and the resulting economic impact. It didn't reach a new peak until May 2007, which didn't hold for too long, as we'll discuss in a bit.
  • Great Recession: The S&P 500 peaked in October 2007, and the financial crisis sent the market plunging in 2008 and into 2009. In March 2009, the S&P 500 bottomed at about 53% below its previous high. The benchmark index didn't reach a new all-time high until March 2013, about five and a half years later.
  • COVID-19 crash: The S&P 500 dropped sharply at the onset of the COVID-19 pandemic, losing about 40% of its value from its February 2020 peak. But the crash was short-lived, with the market breaking to new all-time highs six months later.

So the stock market will recover. It's virtually certain. The United States has experienced dozens of corrections and bear markets, and the market has recovered from every one of them. And there is no reason to believe this time will be any different. The only uncertainty is when it will happen. And the reality is that nobody knows for sure. As we've seen in the last three bear markets, stocks recovered in as few as six months or as many as seven years or more.

The better question to ask

Instead of asking when the stock market will recover, the better question is, "How can I set myself up for success when it does?"

In a nutshell, nobody knows when the stock market will recover and start reaching new all-time highs. It could happen in a year or so if things go very well economically, or it could take several years. After the dot-com crash, it took some solid companies a long time to get back to where they were. For example, Amazon didn't break through its 1999 peak until late 2009.

Since that time, Amazon has rallied for patient investors by more than 1,800% from its dot-com bubble peak -- and that's after losing about half of its value in the current bear market. And some of the most promising businesses from the 2020 to 2021 growth stock surge could behave similarly over time.

Consider this simplified example. If I had invested $10,000 in Amazon at the absolute worst time during the dot-com bubble and held on to every share, my investment would be worth about $192,000 today. That's a pretty solid return over around 24 years. But if I had added $2,500 to my investment at the beginning of 2001, 2002, 2003, and 2004 to take advantage of the lower valuation (investing $20,000 altogether), my investment would have grown to about $1.37 million.

Here's the point. Holding on to stocks you believe in during tough times is an important quality that investors should possess. But great investors take advantage of the difficult times and put money into their highest-conviction investments at a discount.

The Foolish bottom line

Obviously, nobody enjoys watching the value of their investments decline. My portfolio is worth about 23% less than it was at its peak, so I'm in the same boat.

However, waiting for your stocks to "come back" isn't the best long-term mindset, especially if you have a decade or more until you plan to retire. It's a good move to hold on to the stocks of solid companies during the bad times. But it's a great move to invest in solid companies while the market is down.