As stocks have headed ever higher with hardly any breaks recently, stock investors have faced an increasingly difficult dilemma. Should you invest the money you have on the sidelines now and face the possibility of buying in at exactly the wrong moment, or should you stay out of the market and potentially miss even bigger gains in the months and years ahead?

Even though there's no way to be sure what the market will do in the future, there is a middle ground between those stances -- one that gives you a chance to earn higher returns than you'll get in cash while not leaving you dangerously exposed to the whims of the overall market's movements.

The ongoing battle of fear and greed
It's clear that investors are struggling to figure out how to put their money to work. In January, mutual fund inflows into U.S. stock funds were the highest in nearly seven years, with more than $21 billion going in to domestic stock funds during the month.

Those inflows once again show the performance-chasing nature of most mutual fund investors. Only after nearly two years of huge gains are regular investors getting their money into stocks. After fleeing during 2008's bear market, they're more confident about stocks after the ensuing bounce.

Unfortunately, there's a good chance that those who pile willy-nilly into stocks at these levels will be disappointed. Having missed out on nearly doubling their money since the March 2009 lows, S&P index fund investors have a lot less upside than they did back then. The price of waiting until risk was out of the market is that stocks are more expensive -- and with pricier valuations, most stocks lack the margin of safety they had before the recovery. By itself, that doesn't make index funds a bad investment, but if you're looking for gains of 15% to 30% to continue well into the future, you're going to end up disappointed.

Be smart about stocks
Although experts argue about whether the market is fairly valued or overpriced at these levels, one thing is clear: Stocks on the whole aren't the screaming bargain they were two years ago. You can't expect to just throw darts at the newspaper stock listings and come up with a winner.

What you should do is make smart decisions about picking stocks that still have room to run. That involves taking one of two tacks:

  • Grab beaten-down values. Even though most stocks have risen sharply in the past two years, some have been left behind. A couple of sectors that haven't seen much appreciation lately are health care and utilities, both of which have to deal with increasing levels of government involvement. Pharmaceutical companies Abbott Labs (NYSE: ABT) and Eli Lilly (NYSE: LLY) have seen their stocks go mostly nowhere as they grapple with both the uncertainties of health care reform and their own individual pipelines. Health insurance providers WellPoint (NYSE: WLP) and Aetna (NYSE: AET) reported strong earnings recently, but new laws governing insurance coverage could eventually have a big impact on its business as well. And in the utility sector, Exelon (NYSE: EXC) trades at an earnings multiple of less than 11 yet pays a dividend of nearly 5%.
  • Stick with the stalwarts. Just because a stock has risen doesn't mean that it's automatically a bad value. As an example, both Disney (NYSE: DIS) and Accenture (NYSE: ACN) have seen their shares rise sharply in the past two years, with Accenture up 75% and Disney much more than doubling. Yet with forward P/Es of less than 15, they still have the potential for strong future returns despite having had a great run in the past.

Don't give up
When the stock market has had as great a run as it's had lately, it's tempting to think that you've already missed out and should stay on the sidelines. But while now might not be the best time to dump a ton of money into the broad stock market, it is a perfectly good time to buy stocks that still represent good value. Do that, and you'll put yourself in the best position to take advantage of whatever happens next for the stock market.

Great stocks are just a click away. Read our special free report, "The Motley Fool's Top Stock for 2011," and learn about one stock that has potential for huge future gains. Get instant access by clicking here -- it's free.

Fool contributor Dan Caplinger tries to get an early start to just about everything. He doesn't own shares of the companies mentioned in this article. Accenture, Exelon, and WellPoint are Motley Fool Inside Value recommendations. Disney is a Motley Fool Stock Advisor recommendation. The Fool owns shares of Exelon. Motley Fool Alpha owns shares of Abbott Laboratories. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Fool's disclosure policy is never late to the party.