Woman with notebook working at laptop © Sam Edwards, Getty Images

For U.S. stocks, the fresh records just keep coming. Last Tuesday, the S&P 500 ($INX) reached an all-time high, closing at 1,912. On Thursday, it hit another one, rising to 1,920. And on Friday, it set yet another one, stretching on its tippy toes to 1,924. That, as it happens, was the 14th time it hit a new record . . . in 2014.

The tone in market chatter is as unmistakable as it is, well, unrealistic: We are in an age of unstoppable ascents -- and how could it be otherwise?

With bargain interest rates, phenomenal corporate profitability, a gradually improving economy, and "reasonable" valuations, it's no wonder that share prices keep climbing and climbing and climbing. In that wonderful circularity of logic that is Wall Street forecasting, the serial records merely validate the optimists, invalidate the doubters, and justify still another round of cheerful predictions.

Even the legends are getting into the act: Jeremy Siegel, a highly respected expert on the equity markets at the University of Pennsylvania's Wharton School, now forecasts that the Dow Jones Industrial Average ($INDU) will close the year at 18,000. That would hand investors a handsome gain of nearly 8 percent from where it stands today.

But serene, carefree optimism can be a dangerous thing in the markets. By viewing stocks as a reasonably safe haven, investors have actually driven prices to dangerously lofty levels. Remember, profits are at virtually all-time highs by any measure -- as a ratio of sales, GDP or wages. Yet price-to-earnings multiples still hover at a pricey 18 on the S&P 500 on top of those gigantic profits.

Even cockeyed bulls have to admit that this is slippery territory.

So how can those investors determined to "stay in" make sure they aren't left flat on their backs when the ground ultimately gives way? (And it will.) The best strategy is to load up on cheap, reviled stocks and dump the super-expensive high-flyers that are largely responsible for the market's elastic valuation.

Sure, you can protect yourself with an index fund. But there can be a major problem with this broad strategy: Most index funds are "cap weighted," meaning the higher the market value of a company, the bigger its share, or weight, in the fund. In purchasing an S&P 500 index fund, for instance, investors -- many without realizing it -- are allocating a disproportionate, and growing, share of their dollars to the likes of Google (GOOG), Facebook (FB), Twitter (TWTR), Amazon (AMZN), Apple (AAPL) and many other tech and biotech companies that have top valuations but relatively small or non-existent earnings. (The exception is Apple, which carries a P/E of only 15, but gigantic margins that are a magnet for competitors, and may not be sustainable.)

The "buy what's hated, dump what's hot" approach that works best is called "fundamental indexing," and this is a great time to profit from its crowd-defying stance. The pioneer and leader in fundamental indexing is Research Affiliates, a firm that designs strategies for $169 billion in investment funds.

Its FTSE RAFI US 1000 (PRF) chooses and weights 1,000 U.S. stocks not by their market cap, but by their overall size in the economy as measured by four factors: total sales, book value, dividends and profits. Price isn't included. Hence, the fund will put a much bigger weight on a manufacturer or utility with a beaten-down price and big sales than it will on a Facebook or a Twitter. That protects investors against a potential collapse in the high-flyers, and capitalizes on the tendency of unloved stocks to reward investors far better than those that are all the rage.

"For the past seven years, growth stocks have fared better than value stocks," says Rob Arnott, co-founder and CEO of Research Affiliates, who is perhaps the foremost champion of fundamental indexing. "The current market vaguely resembles the tech bubble, though not as extravagant," he adds. "We're seeing bubble behavior."

That's where fundamental funds come in. They have a strong "value tilt" -- which is to say, they give far more weight to "cheap" (low P/E or low price-to-book) stocks than cap-weighted funds do. "Since value has underperformed for so long," says Arnott, "it's likely to snap back and beat growth."

The fundamental investing methodology, indeed, is even more likely to favor the downtrodden than traditional value funds are. That's just what investors should want in these perilous times. The P/E multiple on the Russell 1000 and S&P stands at 18; the FTSE RAFI US 1000 multiple is 16, or 11 percent lower.

The gap is far more pronounced in the other metrics, notably in terms of sales and book value. "For every $100 invested in the RAFI US 1000, you're buying more than $100 in sales," says Arnott. "For the S&P it's $60 in sales. In price-to-book, we're at 2 times versus 2.6 times. So you're buying in at a 20 to 40 percent discount on key metrics."

Given the differential in sales, for example, if profit margins on pricey stocks converge towards those of cheap stocks -- a strong possibility, frankly -- the latter will jump and the former will suffer.

"The higher the flyer, the more significantly we bet against it," says Arnott. "It's called contra-trading. Some high-flyers deserve their valuations, some don't. They're either fully priced or overpriced. The fully priced ones will do no better than perform with the market because they started out so expensive. The overpriced ones will fare badly."

For Arnott, the market is largely a popularity contest in the short-run, and investors should not only resist the urge to join in, but benefit from the excesses. "Cap-weighted indexes chase momentum, growth and popularity. Those popular stocks are perceived as not risky when they're really very risky," he argues. "In a fundamental fund, whatever is most newly beloved is what you are selling, and whatever is newly feared and loathed is what you're buying."

So how well has defying the crowd worked for investors? As it turns out, fundamental indexing has far outperformed not just the overall indexes, but also value stocks -- even in the recent, lackluster period for unloved companies. Over the past decade, the RAFI US 1000 has delivered 9.35 percent annualized gains, versus 7.4 percent for the S&P. The strategy also appears to work in global markets. The ten-year return on the FTSE RAFI All World 3000 is 10 percent, 2.3 percentage points better than the MSCI All Country World fund.

Arnott acknowledges that it takes a strong stomach to sustain the contrarian philosophy. "You need to accept discomfort," he says. "What is comfortable is rarely profitable. True bargains don't exist without fear."

Even in these complacent times, the markets feature turf where investors fear to tread. Those are the places to be. Today's contra-trading, fad-defying contrarians will be tomorrow's winners. It just takes guts to stay the course.

Click here to become a fan of MSN Money on Facebook

More from Fortune