The stock market and its investors have at least one thing in common: They're both prone to turn on a dime when the mood of the market changes. But whether the rally continues or stocks turn back down, take heart -- you'll still have a chance to come out ahead in the long run.

Right now, no one's quite sure which way the market's going to move. After hitting the lowest levels on the S&P in more than a decade, stocks have bounced back with a 50% rise in five months. If you've held on to your stocks so far through thick and thin, you may be wondering whether it's time to get out while the getting's good.

Don't lose focus
Investors take comfort in the belief that through hard work and a thorough understanding of the investments they make, they can find companies that will perform well and reward their shareholders. Yet even if you're confident about your investment decisions, it's still really hard to stand your ground through the market's irrational jumps and lurches.

Now is a good time to look at your portfolio and make sure you're comfortable with the reasons behind your purchases. As long as your initial reasoning was sound, don't second-guess yourself now. It's too easy to panic and dump a losing stock, and then see it rebound when the market comes to its senses.

Make a long-term commitment
Unfortunately, although the rally has probably pulled your net worth out of its nosedive nicely, you can't count on a quick rebound that will get you all your money back. During a bull market, stocks are fun to own, and they seem to offer free money with no risk. Now, of course, we know better. It's hard to think in terms of reward if you invested at the highs and are still sitting on losses of 20%, 25%, or even more of your initial investment.

But keep a couple of things in mind. First, if you keep adding new money to the market, falling prices may offer you better long-term returns. Yes, it might take years for you to get back to even on the money you invested back in 2007 and early 2008. Yet the money you invested three or four months ago is already showing a quick profit, now that stocks have rebounded from their earlier freefall. And even if this is just a respite from an ongoing long bear market, adding money now will still get you a big discount from what you paid before.

Second, keep in mind that in any bear market, a few stocks buck the trend. In the bear market from 2000 to 2002, for instance, tech stocks clearly took the worst hit:

Stock

Total Return for 3 Years
Ended Dec. 31, 2002

Yahoo! (NASDAQ:YHOO)

(92.4%)

Oracle (NASDAQ:ORCL)

(61.4%)

Apple (NASDAQ:AAPL)

(72.1%)

Source: Yahoo! Finance.

But not everything fell. Some stocks did reasonably well over that three-year period:

Stock

Total Return for 3 Years
Ended Dec. 31, 2002

Johnson & Johnson (NYSE:JNJ)

12.8%

Medtronic (NYSE:MDT)

27.1%

Union Pacific (NYSE:UNP)

43.8%

Lockheed Martin (NYSE:LMT)

173.9%

Source: Yahoo! Finance.

That's not to say the same companies that did well from 2000 to 2002 will be the same ones to outperform during the next downturn. It only shows that no matter how bad the market seems, there are pockets of good stocks -- if you know where to look.

Keep on pluggin' along
Some who watched the 1987 market crash firsthand were convinced that another Great Depression would follow. It didn't happen. In fact, it turned out to be one of the last great buying opportunities investors would have for the next decade.

If stocks turn back down now, don't be terrified, the way many were in 1987. Instead, be ready to pounce on some stocks you missed out on buying back in March. Unless you think our economic system is doomed to fail, you'll eventually want to have your money in stocks, too. The only question is how much of a bargain you'll get.

For further related Foolishness:

Picking stocks during market panics isn't easy, but it can be profitable. The analysts at our Motley Fool Inside Value newsletter can point you toward some of the most promising opportunities in the markets. Try it out free with a 30-day trial.

This article was originally published on Jan. 22, 2008. It has been updated by Dan Caplinger, who doesn't own shares of the companies mentioned in this article. Apple is a Stock Advisor recommendation and Johnson & Johnson is an Income Investor pick. Try any of our Foolish newsletters today, free for 30 days. The Fool's disclosure policy gives you security.