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 sell 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 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, 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 service.

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, 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. This method allowed me to triple my investment in specialty chemical company KMG Chemicals (NASDAQ:KMGB) in under two years. It also let me sell the company for more than 17% above last Friday's closing price. 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 easily outpaced the market, gaining 13% in a period where the S&P 500 has only risen about 8.3%. His record is added proof that using a margin of safety truly does work.

Philip has beaten the market without help from the likes of on-again, off-again technology company Apple Computer (NASDAQ:AAPL), which has experienced a tremendous run since its introduction of the iPod brought the company back from the brink. Instead, Philip has relied on stalwarts like beverage giant Coca-Cola (NYSE:KO). Philip recommended Coke in December 2004, when comparisons with archrival PepsiCo (NYSE:PEP) seemed to indicate that Coke was losing ground to its far more diversified competitor. Philip reasoned that Coke, with its solid and growing dividend, large share-buyback program, and inexpensive price tag was simply too good an opportunity to pass up. Sure enough, Philip was right. Since his recommendation, Coke has raised its dividend a whopping 24%, while continuing to repurchase its own shares. These moves showcase its tremendous financial strength and long run potential.

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, last June, Philip put cash-advance company Advance America (NYSE:AEA) on his watch list. He reasoned that the company's stock had fallen far enough to potentially be attractive, following changes to Federal Deposit Insurance Corporation (FDIC) guidelines for the banks that lend it its money. It remained on the watch list until Philip was convinced that it could adapt to the new FDIC guidelines and continue to thrive. Then, it graduated to the status of official pick. Simply put -- a low price is not enough to be a real value. It takes a low price compared to a discernable true worth to be a true Inside Value pick.

Selling high with the margin of safety
Logically, if a company trading below its intrinsic value is worth buying, then a company trading at or above its intrinsic value just might be a candidate for selling. Take former Inside Value selection and long-distance giant MCI, for instance. Philip recommended the stock last August, when it traded at $13.04. After MCI agreed to be purchased by fellow telecommunications company Verizon (NYSE:VZ), Philip reasoned that the firm's value had been realized with the acquisition agreement and that there would be little left to gain by continuing to hold. Even Verizon's bidding war with rival telecom operator Qwest Communications (NYSE:Q) added little to the value of MCI's shares compared to the run that Inside Value saw. Subscribers enjoyed a gain of approximately 52% for MCI in about six months, a classic example of buying low and selling high.

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 for a free 30-day trial to Inside Value, The Motley Fool's home of the margin of safety.

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 Salettahad no financial stake in any of the companies mentioned in this article. The Fool has adisclosure policy.