I'd like to think of myself as a pretty well-educated investor. My family's finances are in order, we live well below our means, and I spend the better part of every week focused on stocks and finance.

And yet, even that doesn't make me immune from one of the biggest mistakes investors can make: not knowing how or when to sell a stock. As you'll see below, a single decision made back in 2012 has already cost my family nearly $50,000. 

The experience has taught me that knowing when to sell a stock is the most underappreciated skill in investing. Part art, part science, nothing is more consequential to your long-term capital gains than knowing if it's time to click the "sell" button.

Case in point: In March 2012, my wife and I made the biggest mistake of our investing lives. At the time, we owned a split-adjusted 154 shares of Netflix. Though the stock had fallen, we were sitting on huge gains and decided to sell. "How much higher could the stock go, anyway?" we said to ourselves to justify the move.

At the time, shares were trading for (a split-adjusted) $9 per share. In March 2018, they hovered at $330. The cost of this single decision: almost $50,000!

That's an expensive price to pay for an investing lesson. But you can avoid this fate by learning from my mistakes. After years of pondering the question, I've decided that there are only six times when it makes sense to sell a stock. In order of importance, they are:

  1. If you're losing sleep over how your cash is invested.
  2. You need the money in the next three years.
  3. The original reason you bought the stock no longer holds true.
  4. There are better places for your money.
  5. Selling could help you reduce taxes.
  6. You need to rebalance your portfolio.

Let's dig deeper into each.

Close up studio shot of a young business model wearing a black blouse, ready to press a red button

Do you have a good reason to sell? Image source: Getty Images

1. You're losing sleep over your investments

In the rush of adrenaline that comes with investing, it's often easy to forget the most important question: "Why do we invest in the first place?"

There are as many answers to this question as there are participants in the marketplace. But I think Motley Fool co-founder David Gardner did a beautiful job of summing up why we invest in a 2017 podcast:

Here's why we invest -- for our children and grandchildren -- because our parents and grandparents did, and made our lives so much better. Because every dollar we invest helps support the companies and businesses we admire and buy from. Because we love and celebrate ownership and believe this world would be far stronger for more owners, not more renters ...

Oh, and have I forgotten? I should throw something in here about achieving financial independence, too, so that you and yours can be self-determined -- not income-determined or government-determined -- and a hundred other reasons besides. These are all, in part or in whole, why we invest.

The bottom line in what David is saying is that investing is a tool to help make our lives better.

If you are losing sleep over your investments -- not able to focus on time with your partner or your children or suffering from stomach pains whenever a particular stock drops -- then what is supposed to be a tool to make life better is doing the exact opposite.

There's an important reality that every investor needs to come to terms with: While the market goes up more than it goes down, when the market does fall, it can often fall quickly. Consider some of the biggest drops over the past 50 years.

Index Time Frame Total Losses
Nasdaq Composite March 2000-September 2002 76%
S&P 500 October 2007-March 2009 57%
Nasdaq Composite December 2007-March 2009 53%
S&P 500  August 2000-September 2002 47%
Dow Jones Industrial January 1973-December 1974 42%
Dow Jones Industrial August 1987-October 1987 35%

Data source: YCharts. Note: Not an all-inclusive list.

While it may have been the smallest of the drops listed, consider for a moment what the 1987 fiasco must have been like for investors. Whereas the other drops took months or years, over one-third of investors' value disappeared in just 36 trading days. The market fell over 20% on a single day: Black Monday, Oct.19, 1987.

If you own a stock that displays this kind of volatility and you can't stomach it, it's simply not worth owning anything that gives you such fits. And once you're done selling, you need to follow up by taking stock of your own emotional intelligence and make future decisions accordingly. 

2. You need the money in the next three years

Now imagine this scenario: You were planning on buying a new house because you're expecting a child in the next few months. But the money you were going to use for a down payment was tied up in the market when it had one of the aforementioned drops. All of a sudden, you have to pull out -- if you can afford it -- a much larger percentage of your nest egg to meet your growing family's needs.

The same could be said for any other major life events, like a retirement on the horizon, or paying for college. If you know a major expense is coming in the next three years, the money to cover it should not be in stocks. It should -- instead -- be in safer short-term investments, like a money market account. If you need to sell some stocks to ensure you can cover these expenses, you should do it.

Another reason why you should sell stocks to shore up any needs you might have in the short-to-medium term is because it will give you a cushion when the market does eventually fall, and help prevent you from selling at the bottom.

In a recent interview with former  hedge fund manager, professor, and best-selling author Nassim Nicholas Taleb, he explained why drastic market drops can be terrible for your long-term wealth:

As an investor you need to think about it in these terms: No investor knows what's going to happen to him or her in the future.

The market may deliver whatever people claim it will deliver. But if you have a drop in the market that may force you to liquidate -- particularly a drop in the market that may correlate with your loss of business elsewhere -- then, automatically, your returns will be the returns from today until that drop in the market. It de-correlates from the market.

