This year has been a rollercoaster in many ways, and some investors have been feeling whiplash from all the ups and downs.

Right now, around 42% of investors feel optimistic about the stock market's next six months, according to the most recent weekly survey from the American Association of Individual Investors. Just two weeks ago, though, that figure was only 28%. A week before that, it was close to 33%.

In other words, many people don't quite know how to feel about the market -- which is understandable, considering policy changes out of Washington can change things on a dime. While nobody knows exactly what's coming, history has both good and not-so-good news for investors.

Gold bull and bear figurines facing each other.

Image source: Getty Images.

First, the not-so-good news

The bad news for investors is more of a harsh reality about the stock market itself: A recession is coming sooner or later.

To be clear, this doesn't necessarily mean that a recession is coming this year or even in the next couple of years. It's impossible to know when the next downturn will begin, and even the experts get it wrong sometimes.

Case in point: Back in June 2022, economists at Deutsche Bank predicted a "near 100%" chance of a recession occurring by the end of the year, going so far as to say that avoiding a hard landing would be "historically unprecedented." Not only did a recession never materialize, but the S&P 500 (^GSPC 0.34%) is up by around 62% since that forecast.

Recessions are hard to stomach, but they're a normal part of the stock market's cycle that we can't avoid entirely. While nobody knows exactly when the next one will begin, it never hurts to start preparing your portfolio accordingly.

The future is still bright for the market

With the bad news out of the way, here's the best part about what history has to say about the stock market: Its long-term future has always been -- and will likely always be -- overwhelmingly positive.

In fact, according to analysis from Crestmont Research, there's never been a single 20-year period in the S&P 500's history that hasn't ended in positive total returns. This means that if you'd invested in an S&P 500 index fund at any point and held it for 20 years, you'd have made money no matter how severe the downturns were in that time.

In the last two decades alone, the stock market faced multiple severe downturns. The dot-com bubble burst in the early 2000s, for example, led to one of the longest bear markets in U.S. history. The Great Recession from 2007 to 2009 was the longest and deepest economic downturn since World War II. And the COVID-19 crash in 2020 was among the fastest stock market crashes ever.

^SPX Chart

^SPX data by YCharts

Despite all of this severe volatility, though, the S&P 500 is still up by a staggering 352% since January 2000. If you'd invested in an S&P 500-tracking fund back then, you'd have more than quadrupled your money by today.

Also, keep in mind that no matter how far stock prices fall, you don't technically lose any money unless you sell your investment. As long as you stay invested until the market rebounds, your portfolio should recover its lost value -- assuming you're investing in high-quality stocks that are more likely to withstand volatility.

A recession is coming sooner or later, but that doesn't have to be cause for alarm. By investing in the right places and holding those investments for the long term, you can not only survive the next economic downturn, but also build life-changing wealth over time.