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

If you can buy something for $1 and turn around and sell it for $2, you've made money. If, on the other hand, you buy something for a buck and can't find someone willing to take it off your hands 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 employing this technique, investors greatly decrease the chance that they'll lose their hats, and increase the likelihood that they'll trounce other investors.

Following in Graham's footsteps, Bill Miller, who runs Legg Mason Value Trust (LMVTX), beat the market for 15 consecutive years -- a record practically unheard of in the mutual fund industry. And Miller's long-run performance pales in comparison with that of Warren Buffett, a former pupil of Graham's. What's more, Graham's margin of safety is something we put to good use at our Motley Fool Inside Value investing 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 its true worth, sell it.

My friend and colleague Philip Durell follows that philosophy as the chief analyst at Inside Value. His selections as a whole are beating the market's return since the newsletter's inception in 2004. 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 oil companies such as Marathon (NYSE:MRO) and Chevron (NYSE:CVX). Their shares may have blown past the market over the past five years, but that's due more to hikes in the price of oil than to any particular operating improvements. If and when oil once again cycles in the other direction, the same forces that propelled their shares upward will knock them back down again.

The strategy simply works
Instead, Philip has relied on companies with competitive moats, such as industrial giant 3M (NYSE:MMM). Because of its large size, strong reputation, and diversified product base, 3M has the financial strength to continue to innovate and grow. Many see conglomerates like 3M and General Electric (NYSE:GE) as too big and having too many parts to outperform the market over time. As a result, they're often saddled with "conglomerate discounts" -- lowered stock prices that reflect the market's pessimism.

Yet it's precisely when those conglomerate discounts are the greatest that an investor has the best chance to profit.

Buying low with the margin of safety
Every company has what Graham calls an "intrinsic value" -- a measure of what that 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 such a calculator available to subscribers -- if you're already a subscriber, you can access it here. If not, you can get access by taking a free 30-day trial of the newsletter.)

Imagine buying pharmaceutical giant Merck (NYSE:MRK) after Vioxx was withdrawn. In spite of the company's strong balance sheet and suite of other products, Merck's shares soon traded as though Vioxx-related lawsuits could potentially bankrupt the company. Investors who were capable of looking through the headlines to the true financial state of the business were richly rewarded for their efforts. It's a tremendously powerful example of what your money can do if you find and buy firms trading at bargain-basement prices.

These days, with the housing market in a slump, several housing-related companies such as Home Depot (NYSE:HD) are struggling. Yet even though the churn in the housing market may be slowing, people still need to repair, maintain, and improve their existing homes. The disconnect between the panic-filled headlines and the reality of a solid core franchise just might be creating another opportunity for investors.

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. Philip recommended just such a sell for credit card giant MasterCard, after it more than tripled for subscribers between June 2006 and July 2007. The shares had simply run past Philip's objective analysis of their true worth. Just as discount prices don't last forever, shares don't continue to trade far above their fair values forever.

In the time since Philip issued his sell, MasterCard's shares have fallen 17.9%. Was that good timing? No -- the timing was more luck than skill. It was simply a textbook example of how to use a company's true value to know when to buy and when to sell.

Follow the formula
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 a 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 a company's price with respect to 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 knowing how to buy low and sell high? Want more value investing tips and techniques? Start with a free 30-day trial of Inside Value, The Motley Fool's home of the margin of safety.

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

At the time of publication, Fool contributor and Inside Value team member Chuck Saletta owned shares of Merck and General Electric. Home Depot and 3M are Inside Value selections. The Fool has a disclosure policy.