"The man who has planned badly, if fortune is on his side, may have had a stroke of luck; but his plan was a bad one nonetheless."

-- Herodotus

Imagine it: You're cruising along toward your retirement, which you've planned for the end of 2008, and you're nearly there. You've got most of your nest egg invested in stocks, because you've read that stocks outperform bonds and most other alternatives over the long haul.

The bulk of your nest egg, in fact, is sitting in an S&P 500 index fund, a most reasonable investment choice. It automatically has you invested in 500 of America's biggest companies, including Boeing (NYSE: BA), Halliburton (NYSE: HAL), MEMC Electronic Materials (NYSE: WFR), Ford (NYSE: F), and Lehman Brothers (NYSE: LEH).

But wait! You haven't checked your balances in a while. Your $1 million nest egg isn't a $1 million nest egg any more. It's now a $910,000 nest egg! What happened? Where did a whopping $90,000 go?

Well, the market started the year by heading south for the winter. At the end of March, the S&P 500 was down about 9% for the year. But as bad as that sounds, it could be even worse. In 2002, the S&P 500 lost more than 22%! That performance would have pulled your $1 million nest egg down to less than $780,000.

Every investor is familiar with paper losses, but when you're close to retirement, those paper losses can translate into a real dilemma. If you planned to withdraw 4% of your nest egg each year in retirement and you were suddenly out $220,000, you'd have lost nearly $9,000 a year in real money.

An ebbing tide lowers all boats
You couldn't have avoided this danger by selecting individual stocks instead of an index fund, because all kinds of stocks swooned this year. Highflier Google (Nasdaq: GOOG) is down more than 20% this year, and ExxonMobil (NYSE: XOM) only recently recovered from a 13% drop.

Managed mutual funds haven't been immune, either. The well-respected Dodge & Cox Stock (DODGX) fund is down 12%, while the Winslow Green Growth (WGGFX), which has an impressive long-term record, has fallen by more than 26%. And if that's not enough, home values have swooned, too! That house you were planning to sell may now be worth 10% to 20% less than you assumed.

When retirements were funded with pensions, economic downturns had a smaller effect on the bottom line. These days, a down market at the wrong time can make it a tough time to retire.

An immediate solution
If you were planning to retire in the next few months and the market has whacked you, consider postponing that retirement for a year or two. If the market recovers in that time, you'll end up with a bigger nest egg, and you'll have to support yourself a year or two less on your retirement funds.

You'll also be in good company. According to Newsweek, when the S&P 500 dropped nearly 50% between September 2001 and September 2002, "21% of working people who'd lost money in stocks had decided to postpone retirement as a result -- and 10% of folks who'd already retired had returned to work."

The longer-term solution
If you aren't close to retirement, you're not out of the woods yet. Market downturns can happen at any point, so the key to a secure retirement is proper planning.

That means keeping money you expect to need within five years someplace other than stocks, because, despite the superiority of stocks over the long term, it's a crapshoot over the short term. Anything can happen tomorrow or next month, and it can take the stock market months or even years to recover from a sizable fall.

So although keeping most of your retirement funds in stocks is a good idea, you should move your short-term money into bonds, money market funds, or CDs.

For more conversation about how to plan for your retirement in any market, our Rule Your Retirement investing service distills vital information into a concise monthly package. Try it for free for 30 days, and see what you think -- you'll have full access to all past issues.

Longtime Fool contributor Selena Maranjian does not own shares of any companies mentioned in this article. The Motley Fool's disclosure policy always has a plan.