In a perfect world, we'd know exactly what every company is worth. In that same world, we'd also be able to exchange cash and shares without worrying about friction costs like commissions, taxes, and SEC fees. With that perfect knowledge and cost-free trading, market-beating investing would be simple. We'd just buy a company if it traded below its fair value, then turn around and sell it if it jumped past that level. And because we would know a firm's exact worth, there'd never be a question about making the right decision.

Unfortunately, this isn't a perfect world. We're forced to pay a broker for access to the market, and we're forced to pay the SEC for maintaining an orderly and fair playing field. Plus, if we manage to make a profitable trade, the federal government and most states expect a cut of the profits. Because of these costs, investment moves that would have made sense in a perfect world often don't make sense in ours.

For example, imagine you bought biotech firm Elan (NYSE:ELN) at the end of last April, when it could have been picked up for about $5.51 a share. In your foresight, you knew -- better than the market did at the time -- that Elan's Tysarbi treatment for multiple sclerosis would not be completely abandoned. Confident in your analysis, you pegged Elan's potential value at $13 a share, assuming the eventual reintroduction of Tysarbi. Eventually, the market woke up to your superior analysis and rocketed Elan's shares skyward, nearly tripling your investment in under a year. Recently trading at about $14.26, however, Elan is now priced above what you think it's worth. In a perfect world, you'd want to take advantage of its high price and sell.

Friction burns
In our world, however, you also have to consider how much you'd keep after factoring in all costs of selling. Say, for instance, that you're in the 25% federal and 5% state tax brackets and that you itemize your taxes. By selling, you'd have a short-term capital gain of about $8.75 a share, and you would owe about $2.52 in taxes for each share sold. After paying those taxes, you'd end up with about $11.74 a stub. Here's your new predicament: Would you rather hold a $13 company trading at $14.26, or would you rather have $11 and change in cash?

I typically won't sell a company unless I can keep more than I think it is worth. In that example, I'd need an amount substantially greater than $13 after taxes to make selling worthwhile. Why pay my broker and the government only to end up with a result worth less than had I done nothing? That's the primary reason why I still own my shares of air conditioning company Lennox International (NYSE:LII), in spite of its approximately 55% run since I purchased it in March 2004. While its shares now appear fully valued, my costs of selling would knock down what I'd keep to less than what the business is worth.

Reply hazy? Try again
In addition to the costs of selling, no matter how thorough our valuation models, they're all based on projections and estimates of the future. Slight changes to our assumptions could have dramatic effects on what we think a business is really worth. In his evaluations, Motley Fool Inside Value analyst Philip Durell uses a technique known as discounted cash flow calculation to find bargains for subscribers. Using that method in November 2004, he originally pegged First Data (NYSE:FDC), the parent company of Western Union, as being worth about $52 a stub. Yet just by adjusting things a tiny bit, that number can change radically -- for the good or the bad. You can see this effect for yourself using Inside Value's online cash flow calculator, which is available here for subscribers (if you're not yet on board, click here to start your 30-day free trial).

It's important to understand the business behind the stock. That way, the numbers you use make realistic sense for the company. For instance, it makes no sense to assume that oil titan ExxonMobil (NYSE:XOM) will always grow its earnings as quickly as it did last year. Oil is an inherently cyclical business. When high prices start looking sustainable, businesses and governments start looking to invest in increased production capacity. With enough investment in production capacity, supply will start to outstrip demand, leading to a surplus and lowered prices, thereby reducing profitability. Incorrectly assuming that last year's growth would be perpetually sustainable would lead you to peg the company's value dramatically above its true worth.

Your weapon against uncertainty
Fortunately, value investing pioneer Benjamin Graham came up with a solution to this conundrum, which he called the margin of safety. To use Graham's margin, make your best projection of a company's true worth, then knock off a decent chunk from that value. If the firm's stock is trading below even the discounted price, then it's time to buy. On the flip side, the time to sell is when that stock is trading so far above its true worth that you'd keep a margin above the highest value you could realistically calculate for the business.

To illustrate, while I've often been accused of being an XM Satellite Radio (NASDAQ:XMSR) basher, I do believe the high-tech radio pioneer is worth something. Specifically, I think a case could be made for a valuation somewhere between $12 and $16 a share, based on a discounted cash flow analysis that incorporates a few generous assumptions such as:

  • improved cost controls
  • decent medium-term growth
  • reduction in the rate of share dilution
  • a cease-fire in the costly talent bidding war with archrival Sirius (NASDAQ:SIRI)
  • mutually beneficial coexistence with content and station providers like Clear Channel (NYSE:CCU).

To get a margin of safety on the buy side, if my assumptions hold true, I might be willing to buy if its shares dropped below $9.60. That's 20% below the low end of what the company just might be worth.

Conversely, if I happened to already own XM, I wouldn't be selling it unless I could keep at least $19.20 from the transaction. Not surprisingly, that's 20% above the high end of what I think it could be worth. Thanks to brokerage commissions, SEC fees, and taxes, I'd probably need to sell it at about $24 to end up keeping that much. This means that I wouldn't be buying XM at its recent price of $23.30, and if I happened to own it, I'd probably start to consider selling it.

The Foolish bottom line
In the end, it's what you keep after all costs that really counts. Your job as an investor is to maximize your net worth. To do that, you must be focused on buying low enough to get a discount to a company's fair value and selling high enough to keep a surplus above its true worth. In between those prices, any moves might cost you more than they're worth.

Do you like the idea of using both a company's true value and what you'll keep when all is said and done to tell you when to buy and when to sell? Take a free trial of Inside Value and see how it's done. Subscribe today, and we'll send you a copy of Around the World in 80 Minutes, the Fool's guide to international investing,absolutely free.

This article was originally published on Feb. 3, 2006. It has been updated.

At the time of publication, Fool contributor and Inside Value team memberChuckSalettaowned shares of Lennox International. First Data is a Motley Fool Inside Value recommendation. XM Satellite Radio is a Rule Breakers recommendation. The Fool has adisclosure policy.