Value investing tends to outperform in bear markets, though you wouldn't know it from the performance of many value investors last year.

And we fared little better. Yes, our Motley Fool Inside Value newsletter, which focuses exclusively on undervalued stocks, did outperform the market, but we'd rather outperform the market with positive returns.

The truth is that it was nearly impossible last year to make money with a long-only portfolio. Even solid companies that looked reasonably priced based their historical performance, like Vornado (NYSE:VNO), American Eagle (NYSE:AEO), and FedEx (NYSE:FDX), struggled as the slowdown affected almost every sector of the economy.

Nevertheless, several of our picks had solid returns last year, including one that we recommended in 2007. In April 2008 we recommended that our subscribers sell it -- despite it being up 80% from our initial recommendation. And then it started to decline.

We weren't timing the market -- we were just being disciplined value investors. That can not only make you money, but also help you keep it. And that's critical in a market like this one.

Let me tell you how we did it.

The business
The stock was Cimarex Energy (NYSE:XEC), a mid-cap natural gas and oil producer with wells in the southwest United States and the Gulf of Mexico. When we recommended it, the company had 1.4 trillion cubic feet equivalent (tcfe) of proven reserves, making it a solid, but not huge, player in the industry.

Almost all of our Inside Value picks have strong market positions, so it's noteworthy that Cimarex had relatively few competitive advantages. Cimarex's revenue was almost entirely dependent on oil and natural gas prices, and its main competitive advantage was that all its production was U.S.-based, which reduced political risks and kept its production close to its primary markets.

What we liked
Why would we recommend a company with only mild competitive advantages in a commodity business? Because the stock had a shareholder-friendly management, a solid balance sheet, and a cheap price tag.

Many oil and gas companies spend their capital increasing proven reserves; they consider generating cash simply an afterthought. Not so for Cimarex, where management focused on allocating capital to the highest-return projects. As a result, Cimarex generated almost $9 per share in cash flow in 2006, which was a lot, considering the shares were trading in the mid-$30s.

What's more, the company wasn't using massive leverage to achieve that cash flow. The balance sheet only had $400 million in debt -- a conservative amount for a business that had almost $900 million in cash from operations. A company with these characteristics could handle rough times.

Bargain bin
What's more, every way we looked at it, the company was cheap. Cimarex was trading at a ratio of enterprise value to mcfe of proven reserves of $2.45. In the preceding year, Devon Energy (NYSE:DVN), EXCO Resources (NYSE:XCO), and Anadarko (NYSE:APC) all made acquisitions at prices greater than $3.50 per mcfe of proven reserves. By that measure, Cimarex was trading at about 68% of its fair value.

We also looked at Cimarex using our own models. If long-term gas prices averaged $6.50 per mcfe and oil prices averaged $60 per barrel, we thought the stock was worth about $52, which made $35 an attractive entry point. What's more, in a world worried about peak oil, these estimates seemed conservative. A $1 increase in natural gas prices would increase our estimate of the value of the shares by $15.

In combination, these factors implied that shares had good upside potential if natural gas spiked, yet were relatively low risk if natural gas prices remained weak.

The outcome
The stock rose 21% between our recommendation and the end of 2007 -- and then natural gas began an ascent, eventually surpassing $13. Cimarex followed. With natural gas prices so high, the company was raking in the cash.

And we recommended that our subscribers get out.

It might seem counterintuitive that we recommended a sell when natural gas prices were high and the future seemed bright. But we got out because we adhere to strict value investing criteria.

Cimarex didn't appear to have any particular advantages in growing its future production, and we saw no reason why natural gas prices deserved to be substantially higher than our long-term estimate of $6.50 per mcfe. In other words, we couldn't conservatively value Cimarex at substantially more than our original $52 estimate -- but the stock was selling for $63.

We got out just before the stock started falling. Because of that decision, we avoided Cimarex's recent descent below $25.

The Foolish bottom line
Part of being a value investor is investing defensively. We don't want to lose money, and that means not just buying when a stock is undervalued, but also selling when a stock is overvalued. This strategy helps you hold on to your profits and provides cash to invest in other undervalued stocks -- all without trying to time the market.

The opportunities present in the market today are far more compelling than they were when we recommended Cimarex. For instance, we've identified an energy company that shares many of Cimarex's attributes -- but while Cimarex was trading at 68% of its fair value when we recommended it, this stock is trading at only 28%.

We think the potential upside is huge. If you'd like to learn more, just click here for a free, 30-day trial to Inside Value. You can read all about it -- as well as all about all of our other recommendations -- and there's no obligation to subscribe.

Before he became an investor, Fool contributor Richard Gibbons always thought gas was rather unattractive. He owns shares, calls, and is short puts on Inside Value's other energy pick. FedEx is a Motley Fool Stock Advisor choice. The Motley Fool owns shares of American Eagle Outfitters. The Fool's disclosure policy likes to move it, move it.