Can you believe this rally? After falling more than 57% from its October 2007 peak to the recent March lows, the S&P index has come back in a big way, notching a 33% gain since its nadir. If you were scared out of the market a couple of months ago, or worse, decided to jump on the short-selling bandwagon, you can't be a happy camper right now.

But as I watch banking stocks like Wells Fargo (NYSE:WFC), tech stocks like Research In Motion (NASDAQ:RIMM), and industrials like Caterpillar (NYSE:CAT) notch unbelievable gains, I can't help but wonder how far this can go. Sure, the market is still down more than 40% from its peak, but are we on a crash course with that peak number in the near future? Or will the market have to hit the brakes?

As always, don't time the market
You may think this is where I say, "Don't worry about when the rally will end! You can't time the market." And you're right ... sort of.

The ability to time the movements of the market, whether through sheer clairvoyance or patterns that show up in charts, is something that -- like sea monsters -- I hold could be true. But I remain skeptical. However, that doesn't mean we need to be totally clueless on where the market could be headed.

Just as investors concern themselves with the valuations of individual stocks, we can also look at the valuation of the market as a whole. When the market's valuation is low, it's a great time to be a buyer, and when it's high, it's time to get more cautious.

Why there's reason for worry
Looking back over more than 100 years of price and earnings data for the S&P (which has been compiled by Yale professor Robert Shiller), the average trailing-12-month price-to-earnings ratio of the index has been 15. So, generally speaking, it's been a good thing from a valuation perspective to be a buyer when that multiple falls below 15, and you've generally been better off being a seller -- or at least being more cautious -- when it climbs above 15.

It's difficult to make comparisons to today's valuations because, although the market has fallen precipitously since its peak, so have earnings. In fact, thanks to massive losses taken in various sectors of the economy, Standard & Poor's reported an overall loss for its primary index in the fourth quarter. And while we may not see loss levels that high going forward, current projections from S&P show a slow climb for earnings through the end of next year.

But climbing earnings is good, right? Of course it is. But the problem comes when share prices have climbed even faster. Assuming S&P is correct about its projection for 2010 earnings, the P/E for the S&P index at the end of 2010 would be 26 -- if we don't gain another single point between now and then.

This, of course, doesn't account for the possibility that the global economy isn't in the clear. There's a lot of media talk about "green shoots" showing up in the economy, but green shoots are young and fragile, and they can die off before flowering.

But then again ...
Does this mean I'm getting ready to short the daylights out of the market? Hardly. While I see reason for caution after such a raucous rally, there are some good reasons to avoid total bearishness.

First of all, as Millennium Wave Advisors' John Mauldin has pointed out on a few occasions, S&P wasn't exactly a steady hand when projecting earnings for 2009. After pegging 2009 earnings for the S&P 500 index at $81.52 in March of 2008, it has steadily cut that estimate and today it stands at $28.51. Could S&P be incorrect in the other direction when it comes to 2010? Sure seems like a possibility.

Additionally, one could argue that because of the influx of index, mutual fund, and individual investors in the market, there is a "new normal" for the market's valuation. Indeed, the average one-year P/E of the market over the past 20 years has been 23, versus 15 for the entire Schiller data set. However, I'm always skeptical of anything that implies "it's different this time," so I'm not so keen on this theory.

Finally, while the valuation of the overall market may be worrisome, that doesn't mean that some individual stocks aren't bargains. Microsoft (NASDAQ:MSFT) is still growing sales and trades at 11 times its trailing earnings. Fast-growing Latin American cell carrier America Movil (NYSE:AMX) is changing hands at 13 times earnings.

And for those investors who think a recovery for oil is in the cards when the economy turns around, oil majors like ExxonMobil (NYSE:XOM) and ConocoPhillips (NYSE:COP) could stand to gain as well.

Finding the middle road
So how high can stocks go? Well, they could certainly go much higher, though the data I've shown you indicates that they may have gotten ahead of themselves. Now may be the time for savvy investors to crank up the caution just a bit, even while they capture much of the additional gains the market racks up during this swing. Among other things, that means evaluating companies on a case-by-case basis to ensure that you're selecting only the best companies at bargain valuations.

If you'd like some help getting started, the advisors at Motley Fool Inside Value have just identified their top five stock recommendations on both a pure upside and a risk-adjusted basis. Click here to read all about their favorite stocks, free for the next 30 days. There's no obligation to subscribe.

Fool contributor Matt Koppenheffer does not own shares of any of the companies mentioned. Microsoft is a Motley Fool Inside Value recommendation. America Movil is a Motley Fool Global Gains selection. The Fool's disclosure policy has never once been caught with its pants down. Of course, it doesn't actually wear pants.