SAN FRANCISCO (MarketWatch) — 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.

Volatility: What to do now

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, a chartered financial analyst and head of investment management at Research Affiliates LLC 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, 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 agreed. “You can’t get to a retirement goal earning 2% or 3% in bonds when inflation is running at 3.5%,” said Jeff Layman, CFA, 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 how many years out you are from retirement, your ability to ignore the daily headlines and focus on the long term, and other factors. What’s most important is diversifying across a broad array of asset classes, rebalancing regularly and controlling your expenses.

Getting out while getting’s good

Maybe you’re envying your neighbor who moved all his money into cash in July or early August, before the Dow Jones Industrial Average DJIA, +1.19% fell a gut-wrenching 635 points on Monday, Aug. 8, then proceeded to seesaw, closing up 430 points on Tuesday, down 520 points Wednesday, and up 423 points on Thursday, closing out the week down just 1.5%.

Certainly, your neighbor was not alone. The U.S. debt-limit debacle, Europe’s debt crisis, ongoing fears of the dreaded double-dip recession and a general crisis of confidence prompted plenty of people to jump out of stocks in recent months.

Investors pulled a net $13 billion out of equity mutual funds in the week ending Aug. 3 (the most recent data available) — that’s the week before those four massive DJIA 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. See the ICI mutual-fund outflow data.

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. Read how the DJIA notched a gain of more than 7% in the three trading sessions through Monday, Aug. 15.

Retail investors like you and me are known for pulling out of the market — and then missing the rebound. From 1991 through 2010, the average annual return of the S&P 500 SPX, +0.82% was 9.1%, but the average equity investor return was a measly 3.8%, according to Dalbar, a financial-services market research firm.

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, CFA, member of the investment policy committee at investment firm Edward Jones, in St. Louis, Mo. “It’s because they bought high, and they sold low.”

Focus on what you can control

Plenty of regular 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, 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.” Read Swensen's piece on mutual funds.

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

You also have some ability to diversify your holdings. In addition to U.S. stocks and bonds, consider emerging-market stocks and bonds, commodities, Treasury Inflation Protected Securities (TIPS) and real-estate investment trusts (REITs), among other options. Get ideas by looking at how the Lazy Portfolios are invested.

If you don’t have access to much variety in your 401(k), consider investing in that plan up to the full employer match, and then investing some money through an IRA 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.

Understand risk

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 401(k) nest egg when you start pulling the money out. Read more: Higher tax rates loom for 401(k) savers.

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 timeframe, 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.”