Bet against the masses. Don't be the lemming. Be fearful when others are greedy.

Follow these simple rules, and you'll probably be a successful investor.

With those rules of thumb in mind, you'd be forgiven for thinking now is a terrible time to buy stocks. The S&P 500 is up more than 50% since March, which is typically consistent with a market flooded with uncontrollable euphoria. Sure enough, many are preaching about an overvalued market that's gotten way ahead of itself.

Oh really? 
And maybe they're right. Sooner or later, they probably will be. But perspective is in order: When stocks bottomed out earlier this year, a better part of the investment community thought the world was about to explode. Companies like American Express (NYSE:AXP) and Ford (NYSE:F) traded for trivial valuations because, quite literally, some feared imminent implosions.

Today, it looks like we've skirted most of those calamitous end-of-the-world threats. It's still terrible, mind you, just not as terrible as many thought. Naturally, stocks have sprung back to levels that reflect a deep recession, rather than a total Mad Max scenario.

This is an incredibly important distinction to make: Markets haven't risen to levels reflective of exuberance, but to levels consistent with a world that isn't about to fall into mass insolvency.

This is evident by looking at the biggest winners over the past few months. By and large, the stocks that have risen the most are ones you wouldn't recommend to your worst enemy. Have a look:

Company

3-Month Return

2009 EPS Estimates

Dollar Thrifty Automotive

238%

($0.30)

Avis Budget Group

196%

($0.06)

ArvinMeritor

249%

($1.45)

Data from Yahoo! Finance and Google Finance.

Are these companies destined for greatness? Did they announce a new blockbuster product? Are they the next Apple (NASDAQ:AAPL), waiting to change the way we live? Goodness, no. Not even close. Their huge gains are simply a reflection that they'll live to see another day.

In general, this is a rally built on canceling out past pessimism. The biggest gains have been concentrated in very low-quality companies that are simply being given a second shot at life.

Not all gains are created equal 
The idea that a stock is overvalued after a massive run-up is contingent on the idea that it was properly priced to being with. But this was hardly the case when the market bottomed in March. More importantly, some of the highest-quality companies in the world have largely been left out of the rally and still trade at attractive prices.

Here are three in particular:

Company

3-Month Return

Forward P/E Ratio (FY 2010)

Allstate (NYSE:ALL)

9.97%

7.0

Safeway (NYSE:SWY)

(5.24%)

9.7

Procter & Gamble

0.28%

12.8

What's to like about these three? Glad you asked:  

  • The most important thing you need to know about Allstate is that it isn't AIG (NYSE:AIG). It's an insurance company that operates in the way insurance companies have for centuries. But investors who fled this company's shares in droves over the past year will hear nothing of it. Good insurers have been thrown out with the bad, leaving Allstate -- proud decliner of all taxpayer help it was offered -- down to a pathetic seven times forward earnings. If you think that's an appropriate valuation, you're living in the same panic-filled world that enabled the March lows.
  • Safeway gets overlooked because it isn't Whole Foods (NYSE:WFMI). But this grocery store chain is doing everything it can to catch up. Safeway created, and is signing up other grocery retailers to sell, a semipremium line of organic foods. Getting other grocers to sell your private-label products is a brilliant move that can ignite growth in an otherwise tepid industry. And yet shares still trade at all of 10 times forward earnings.
  • Whether you know it or not, you probably use several Procter & Gamble products. Its strong brands -- which range from Gillette to Cascade to Tide -- are in your bathroom, kitchen, and laundry room. Since 1994, P&G shares have traded at an average of more than 26 times earnings. Today, you can pick them up for under 13 times earnings. That's the kind of opportunity that makes investing in recessions such a blast. 

Onward 
Perspective can be a powerful thing: One year ago, Dow 9,500 would have been associated with the end of the world. Today, some want to treat it like it symbolizes irrational exuberance simply because we've bounced so far off the March lows. This is inherently flawed thinking. Focusing on a stock's percentage change over a short period of time is utterly meaningless. Drilling down on a company's intrinsic value and buying bargains like we haven't seen in decades is what's important.

And that's why our Motley Fool Inside Value team of analysts is having a field day digging through the rubble and finding cheap stocks like never before. If you'd like to see what they're recommending right now, click here to try the service free for 30 days. There's no obligation to subscribe.

This article was first published on June 25, 2009. It has been updated.

Fool contributor Morgan Housel owns shares in Procter & Gamble. Apple and Whole Foods are Motley Fool Stock Advisor recommendations. American Express is a Motley Fool Inside Value selection. Procter & Gamble is a Motley Fool Income Investor recommendation. The Fool owns shares of Procter & Gamble and has a disclosure policy.