Arguably, the most dangerous times to invest are when the market is severely overvalued or undervalued.

In the former case, the "animal spirits" that led to the overvaluation can entice investors to jump in at the worst time. On the flip side, stocks typically end up undervalued when everyone is fearful about the future and nothing seems to be going right. Panicking and selling at low points can be just as detrimental to your portfolio.

But what about times like now? If you ask me, there aren't clear signs that the market is particularly overvalued, or that it's attractively undervalued. Instead, it's sitting in some no-man's land that's flummoxing many investors -- professional and individual alike.

Over the weekend, I had some fun with the cyclically adjusted price-to-earnings (CAPE) measure that Yale's Robert Shiller keeps track of. What I found suggested a few approaches to attacking today's market.

Stay the course
In each of the scenarios that I ran with Shiller's data, I started our hypothetical investor with $100,000 in 1950 and had him investing an additional $1,000 per month. So in total, each investor is contributing $826,000 over the course of a little more than 60 years.

The first scenario mapped out what would have happened to the classic buy-and-hold investor. This guy has the emotions of a computer and not only keeps his money in the market, but diligently invested his $1,000 every month no matter what the market was doing.

At the end of the period, this buy-and-holder would have ended up with $14.5 million. Sure, he also had that much way back in 1998 -- not to mention more than $20 million in 2000 -- but it's a decent end result considering there is basically zero work involved in this method of investing. And that's not to mention that going with a brain-dead investing plan like this cuts out pricey money manager fees and a significant amount of trading costs.

For those that would rather be on the golf course than doing investment research, this may not be a terrible approach.

Do a little better
In the scenarios I ran, investors that jumped wholly in and out of the market based on valuation levels tended to do worse than those that just stayed in. However, investors that took a measured approach to market valuations tended to do a good deal better than the buy-and-holders.

For these investors, I set a valuation range below which they became buyers, above which they became sellers, and held in between (assuming they already had something in the market). Any money that wasn't in the stock market was collecting returns from Treasuries.

The two valuation ranges I used were 13.1 to 19.7 and 20.7 to 31.1, which translate to 20% above and below the long-term average for CAPE and its average over the past 20 years.

Interestingly, the two ranges didn't give vastly different results -- $17.5 million and $17.1 million, respectively. To me, this suggests that the specifics of the range -- within reason of course -- weren't as important as just having firm parameters for where you're buying and selling.

This valuation-range approach could certainly be put to work today, but what range should you go with? The range based on the long-term CAPE average hasn't seen a buying opportunity since 1986, so that might be a bit too conservative. On the flip side, the only period that the CAPE has only gone above 31 -- the upper end of the other range -- was during the dotcom bubble, so that might not be conservative enough.

In my opinion, the best range is in between the two extremes -- I might suggest using the 20-year average of 25.9 and the long-term average of 16.4 as your upper and lower bounds.

Forget the market and do even better
A third option for those willing to do more work is to stop worrying about what the market as a whole is doing and look for individual stocks.

As the name suggests, the S&P 500 is made up of 500 stocks, and those stocks are chosen primarily based on size, liquidity, and representativeness of the U.S. economy, not valuation. So when you invest in the entire S&P 500 index, you're getting a mix of stocks that are fairly valued, undervalued, and arguably overvalued.

Company

Trailing Price-to-Earnings Ratio

Forward Price-to-Earnings Ratio

Amazon.com (Nasdaq: AMZN)

53.5

41.5

Intuitive Surgical (Nasdaq: ISRG)

44.2

37.1

Sears Holdings (Nasdaq: SHLD)

41.4

35.2

Medtronic (NYSE: MDT)

13.6

10.8

ExxonMobil (NYSE: XOM)

13.6

10.2

Northrop Grumman (NYSE: NOC)

11.1

9.8

Aflac (NYSE: AFL)

12.4

7.6

Source: Capital IQ, a Standard & Poor's company. As of June 4, 2010.

Now, are the companies on the top of this list definitely overvalued? In short, no. Amazon and Intuitive Surgical are both surging growth companies, and heady growth could prove today's valuations to be reasonable. Sears, meanwhile, is a turnaround story. Thus far, the turnaround has been more story than actuality, but if Chairman Eddie Lampert can get some traction, investors think the results could be impressive.

The point, though, is that if you buy the entire index, you don't have any choice but to take on those potentially overvalued stocks.

If, however, you invest in stocks individually, you can stop worrying about the market's valuation and focus on finding stocks that have undeniably attractive valuations. The four stocks on the bottom half of this list weren't chosen at random -- I believe that all of them could be good investment candidates right now. On top of the low valuations, they are all high-quality businesses that appear to have bright futures ahead.

Exxon is the 800-pound gorilla in its industry and may even be the greatest company out there. Northrop Grumman relies heavily on the only customer that can be relied on to spend in this rocky economy -- the U.S. government. Medtronic is a leader in the medical device industry that's delivered average annual profit-per-share growth of almost 14% over the past five years and is expected to keep up at least 10% growth in the years ahead. And after a strong first quarter, Motley Fool Stock Advisor pick Aflac looks ready to bounce back from some profit-slashing investment losses it took during the market's downturn.

Though these are far from the only opportunities out there right now, I think they're very representative of the kind of bargains that can still be found for investors willing to apply a little extra elbow grease.

Chime in
Though I've stashed a portion of my investable cash in indexes, my preference is always toward getting down and dirty to find undervalued stocks. But I want to know how you're handling today's market. Head down to the comments section and share your approach.

Can sticky sales give a company an edge? You bet your butt!

Intuitive Surgical is a Motley Fool Rule Breakers recommendation. AFLAC and Amazon.com are Motley Fool Stock Advisor picks. The Fool owns shares of Medtronic. Try any of our Foolish newsletters today, free for 30 days. The Motley Fool has a disclosure policy.

Fool contributor Matt Koppenheffer does not own shares of any of the 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 assures you no Wookiees were harmed in the making of this article.