The ups and downs in the stock market have dealt a blow to most people's retirement accounts.

But while short-term fluctuations may be stressful, they won't necessarily derail long-terms goals. Still, the recent swings can be a reality check: What happens if stocks stay soft for a long time? On the flip side, what if there's a sustained rally? When setting up a retirement plan, it's a good idea to factor in slumps. The online Retirement Planning Calculator from can help with that.

The calculator estimates how long retirement savings will support you based on information such as current age, savings and retirement date. The calculator also asks you to estimate the rate of returns expected in the years leading up to and during retirement. Even small changes in those estimated annual returns will have a major impact on the success of your retirement plan.

When you first set up your retirement plan, you probably estimated an 8% average rate of return on your investments -- that's the average yearly return (excluding dividends) of the S&P 500 dating back to the 1950s. But what if your average rate is closer to 10%? What if it's closer to 6%? The calculator can help lay out these scenarios.

Say your retirement accounts are now worth around $250,000. You're 40 years old, earning $60,000 a year and putting 10% of your income in a retirement account. You plan on retiring at 67 and figure to live off 80% of your income at retirement. (The calculator assumes your salary will increase by 4% a year until you retire.) With an estimated 8% return in the years leading up to retirement and a slightly more conservative 6% return during retirement, your retirement dollars would have you covered until age 96. (Investors' annual returns typically drop off during retirement as they shift more money from stocks to the relative safety of bonds.)

And what if the market recovers dramatically from the current downturn and your investments post 10% annual returns leading up to retirement and 8% during retirement? In that case, your retirement dollars would support you long after you reach 96 -- at that age, you'd have more than $22 million in your retirement account!

But what if the market continues to struggle over the next decade or so and only averages a 6% rate of return? In this scenario, which includes a 4% rate of return during retirement, your retirement dollars would likely run out by age 80.

Knowing that, consider how you can get things back on track. Adjust your retirement age in the calculator to see how that affects your retirement savings, and consider boosting savings to make up for the reduced rate of return. Remember that Social Security benefits will most likely contribute to retirement income as well.

No crystal ball can tell us where the market will be in five, 10 or 20 years, and investors shouldn't lose sleep over stock-market returns in the coming years. That said, a little research can go a long way in preparing you for how your savings will fare in a variety of markets.
Peter McDougall is a freelance writer who lives in Freeport, Maine, with his wife and their dog.