The past year has been rough for investors. Major market indexes have been in and out of bear market territory for close to a year, recession warning bells continue, and now the collapse of Silicon Valley Bank has many people understandably rattled.

Amid all this chaos, it can be tempting to stop investing until things feel a bit more stable. When that might happen, though, is anyone's guess.

Is it safer to press pause on investing for right now? Or should you keep going? Here's Warren Buffett's advice.

Is the stock market safe right now?

When there's bad news after bad news, the last thing on your mind may be investing more. But according to Warren Buffett, times like these are the best investing opportunities.

Warren Buffett at an event speaking into a microphone.

Image source: The Motley Fool.

Back in 2008, during the height of the Great Recession, Buffett wrote an opinion article for The New York Times. In it, he writes: "[B]ad news is an investor's best friend. It lets you buy a slice of America's future at a marked-down price."

Stock prices are lower than they've been in a long time, which means now is your chance to buy at a discount. Some stocks haven't seen a slump like this since 2008, and once the market recovers, it could be years before we see discounts like this again.

Even big-name stocks are essentially on clearance right now. The price of Amazon, for example, is down nearly 45% since April 2022. Microsoft's price has fallen by close to 20% in that timeframe, and Apple is down close to 15%. If you've been waiting for a more affordable chance to buy, now may be the time.

Your best chance to see lucrative returns

Not only can investing now save you money, but it can also set you up for significant gains during the market's inevitable upswing.

For example, say you had invested in an S&P 500 index fund in March 2009, when the market officially bottomed out during the Great Recession. At the moment, that may have seemed like the worst possible time to buy, as stock prices had already plummeted.

However, if you had simply held that investment for five years, you'd have earned returns of more than 177%.

^SPX Chart

^SPX data by YCharts

Buying during the market's low points is another piece of advice from Buffett. "A simple rule dictates my buying," he writes in the Times article. "Be fearful when others are greedy, and be greedy when others are fearful."

The stock market has been incredibly volatile over the past year, and if a recession is looming, things could potentially get worse before they get better. But right now is the time to "be greedy," as Buffett puts it, and take advantage of these lower prices.

The secret to making money during periods of volatility

In times like these, it's especially critical to ensure you have the proper strategy. If you invest in the wrong places or sell at the wrong time, you risk losing more than you gain.

There are two keys to maximizing your earnings when the market is shaky: Invest in quality companies and keep a long-term outlook.

The strongest stocks are the ones from companies with solid underlying business fundamentals -- such as healthy financials, a competitive advantage in the industry, and a competent leadership team. These companies are far more likely to survive tough economic times, no matter what the future holds.

The second part of that equation, then, is to stay focused on the long term. Even strong stocks can take a serious hit in the near term. But over several years, they're likely to not only recover, but go on to see positive total returns. By buying during the market's slumps and staying invested through the recovery period, you can maximize your earnings.

What's going to happen with the market?

Unfortunately, nobody -- even the experts -- can say precisely what will happen over the coming weeks or months. But over the long term, the market is extremely likely to recover. By investing in quality stocks, you can give your portfolio the best shot at rebounding, too.

When in doubt, it doesn't hurt to follow Buffett's lead.

"I can't predict the short-term movements of the stock market," he writes. "I haven't the faintest idea as to whether stocks will be higher or lower a month or a year from now. What is likely, however, is that the market will move higher, perhaps substantially so, well before either sentiment or the economy turns up. So if you wait for the robins, spring will be over."