It's a nerve-racking time to be an investor, so if you're feeling anxious about the stock market, you're not alone.

Several recent events have caused concern for many investors -- including the collapse of Silicon Valley Bank and crypto exchange FTX, and threats of an upcoming recession. The general market volatility over the past year has also worried many people, and it can be tempting to press the pause button on investing for now.

Sometimes, that's not necessarily a bad thing. In other cases, though, you're better off continuing to invest despite these unnerving events. Here's how to decide what you should do.

Person with a worried expression sitting in a chair.

Image source: Getty Images.

When to consider avoiding the market: You have no emergency fund

If you're a long-term investor, volatility over the coming weeks or months isn't too concerning. As long as you leave your money in the market until prices recover, you can simply ride out the storm without experiencing any losses.

But if you invest all your spare cash and then face an unexpected expense, it could be costly.

Nobody knows for certain how the market will perform in the near term, and there's a chance stock prices could have further to fall. If prices drop and then you suddenly need the money you've invested, you might have no choice but to sell your investments at a discount and lock in those losses.

If you're going to continue investing right now, it's wise to ensure you have at least a few months' worth of savings stashed away in an emergency fund. That way, if you do face an unexpected expense, you can cover it without having to touch your investments.

Why now could be a smart time to invest

1. Prices are lower

If your finances are in good shape and you have a healthy emergency fund, right now can be a fantastic time to invest -- even if more volatility is on the way.

Share prices are lower than they've been in a long time. Some stocks are down 50% or more from their peak a year or two ago, which means now is a smart time to load up on quality investments for a much lower cost.

It can be daunting to invest during the market's low points, especially if prices fall further. But this strategy can save you a lot of money over time. If you only invest when the market is thriving, you're paying a premium on your shares and spending far more than you need to over the long run.

2. You can set yourself up for lucrative earnings

Buying during the slumps can also put you in an excellent position to see significant returns when the market inevitably rebounds.

For example, say you had invested in Amazon in 2008, at the height of the Great Recession. At that point, its price had fallen more than 65% from its peak, and it might not have seemed like the best time to buy.

But if you had bought during the low point and simply held your investment, you would have seen returns of over 370% in the following two years alone. Within five years, those returns would have skyrocketed to 935%

AMZN Chart

AMZN data by YCharts.

Of course, not all companies will experience Amazon-like returns. But the best way to maximize your earnings in the stock market is to invest in quality stocks when their prices are lower, then hold those investments through the recovery.

3. You won't miss out on the next bull market

Timing the market effectively is next to impossible, because stock prices can be unpredictable in the short term. While we do know that a bull market is coming eventually (no downturn can last forever), it's unclear exactly when it will begin.

Also, because the market is constantly fluctuating, we might not even know that a bull market has begun until we're months into it. If you wait until the market is well into recovery to invest, you could waste valuable time.

For instance, say you had invested in an S&P 500 index fund in January 2009, just before the market officially bottomed out. At the time, it might have seemed like a terrible idea, since prices were still volatile throughout the following months. But by the end of the year, you would have earned returns of more than 23%.

^SPX Chart

^SPX data by YCharts.

Instead of investing in January, however, say you waited until August, when the market was already well into the recovery. While that might have seemed safer, you would have only seen returns of around 13% by the end of the year.

The market could face more volatility in the near term, but that doesn't mean now is a bad time to invest. By choosing quality stocks and holding for the long haul, you're far more likely to make money in the stock market.