"When in doubt, sell."

Sometimes, you hear stock advice that is so bad, you can't help but cringe. The above is just that.

The quote comes from the chief investment advisor of an investment management company who was talking about dealing with the fallout from the disaster in Japan. I'm not going to name names because quotes can be taken out of context and perhaps this is one of those cases.

But as it stands, this is horrific advice that succinctly captures some of the biggest mistakes that an investor can make.

When nobody's in doubt
The inverse of the quote above would suggest that when you have no doubts, you should be buying. In fact, the times when investors tend to have the most confidence are usually the worst times to buy.

Back in 1999 and 2000, most investors were absolutely convinced that all Internet-related companies were going to the moon. "Old-fashioned" valuation methods no longer applied and unshakable confidence in massive future profits led most investors, like so many lemmings, to walk themselves over a massive cliff.

Ditto for 2005 and 2006. When housing prices were soaring, homebuilders were rolling in it and banks looked like they could do no wrong. There was little doubt then -- after all, housing prices never go down, right? -- and so everyone was lining up to buy.

When everyone's in doubt
I think the market may revile uncertainty more than I revile the scorpions that I occasionally find in my house (even if the market doesn't have to worry about getting up in the middle of the night and finding uncertainty on its bedroom wall). And so while the quote we started with may be objectively terrible advice, it's the advice that most investors seem to follow.

In the wake of the Internet and housing bubbles, investors lost nearly all of their confidence and took the tact of selling first and asking questions later. As the market was hitting its lows in March of 2009, United Technologies (NYSE: UTX) and Union Pacific (NYSE: UNP) had both lost more than 40% of their value over the preceding year and were trading at 7.7 and 7.4 times their respective trailing 12-months earnings. Both are venerable, high-quality companies and both had just finished reporting higher revenue and profit for 2008. Sure, both had down years in 2009, but irrational doubts and the knee-jerk sell response got the best of investors.

Of course for investors that didn't have the "when in doubt, sell" attitude, both stocks have returned more than 100% from their respective low points, while the companies' businesses have more than recovered from their one-year dips and are projected to log healthy growth going forward.

On the wrong side of doubt
Though I'd strongly encourage fellow Fools to not follow that terrible advice, I'm frankly thankful that there are investors out there that have that view. Why? Because their ill-timed buying and selling creates opportunities for me to profit.

After a near-doubling for the S&P 500 from the 2009 lows, there aren't nearly as many stocks that are being sold by doubters with itchy trigger fingers. However, we can easily find the stocks that investors currently have their doubts about by looking for low price-to-earnings multiples. The reason is that if investors are pessimistic about a particular company, then they will sell it -- or refuse to buy it -- even if the stock seems to promise a high level of profit in relation to its stock price.

Company

Forward Price-to-Earnings Ratio

Return on Unlevered Net Tangible Equity*

Microsoft 9.8 48%
IBM 12.4 65%
Pfizer (NYSE: PFE) 8.7 47%
Abbott Laboratories (NYSE: ABT) 10.5 39%
Freeport-McMoRan (NYSE: FCX) 8.8 35%

Source: Capital IQ, a Standard & Poor's company.
*A measure of profitability and returns on capital borrowed from Warren Buffett.

To be sure, this is just a starting point. While these are good measures to use to pick out high-quality companies that investors have gotten overly pessimistic about, you still need to do some research to figure out whether there is merit to the pessimism.

But could this actually work in the real world? Let me put it this way: Warren Buffett's Berkshire Hathaway (NYSE: BRK-B) announced yesterday that it's buying chemical company Lubrizol (NYSE: LZ). Lubrizol's return on unlevered net tangible equity is 32.7% and, prior to the buyout offer, its stock was trading at a mere 9.3 times forward earnings.

Doubt and fear in the face of uncertainty is natural. But the best investors are those that not only don't get pushed into rash moves by their emotions, but profit from others' irrationality.

You can zero in on the stocks above by adding them to your Foolish Watchlist.

Berkshire Hathaway, Microsoft, and Pfizer are Motley Fool Inside Value picks. Berkshire Hathaway is a Motley Fool Stock Advisor recommendation. Motley Fool Options has recommended a diagonal call position on Microsoft. The Fool owns shares of Abbott Laboratories, Berkshire Hathaway, International Business Machines, and Microsoft. Motley Fool Alpha owns shares of Abbott Laboratories. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors.

Fool contributor Matt Koppenheffer owns shares of Berkshire Hathaway, Microsoft, and Abbott Labs, but does not own shares of any of the other companies mentioned. You can check out what Matt is keeping an eye on by visiting his CAPS portfolio, or you can follow Matt on Twitter @KoppTheFool or on his RSS feed. The Fool's disclosure policy prefers dividends over a sharp stick in the eye.