After early 2020's steep market crash, stocks not only recovered and gained for the year, they also started 2021 out with a bang. The S&P 500 climbed 67% from its low point in March through the end of December. Then the index marched another 12% higher from the start of this year through May 7.

Then came a dip that many saw as a buying opportunity. But the declines kept coming, and worries about the possibility of a market crash grew. The S&P 500 lost as much as 4% in about three days. Popular stocks such as Disney, Netflix, and PayPal are down since the start of the month. 

With that as the backdrop, the big question on many investors' minds is: Should I keep buying stocks right now?

A man sitting at his laptop discusses something with a man standing next to him.

Image source: Getty Images.

Black Monday

To help answer that question, let's start with a look back at a few historic stock market crashes. The Black Monday crash happened on Oct. 19, 1987. The Dow Jones Industrial Average sank by 22% in one trading session. But over the course of the 12 months that followed, the Dow fully recovered from that plunge.

^DJI Chart

^DJI data by YCharts

Fast-forward a decade from there, and you come to the period when the dot-com bubble burst. That was a more gradual process, beginning after the Nasdaq Composite Index reached more than 5,000 in early 2000. From there, it lost more than 70% of its value through October 2002. The recovery from that slide took a while. But investors who held on for the long term saw the tech-heavy index climb back past 5,000 again in 2015.

^IXIC Chart

^IXIC data by YCharts

Let's look at one more: During the 2008-2009 financial crisis, the Dow lost more than 50% from its peak in 2007 through its low in 2009. Again, the best strategy was holding on. By 2013, the index had recouped its losses and was setting new highs.

^DJI Chart

^DJI data by YCharts

As these examples and others would show, U.S. stock market crashes have always been followed by recoveries -- and, eventually, gains past prior highs. Of course, it's painful to watch as your holdings lose value. But history suggests that for those with properly diversified portfolios, those losses won't last forever. And that means that if you buy stock in great companies now and hold for the long term, you're likely to profit.

What's your investing time horizon?

This leads me to my next point: Investing success is heavily influenced by your time horizon. If you're a long-term investor, you'll stand a better chance of profiting from buying stocks in this market environment than you'll have if you're a short-term investor or a trader.

Market crashes illustrate just how important it is to have a long-term mindset when it comes to your portfolio. Downturns and bear markets happen. Many of your investments may decline. But you haven't really lost money unless you sell. That's why you should only invest money that you won't immediately need and are willing to keep in stocks for a while. This way, you won't feel forced to sell when prices are down. You'll have the luxury of holding on through the difficult times -- and locking in profits when you choose to do so.

My final point is this: When the market is falling, you can pick up shares of great companies at relative bargain prices, making times like this perfect for a stock market shopping spree. Now is the time to look closely at companies' earnings reports and consider their track records and future prospects. It's also worth weighing their price-to-earnings ratios and price-to-sales ratios. These can give you a better idea of how much of a deal a given stock might be.

So, should you keep buying -- even if the broader market's declines continue? If you're a long-term investor, absolutely. Market downturns don't last forever. If you choose a solid catalog of quality stocks today, it's likely that overall, your investment portfolio will increase in value over time.