Many stocks in the S&P 500 are near their 52-week highs. But that doesn't mean they can't keep climbing higher.

The opinions expressed in this commentary are solely those of Paul R. La Monica. Other than Time Warner, the parent of CNNMoney, Abbott Laboratories and AbbVie, La Monica does not own positions in any individual stocks.

Nearly three-quarters of the stocks in the S&P 500 are trading near their 52-week highs.

That might sound like a great excuse to sell. But strangely enough, the market's momentum may be a sign that stocks could keep climbing.

However, there is evidence that investing in stocks even when the bull is starting to show some signs of age is not a terrible idea.

According to research from Pavilion Global Markets, a brokerage in Montreal, the market has historically continued to rally when a large number of stocks are already near their 52-week highs.

Pavilion found that since 1991, the S&P 500 rose an average of nearly 9% during the twelve months following a period when at least 75% of the companies in the index were within 10% of their 52-week highs.

That doesn't mean that stocks are going to go up without any hiccups. Pavilion also found that the S&P 500 actually dipped 2% during the first three months after a big chunk of stocks got close to their highs.

That makes sense. Many experts feel that the market is due for a small pullback, if not necessarily a major correction. And over the past two decades, it appears that stocks usually do slip immediately after getting near a new peak, and then wind up rallying again after the sell-off.

Of course, this time might be different. Many stocks are not just at 52-week highs. They are at all-time highs. There are also many reasons for investors to be nervous.

That's why investors looking to jump on board the momentum bandwagon need to be careful. Some stocks trading near their highs are way too risky. But it's a mistake to declare that every stock that is up a lot must be overvalued simply because it has gone up a lot. Many stocks rise because they are great, growing companies.

So I ran a screen (courtesy of our trusty Thomson Baseline machine) to find stocks near their 52-week highs that still have reasonable valuations, healthy earnings prospects and low debt loads. Those are the types of companies you want to own for the long haul, and they should hold up better than others if the broader market does pull back.

The companies that came up on this screen are an interesting mix. Among them are CVS Caremark (CVS), Bank of NY Mellon (BK), Corning (GLW), Southwest Airlines (LUV) and Whirlpool (WHR).

Finally, investors shouldn't completely ignore stocks that are closer to their lows than their highs either. It's always a gamble to bet on a stock that's fallen out of favor on Wall Street. Something that may look like a steal may be cheap for a reason -- the proverbial value trap.

But if you time a rebound (or even just a shift in sentiment) right, it can be lucrative. Pavilion found that since 2001, the 30% of stocks in the S&P 500 that were furthest from their 52-week high actually outperformed the 30% that were closest to their 52-week high by a slim margin.

That suggests that the overall market could keep going up, but the companies leading the rally may change. We've already seen a rotation out of some of last year's hot stocks like Apple (AAPL) and Whole Foods (WFM).

While I'm still a little skeptical that struggling firms like Hewlett-Packard (HPQ), Best Buy (BBY) and BlackBerry (BBRY) are on the path to a long-term recovery, you can't argue with how the stocks have done this year.

That said, you'll be able to sleep a lot better at night if your portfolio has a mix of contrarian stock picks on the verge of a turnaround as well as shares of attractively valued companies that have done well because of great fundamentals.

The notion of buying low and selling high may need an update. But diversification never goes out of style.