The last two years have been some of the best in the market's history, with the S&P 500 soaring by over 100% since the market bottomed out in March 2020.

However, some experts believe a crash may be on the horizon. As stock prices continue to climb, many investors worry that the market is overvalued and due for a correction. Does that mean it's time to start caching cash for 2022? Here's what you need to know.

Person looking out a window, looking concerned.

Image source: Getty Images.

How likely is a market crash?

The last couple of weeks have been particularly volatile for the stock market, leading some to believe that we're headed toward a downturn. That said, it's impossible to know for certain when or if the market will crash.

There are some factors -- such as the omicron COVID-19 variant that's spreading quickly across the United States -- that could trigger a market crash. But there's no way to know for certain whether omicron will hurt the market or not. Case in point: When the delta variant began spreading over the summer, stock prices continued climbing.

Record-high inflation could also affect the future of the market, but whether it will cause a crash is anyone's guess. High inflation rates can have an effect on consumer spending, as people are spending more of their paychecks on rent, utilities, and other basic necessities. That could, in turn, cause stock prices to fall.

That said, inflation has been steadily climbing over the last few months, and it's seemed to have little effect on the market. So whether it's enough to lead to a crash is uncertain.

How to prepare for the unpredictable

Investing in the stock market can be frustrating at times because it's so unpredictable. Nobody -- even the experts -- can say for certain when or if a crash will occur.

If you're nervous about investing during periods of volatility, it can be tempting to pull your money out of the market or stop investing entirely. But market downturns aren't as alarming as they may seem, and there are ways to prepare for them -- even if nobody knows when they're coming.

First, make sure you have a solid emergency fund and that you're only investing money you won't need for the foreseeable future. Market downturns are one of the worst times to withdraw your investments, because stock prices will have dropped and you'll end up selling for a discount.

When you have at least three to six months' worth of savings in an emergency fund, you can leave your investments alone until the market recovers. Keep in mind that you won't lose any money unless you sell, and the market will bounce back eventually. By staying invested, you can simply ride out the storm.

It's also important to double-check that you're only investing in solid, long-term companies. Not all stocks can survive a market crash, but companies with strong underlying business fundamentals have the best chance at pulling through. If the market does crash in 2022, investing in the right companies can save your portfolio.

Nobody knows when or if the market will crash in the coming year, but it's wise to be prepared just in case. By building a solid emergency fund and investing in the right stocks, your portfolio will be able to survive anything.