If you need to sell stocks to give yourself a cushion, do it now and on your own terms. Otherwise, you'll be forced to sell everything at the worst possible moment.

3. The original reason you bought the stock no longer holds true

Now that we've covered the macro reasons to sell a stock, let's focus on much more specific cases.

Before you ever buy a stock, one of the best things you can do is start an investing journal. In this journal, write down two very simple things to help you make better decisions: exactly why you think a stock is a good "buy", and what would have to happen to make you sell a stock. The former is referred to as an "investment thesis" while the latter defines your "exit strategy."

Writing these things down while you have a level head is a great way to protect yourself from making emotional investing decisions. 

Critically, your investing thesis and exit strategy should have everything to do with the performance of the underlying company -- and very little to do with the performance of the stock itself.

As Benjamin Graham -- the father of value investing and mentor to Warren Buffett -- once said: "In the short run, the market is like a voting machine -- tallying up which firms are popular and unpopular. But in the long run, the market is like a weighing machine -- assessing the substance of a company."

To be a successful investor, you need to ignore the noise of the short-term stock market moves, and focus on the long-term signal provided by "the substance of a company." Writing down your reasons for buying -- or potentially selling -- will make it much easier for you to part ways with a stock once your original thesis no longer holds water.

4. There are better places for your money

Of all the reasons to sell a stock, this is by far the murkiest. In fact, it's best to avoid using this stock-selling justification if at all possible. However, from time to time, life can get in the way. For instance, my wife and I regularly devoted 20% of our earnings to the stock market. When our children were born, however, things changed: We bought a house, she stayed at home, and our expenses went up. We simply didn't have as much to invest.

But that didn't stop me from researching companies to invest in. When great ideas came along -- but I didn't have dry powder to invest -- I had to weigh how good an investment each of my positions was. If, after careful evaluation and sleeping on it, I decided one stock was a better bet than another, I would sell the latter to buy the former.

And it goes beyond stocks, too. As we already covered, sometimes you need to anticipate changes in your life -- like paying for college or preparing for retirement. When my daughter reaches 15 years of age, for instance, I'm going to start moving a portion of her investments into CDs or money markets. While the returns will likely be lower, so too will the chances of us losing a large sum of money. The same would apply to people approaching retirement. Slowly, a portion of one's nest egg should be moved into less volatile investments -- CDs, money markets, and bonds.

5. Selling could help reduce taxes

There are times when selling stocks can help you lower your taxes. This is often referred to as tax loss harvesting.

The basics are pretty simple and only apply to your non-tax-advantaged (i.e. non-IRA or retirement) accounts. When you sell a stock that you lose money on, this can help offset any taxes you might owe for capital gains. By selling losing investments, you can cancel out capital gains you might experience and up to $3,000 in earnings as well. 

There are, however, a few tax caveats worth mentioning. First and foremost, if you are selling a stock of a company that you have serious conviction in (i.e. that you strongly believe will be a solid performer), you must wait at least 30 days before repurchasing the stock if you want to get the full tax benefit. You run the risk, then, of missing the stock making gains during the time frame you don't own it.

Sometimes, investors mitigate these risks by selling one losing investment and then buying shares of a similar company immediately thereafter. In some industries -- say, energy, where you are dealing with two oil companies -- this makes sense. In others -- say, social media, where there are only a few dominant players -- it doesn't. 

You need to plan your moves wisely and consult your tax professional to get the best advice.

6. You need to rebalance your portfolio

 Finally, it's wise to figure out what the maximum percentage of your portfolio you are comfortable having devoted to a single stock. Even if you spread your bets around evenly, a single company's stock can perform so well that it becomes an enormous allocation. That can also make you lose sleep.

This is something I know well: Amazon has easily been my family's best investment. At one point, however, it accounted for 25% of our portfolio. I wasn't comfortable with it eclipsing the 20% mark. As a result, I've had to periodically sell shares of the company to make us more "balanced." 

Most professionals would counsel that even my 20% allocation is a bit risky -- all it would take is some unforeseen event and my family could lose a significant portion of our nest egg, for instance. In fact, many believe that you should rebalance your portfolio according to the different industries and company sizes that it contains every year.

At the end of the day, however, it's up to each individual investor to weigh and acknowledge the risks and rewards that come with the allocations in their portfolio. 

Should you sell your stock?

Once you make the decision to buy a stock, there's nothing more hazardous to your wealth than frequently trading in and out of positions. Selling stock should be a rare occurrence, and only if you fall under one of these six circumstances. 

Otherwise, stick to a regular investing schedule, check your portfolio quarterly, and go on enjoying your life!

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Brian Stoffel owns shares of Amazon and Netflix. The Motley Fool owns shares of and recommends Amazon and Netflix. The Motley Fool has a disclosure policy.