After suffering through the "lost decade" for stocks, investors were taken on a roller-coaster ride in recent weeks -- and the future looks to hold more of the same: a highly volatile stock market and lower annual average returns.

You'd think that might mean that investors whose main goal is a comfortable retirement should be anywhere but in stocks.

Not so.

Despite the bleaker outlook going forward, the stock market is still about your only hope of overcoming the bite that inflation and taxes will take out of your retirement savings.

"The future real (after-inflation) return of a traditional mix of stocks and bonds may be closer to 2% than the 5% average of the past," said Chris Brightman, the head of investment management at Research Affiliates in Newport Beach, Calif.

And the ride will be bumpier. Brightman said the annualized standard deviation of monthly stock-market returns was 15% for the past decade, up from about 10% in the 1990s and 1960s. Still, he said, "the average recent volatility of 14% to 15% is only slightly higher than the 13% to 14% level during the 1970s and 1980s." Since 1831, the average is 14.5%.

But despite the weak -- and volatile -- outlook, people investing for retirement need stocks.

"We're likely to be living in a more volatile period for some significant period of time, and I believe market returns are likely to be relatively modest compared to what they have been," said Harold Evensky, the president of money-management firm Evensky & Katz in Coral Gables, Fla. "I still think they're going to be higher than what someone is going to get in bonds. That's the reality investors have to live with."

Others agree. "You can't get to a retirement goal earning 2% or 3% in bonds when inflation is running at 3.5%," said Jeff Layman, the chief investment officer at BKD Wealth Advisors in Springfield, Mo. "The impact of that is much more devastating on a portfolio over time than periodic rounds of volatility."

This doesn't mean you must throw 70% of your retirement-plan assets into stocks. Your precise allocation will depend on such factors as how many years out from retirement you are and your ability to ignore the daily headlines and focus on the long term.

What's most important is diversifying across a broad array of asset classes, rebalancing regularly and controlling your expenses.

Maybe you envy your neighbor who moved all his money into cash in July or early August, before the gut-wrenching gyrations of the Dow Jones Industrial Average ($INDU).

Certainly, your neighbor was not alone. Plenty of people have been jumping out of stocks in response to the U.S. debt-limit debacle, Europe's debt crisis, ongoing fears of a new recession and a general crisis of confidence.

Investors pulled a net $13 billion out of equity mutual funds in the week ending Aug. 3 -- that's the week before four massive Dow moves -- up from the net $9.3 billion investors withdrew a week earlier and the less than $4 billion pulled out in each of the first two weeks of July, according to the Investment Company Institute, a mutual-fund company trade group.

Sure, your neighbor seems prescient. But does he know when to get back in? "Markets go up just as precipitously and as fast as they go down," Evensky said.

Retail investors are known for pulling out of the market -- and then missing the rebound. From 1991 through 2010, the average annual return of the Standard & Poor's 500 Index ($INX) was 9.1%, but the average equity investor return was a measly 3.8%, according to Dalbar, a provider of market research.

Why? Because investors bought when stocks were on a tear and sold when they fell in value.

"It's not because they owned the wrong investment," said Scott Thoma, a member of the investment policy committee at investment company Edward Jones. "It's because they bought high and they sold low."

Focus on what you can control

Plenty of investors fear the system is rigged against them -- that big-money investors with sophisticated trading software are stacking the deck against the little guy. But even the sophisticates fell hard "during the tech crash, during the last crash and probably during this one," Evensky said.

Instead of worrying about them, Evensky said, focus on what you can control. For one, mutual-fund expenses.

David Swensen, the chief investment officer at Yale University, said in a recent opinion piece in The New York Times that "even Morningstar concludes . . . that low costs do a better job of predicting superior performance than do the firm's own five-star ratings."

While 401k's and other defined-contribution plans are far from perfect, most offer access to cheap index funds.

You also can diversify your holdings. In addition to U.S. stocks and bonds, consider emerging-market stocks and bonds, commodities, Treasury inflation-protected securities and real-estate investment trusts, among other options.

If you don't have access to much variety in your 401k, consider investing in that plan up to the full employer match, and then investing some money through an individual retirement account to get access to more investment options.

You're also in control of rebalancing. Once you've decided what percentage of your portfolio to invest in each asset class, revisit your portfolio quarterly. If necessary, sell investments that have grown beyond your target allocation and buy more of those that have dropped below your target.

Investors tend to focus on market swoons, but that's not the only risk you face. "In our definition, risk is not reaching your long-term goal," Thoma said.

And don't confuse certainty with safety. "Putting your money in CDs may feel very certain -- you know you'll get every penny back -- but it's very unlikely to be safe for most investors because there's not going to be enough money to pay the bills after you factor in inflation," Evensky said.

Another risk: taxes. You'll owe income tax on that 401k nest egg when you start pulling the money out.

Click here to become a fan of MSN Money on Facebook

And keep in mind, that "lost decade" wasn't so for everyone. If you put $10,000 into the S&P 500 in 2000, you'd have about the same amount in 2010, Thoma said. But investors who put in $10,000 over time in regular monthly installments? "Their money would have grown to over $14,000 during that time frame, if you were in a 65/35 portfolio," Thoma said.

"It's because you invested over time," he said. "A lot of your money was invested lower and benefited from that recovery. That's where people have to focus more often than not."

This article was reported by Andrea Coombes for MarketWatch.