Pop quiz, hotshot: The S&P is up 65% from its closing low last March. If the market continues to go up, you want to ride along with it. But if it reverses course, you want to protect your nest egg. So what do you do?

The answer seems obvious, right? U.S. unemployment is still close to double digits, we've yet to touch the financial industry with any reforms, and mortgage delinquencies are hitting new highs and threatening to be a drag on major mortgage lenders like Wells Fargo (NYSE: WFC) and JPMorgan Chase (NYSE: JPM). It's time to sell!

But wait just a second there. First quarter earnings reports are continuing to come in with very strong numbers. Earlier this week, both Hewlett-Packard (NYSE: HPQ) and Target (NYSE: TGT) reported better-than-expected numbers, highlighting some strength in two important parts of the economy. Hewlett-Packard sounded a particularly bullish note -- not only did it raise its full year guidance, but its CEO quipped that he is "confident in the enormous opportunity that lies ahead." Target may not have been quite as bullish, but the retailer said it's seen customers putting more in their baskets, and that it expects continued growth in the quarters ahead.

Meanwhile, the Federal Reserve is continuing to goose the economy with low interest rates, and many economists seem confident that the recession is over and the U.S. is returning to growth. For Pete's sake, buy!

Don't mind the 65%
Stock market commentators tend to be a rather fearful bunch. When times get bad and the market is sinking, many of them seem to suffer from taphephobia -- a fear of getting buried alive -- and they want to run for the hills as quickly as possible. On the flip side, when the market is shooting up, acrophobia -- the fear of heights -- seems to come into play and, well, they're off running for the hills again.

But if you ask me -- or, really, any fundamentals-oriented investor -- our concern shouldn't rest with how much the market has gone up or down, but rather whether its valuation is attractive or unattractive. If a hot market with sky-high valuations rises 65%, that acrophobia is probably warranted. On the other hand, if a sorely undervalued market tacks on that same 65%, there could still be good reason to buy. 

Do mind the valuation
There are many ways to track the market's valuation, but I'm a big fan of the work that Robert Shiller of Yale has done. He maintains a spreadsheet that tracks the S&P's price and earnings going all the way back to 1871 and tracks the market's valuation by comparing price with the average earnings over the past 10 years.

The long-term average P/E ratio is around 16.4. The current readout is just above 20, which is up from 13.3 in last March, and down from 27 prior to the market's crash. While we could say that we're still below pre-recession valuation levels, it's hard to say that today's valuation is particularly attractive compared to the long-term average.

Fortunately, earnings are starting to recover. If first-quarter earnings hit S&P's estimates, then total S&P 500 earnings over the past year will be more than $60. This is still below the trailing earnings from the same period in 2005, but it's a heck of a lot better than the single digit earnings that were posted in 2009. And S&P seems to think we're going to continue to move in the right direction and be above $80 by 2011.

If we switch our view to a single-year P/E, S&P's improving earnings show that valuations are currently below their average of 22.7 over the past 21 years. Which, of course, sounds more bullish than the data we pulled from Shiller.

So what do you do?
Back in March of last year, when the market's valuation was undeniably low, it was difficult to go wrong with buying an index fund and calling it a day.

Sure, you could have trounced the market by buying certain individual stocks such as Ford (NYSE: F) (up 564%) or Intuitive Surgical (NYSE: ISRG) (up 243%). But you'd have had to trust that Ford wasn't going to follow the other major U.S. carmakers into oblivion to take a chance on its stock, while shrugging off fears that lack of available credit would crimp Intuitive Surgical's sales to jump on that one.

And if you skipped out on those gut-churning wagers, you still would have done quite well with a simple index.

If you're a long-term retirement investor and you want to keep it simple, you still may be OK grabbing those index funds today. For investors who like to put on a hard hat and go prospecting for the best stock opportunities, though, now is a good time to start eschewing the index funds in favor of individual stocks that are still undervalued. 

Now there's probably an argument to be made that both Ford and Intuitive Surgical are still good picks today. Ford has actually benefitted from the fall of its competitors by picking up market share, while Intuitive Surgical has continued to grow at a torrid pace. However, Intuitive Surgical is trading at an astronomical valuation, while Ford still has a huge debt load to contend with. And with certifiable blue chips trading at very reasonable valuations today, I think there are better deals to be had.

ExxonMobil, for example, is still trading at less than 11 times its expected 2010 earnings, which is much more attractive than the broad S&P index. With Exxon, you get the 800-pound gorilla in the energy industry and take home a 2.8% dividend to boot.

Meanwhile, Cisco (Nasdaq: CSCO), the hands-down leader in networking hardware, is trading at a forward P/E of 14.6. And that's after reporting a blowout quarter that the company's CEO called its best ever, and taking a bullish stance on the company's growth in the next quarter.

And while I think the stocks of those blue-chip candidates could perform quite well, there may be even more opportunity for investors willing to consider small-cap stocks. The world of small caps is a largely uncharted sea of stocks that most institutional types avoid because they're too small to make an impact on huge mutual fund portfolios. For individual investors, though, they can be a great way to find hidden value -- particularly at the front end of an economic recovery.

If you're looking for stock ideas, the advisors at Motley Fool Hidden Gems are a great resource for new or veteran small-cap hunters. You can see their six Buy First stocks and read the research on all of their recommendations free for 30 days. Click here to get started.

This article was first published Aug. 4, 2009. It has been updated.

Fool contributor Matt Koppenheffer does not own shares of any of the companies mentioned in this article. Intuitive Surgical is a Motley Fool Rule Breakers pick. Ford Motor is a Motley Fool Stock Advisor recommendation. The Fool's disclosure policy enjoyed Speed in spite of Keanu Reeves.