It's tough to be an investor when the market is on a downhill slide.

Stock prices are continuing to fall, with the S&P 500 down more than 18% since its peak in early January. Even more unnerving is that nobody knows how long this downturn will last or how far prices will fall before the market bottoms out and starts to recover.

That uncertainty can make it difficult to know how to handle your investments. Should you continue investing? Wait until the market stabilizes? Or perhaps even pull your money out of the market altogether? Here's what you need to know.

Person sitting at a table looking at a laptop and documents.

Image source: Getty Images.

What does a downturn mean for your investments?

In most cases, the best way to survive a market slump is to continue with your normal strategy. Keep investing as usual, hold onto your current investments, and simply ride out the storm.

While it may seem counterintuitive to keep throwing money in the market when prices are plummeting, this strategy could actually help you earn more over time.

Since its inception, the market has faced dozens of downturns. In fact, since 1928, the S&P 500 has fallen by more than 20% on 21 separate occasions. Yet it has managed to recover from every single slump and go on to earn positive average returns over time. No matter how bad this current downturn gets, it's extremely likely the market will rebound once again.

If you continue investing now, that puts you in a fantastic position to see substantial returns down the road. Stocks are essentially on sale right now, making it a smart opportunity to invest at a discount. Once the market inevitably recovers and stock prices increase again, your investments could soar in value.

When it might be better to avoid investing

Most of the time, it makes sense to continue investing even when stock prices are falling. There are some situations, though, where you may be better off putting your money elsewhere.

If you don't have an emergency fund, for example, you may want to focus on building a solid stash of savings before you invest.

Downturns are one of the worst times to sell your investments, because stock prices are lower and you're selling for a discount. If you invest all your spare cash and then face an unexpected expense, you may end up losing money if you sell your stocks during a downturn.

Similarly, if you're struggling to make ends meet, you're probably better off waiting to invest. While it's extremely likely the market will rebound eventually, it could take months or even years before stock prices fully recover. Until then, there's always a chance that prices could fall further and your investments could drop in value.

As a general rule of thumb, then, it's best to avoid investing any money you might need in the next several years.

Market downturns aren't always easy to tolerate, but they won't last forever. By keeping your focus on the long term and investing carefully, your investments have a far better chance of surviving any potential market volatility.