Warren Buffett once said, "Be greedy when others are fearful." But you shouldn't be so greedy that you end up losing everything.

While many people are panicking over falling stock prices, smart investors are finally seeing bargains they've been waiting for years to find. Putting more money into the market makes a lot of sense when prices are down -- especially if you expect a favorable resolution to the economic crisis in the short term. But borrowing money to buy shares by using a margin account can lead to disaster, as some major company executives learned in the recent market meltdown.

No shortage of bargains
It's easy to understand why more people are falling into the margin trap. Unlike previous bear markets, the current crash is knocking down nearly every stock. Last Monday, half of the entire NYSE set new lows for the year.

And we're not just talking about financial stocks, for which some of those fears may be more justified. High-quality blue-chip stocks are among those that have taken a beating. Here's just a selection of stocks from our Motley Fool CAPS service with top four- and five-star ratings that are off at least 50% from their highs:

Stock

CAPS Rating (out of 5)

% Below 52-Week High

Apple (NASDAQ:AAPL)

****

52.3%

Merck (NYSE:MRK)

****

57.4%

Schering-Plough (NYSE:SGP)

****

60%

UnitedHealth Group (NYSE:UNH)

*****

70.8%

Transocean (NYSE:RIG)

*****

57.6%

Source: Motley Fool CAPS.

The dangers of margin
Yet no matter how convinced you are that your stock will recover, it can still keep dropping. That's what Chesapeake Energy (NYSE:CHK) CEO Aubrey McClendon found out last week, when he was forced to sell his entire 33.5-million-share stake in the company because of a margin call. A General Growth Properties (NYSE:GGP) executive made the same mistake recently.

In theory, margin accounts give investors added flexibility. A margin account gives you the right to use your shares as collateral to take out a loan. Often, brokers offer such loans at favorable rates compared to other loans -- especially in a tight credit environment, in which it's often hard to get a loan at all. And unlike most loans, borrowing on margin doesn't come with any strict repayment terms; you typically can choose when you want to repay the money.

The key requirement of a margin loan, however, is that you can borrow only up to a certain percentage of your portfolio's value. If your stocks fall, that means your borrowing power also goes down.

That's really bad if you've already used up a lot of your margin. If the amount you're allowed to borrow falls below your outstanding loan balance, your broker will demand immediate repayment of the excess amount. If you don't pay, your broker has the right to sell stocks in your portfolio without your consent, to cover the margin loan.

How to avoid the margin trap
When bargains are all around you, your first impulse may be to scoop them all up like a Christmas shopper on the day after Thanksgiving. But to be a smart bargain-stock seeker, follow these simple rules:

  • Ration your cash. If you're fortunate to have some cash available to invest right now, don't spend it all at once. By breaking your purchases into three or four parts, you may not end up with as many shares as you otherwise would get -- but you'll be able to pick up even cheaper bargains if shares fall further.
  • Know your limits. The easiest way to avoid margin trouble is simply not to use margin at all. But if you want to buy on margin, be sure to keep your borrowing well below the loan limit. Different brokers have different limits, so get in touch with your broker and find out what limits apply to you.
  • Don't panic-buy. As appetizing as crashing stocks may look, bear in mind that it's OK to miss out on some of the stocks you wanted to buy now. There will always be other chances to add them to your portfolio later, when you have more cash available. And if stocks keep falling, you'll be glad you waited.

When fear is all around, it's fine to let your inner greed show. But keep it on a tight leash, and don't be overconfident. If you don't use tools like margin wisely, you could end up having to sell at what proves to be the absolute low -- and lose everything in the process.

For more on finding opportunities after the crash: