We all invest for the same reason: to make money. And in order to make money investing, we need to know two key things: when to buy and when to sell.

If you can buy something for a dollar and turn around and sell it for $2, then you've made money. If, on the other hand, you buy for a buck and can't find someone willing to buy it for more than $0.50, you've lost money. Clearly, to make money at investing, the goal is to buy low and sell high. More than half a century ago, Benjamin Graham, the pioneer of value investing, came up with a simple way to do just that -- a concept known as the margin of safety. By deploying this technique, investors greatly increase both the chance that they won't lose their hats, and the likelihood that they'll trounce other investors.

Following in Graham's footsteps, Bill Miller, who runs Legg Mason Value Trust (FUND:LMVTX), has beaten the market for 15 consecutive years -- practically unheard-of in the mutual fund industry. Bill's long-run performance pales in comparison to that of Warren Buffett, a former pupil of Graham's and current head of Berkshire Hathaway. What's more, Graham's margin of safety is something we put to good use here at the Motley Fool Inside Value newsletter.

Know a company's true worth
The key to success is a clear understanding of a company's true worth. With that knowledge in hand, buying low and selling high becomes a simple matter of waiting and buying a stock only when it falls below the company's true worth by a tempting margin. Once you own it, you need to keep tracking the company's value. When the stock rises to an uncomfortably high premium to the company's true worth, sell it. The central lesson: All buying and selling decisions should be guided by comparing a company's stock price to its true worth, not by some vague notion of what the hot stock of the moment is.

My friend and colleague Philip Durell follows that philosophy as chief analyst at Inside Value. His selections as a whole have just about tripled the market's return since the newsletter's inception last year. His record is added proof that using the margin of safety truly does work.

Philip has beaten the market without help from the likes of Internet search titan Google (NASDAQ:GOOG) and its 334% return since its initial public offering in 2004. Instead, Philip has relied on stalwarts like Lloyds TSB (NYSE:LYG), a leading British bank with a better than 6.5% dividend yield. Philip recommended Lloyds when it traded for $31.79, but he figured it was worth $44. Sure, Lloyds hasn't rocketed skyward like Google has, but Lloyds' investors can sleep soundly at night, knowing that at current valuations they get paid back more in dividends per dollar invested than Google takes in as revenues per dollar invested. Not only that, Inside Value readers got the chance to buy Lloyds at an attractive discount to its true worth.

Buying low with the margin of safety
Every company has what Graham calls an "intrinsic value," a measure of what a company is really worth. Finding that value is part art and part analysis. One of the most powerful tools in a value investor's toolkit is a discounted cash flow calculator, into which you put your estimate of how much cash the company will generate in the ensuing years. The calculator then tells you how much the company is worth today. Inside Value has just such a calculator available to subscribers. If you're already a subscriber, click here to access it. If not, click here to take a free 30-day trial to the newsletter and play with the calculator to your heart's content.

Once you've figured out what the company is worth, you can use that information to determine whether or not it has enough of Graham's margin of safety to be worth buying. For example, a while back I told Inside Value subscribers on a members-only message board that homebuilder Lennar (NYSE:LEN) (NYSE:LENb) looked undervalued, with its Class A shares trading for $42.77. My discounted cash flow calculations at the time placed Lennar's value at $59.33. That put those shares at about 28% undervalued. (Another way of saying that: The A shares had a 28% margin of safety.) That discount gave investors a great margin of safety. The larger the margin, the better the buy.

In spite of nearly constant talks of a cooling housing market since then, Lennar has climbed upwards. Its A shares recently traded for $58.24, remarkably close to my initial estimate. That translates to a better than 36% return, before dividends.

Selling high with the margin of safety
Logically, if a company trading below its intrinsic value is worth buying, then a company trading above its intrinsic value just might be a candidate for selling. Take pharmacy services management company and former Inside Value selection Omnicare (NYSE:OCR). When lead analyst Philip Durell uncovered it in October of 2004, it was trading at $29.51 a share, and he pegged its value at $41. About a year later, it had shot up to $59.61, more than doubling and far surpassing Philip's estimate of its true worth. When it got that high, Philip said that enough was enough and recommended a sell. With the rise, the margin of safety had turned into a margin of peril, and the risks of continuing to hold outweighed the potential rewards.

Knowing when to sell is key to any investing strategy. Philip is a master at using Graham's principles to determine that time. His sell recommendations also include GTECH Holdings (NYSE:GTK), the lottery services company, on news that it would be bought out by Italian firm Lottomatica. Philip's reasoning there was simple: With the acquisition baked into GTECH's market price, there was simply no more room for its shares to climb.

The Foolish bottom line
Once you've figured out what a company is really worth, its margin of safety will tell you when it's time to buy and when it's time to sell. The lower the company's price with respect to that intrinsic value, the stronger the margin of safety, and the better the chance that buying that company will lead to a profitable investment. The higher the company's price with respect to that intrinsic value, the more that margin of safety has been reversed, and the better the chance that it's time to sell your position and take the extra profits from your bargain-hunting trip.

Like the idea of finally knowing how to buy low and sell high? Want more value investing tips and techniques? Click here to begin your free 30-day trial of Inside Value, The Motley Fool's home of the margin of safety.Subscribetoday, and we'll not only knock $50 off the regular price, but we'll also throw in a copy of Benjamin Graham's seminal work, The Intelligent Investor, as well as access to the Fool's Stocks 2006, absolutely free.

This article was originally published on July 13, 2005. It has been updated.

At the time of publication, Fool contributor and Inside Value team memberChuck Saletta owned shares of Omnicare and class B shares of Lennar. The Fool has adisclosure policy.