Getting out of the market is easy. Figuring out how to get back in, though, takes a whole lot more courage.

The past two years have thrown a lot of investors completely out of their comfort zone. During the early part of the bear market, many investors didn't realize just how extreme the stock market's declines would be. Despite every warning to the contrary, many investors panic-sold their stocks, retreating to the sidelines to wait until things looked better for the economy and the financial markets.

If you're still out of the market, you probably regret it. Cash accounts pay little or nothing these days, while stocks have rebounded nicely from their lows earlier this year. So how can you get back into the market without putting your entire portfolio at risk if the dreaded double-dip recession rears its ugly head?

Is it better yet?
If you believe what the stock market is telling you, you might think someone has sounded the all-clear signal. The S&P 500 had risen more than 50% from its March lows to break the 1,000 level before Monday's pullback, and dozens of stocks have seen even bigger gains.

Yet the news on the economic front is far from universally positive, and there's no guarantee that we won't see a relapse of a shrinking economy. Unemployment remains at high levels, and corporate earnings are still weak despite some encouraging results in the most recent quarter. Many still argue that the rally is just a natural part of a larger bear market.

Stop waiting and dip in
Given all that uncertainty, it's hard to pinpoint when to put your cash back into the stock market. That's why many smart investors don't even make the attempt -- they just use a simple strategy to work their way back into stocks.

If you panicked last fall or earlier this year and still have more cash in your portfolio than a long-term investing strategy would advise, then my advice to you is simple: Start working your way back toward your normal asset allocation today. You'll always find reasons to doubt whether investing at any given time makes sense, but if you just give up on the failed notion that you can time the market accurately, you'll do a lot better in the long run.

The key, though, is beating your fear. Even though stocks could fall at any time, you can reduce those investing fears by reinvesting a little at a time.

How dollar-cost averaging pays off
For frightened investors, it's a lot easier to buy stocks bit by bit via dollar-cost averaging than to reinvest everything at once. As it turns out, not only is that a reasonable strategy to reduce your risk, but it also can actually pay off if your fears turn out to be true.

Let's look at an example. This time last year, the S&P was trading between 1,250 and 1,300, having fallen roughly 20% from its record highs during the previous autumn. Tensions were high about what might be the next shoe to drop in the emerging financial crisis.

Now let's consider two possibilities. If you had $10,000 to invest back then, you could have put it all to work immediately, or you could have split it into four equal chunks and decided to invest a quarter of it every three months. Take a look at how much your investment would be worth now, depending on which strategy and which of the following stocks you'd chosen:

Stock

Invest All At Once

Dollar-Cost Average Over Four Quarters

Southern Copper (NYSE:PCU)

$11,923

$17,174

Bank of America (NYSE:BAC)

$6,040

$17,255

Southern Company (NYSE:SO)

$8,660

$9,834

Amazon.com (NASDAQ:AMZN)

$9,881

$13,807

Caterpillar (NYSE:CAT)

$6,825

$12,026

PepsiCo (NYSE:PEP)

$8,310

$10,335

Medtronic (NYSE:MDT)

$6,997

$10,101

Source: Yahoo! Finance.

As you can see, thanks to all the volatility we've seen over the past year, dollar-cost averaging didn't just outperform a one-time investment. It turned several losing stocks into winners. It is important to note, however, that these returns do not take into consideration trading or brokerage fees, which will inevitably increase with dollar-cost averaging.

Of course, if the financial crisis had never happened and stocks had simply moved higher, then you would've been better off getting your money in sooner than later. But without that perfect foresight, you might be much more comfortable giving up some potential upside in order to get the downside protection that dollar-cost averaging can offer.

Be afraid but invest anyway
It's OK to be scared to invest right now. Despite some of the progress that's been made, there's a lot more uncertainty yet to come. Nevertheless, the time you spend on the sidelines will cost you plenty over the long haul. Dollar-cost averaging back into the market is a low-risk way to get you back on track.

Avoid the biggest single mistake you can make with your investments. John Rosevear tells you right here what you might be doing wrong and how you can fix it.

The Motley Fool's Rule Your Retirement newsletter gives lots of advice about asset allocation for all sorts of financial goals. Start your free 30-day trial now by clicking here.

Fool contributor Dan Caplinger stayed in the market through thick and thin and has continued to add money. He doesn't own shares of the companies mentioned in this article. Amazon.com is a Motley Fool Stock Advisor selection. PepsiCo and Southern Copper are Income Investor recommendations. The Fool owns shares of Medtronic. Try any of our Foolish newsletters today, free for 30 days. The Fool's disclosure policy has great sideline seats, but it would rather get in the game.