There are right and wrong times to sell stocks. It's generally a bad idea to sell a stock simply because the price went up or down. On the other hand, there are some other situations that can be perfectly valid reasons to hit the sell button:

  1. The reasons you bought the stock no longer apply.
  2. The company is being acquired.
  3. You need the money, or you will soon.
  4. You need to rebalance your portfolio (because it's out of balance, or your investment goals change).
  5. You see a better opportunity to invest elsewhere.

With that in mind, here's a rundown of these five good reasons to sell stocks, and how to know if one of them applies to you.

Green button on a keyboard labeled Sell

Image source: Getty Images.

1. The reasons you bought the stock no longer apply

I often get asked questions such as "My Apple (NASDAQ:AAPL) stock has doubled since I bought it. Should I sell?"

My response is always the same: "Why did you buy the stock in the first place, and do those reasons still apply?" In simple terms, every stock investment you make should have a reason behind it, other than just because you want the price to go up. This is known as an investment thesis. Maybe you thought that Apple will remain the dominant player in the smartphone business, and it will continue to expand its service businesses. That would be your thesis for buying, and before you sell, it would be a good idea to think long and hard about whether that thesis still applies.

The point is that as long as the original reasons you bought a stock still apply (and none of the other reasons we're about to discuss apply), there's really no good reason to sell. For example, I bought Square (NYSE:SQ) for an average price of about $11 per share. It now trades for about six times that amount, and I haven't considered selling a single share. I bought it because the company was doing an excellent job of creating a financial ecosystem for individuals and businesses and had tons of growth runway. Those things still apply to Square, so I'm still a shareholder.

On the other hand, if something fundamental changes, it can be a good reason to sell. To name a few examples of what this could mean:

  • The company's market share is falling, or a competitor is now offering a superior product for a lower price.
  • The company has been consistently growing sales at 20%-25% per year, but this has noticeably slowed without any good explanation.
  • New regulations make it more difficult for the company to earn the same profit margins it has historically generated.
  • The company's management changed -- especially if the new managers are making reckless decisions like taking on too much debt.

Of course, this isn't an exhaustive list, and there's no way to list all possible reasons you might want to get rid of a stock. But, if something changes that contradicts your investment thesis, it's one of the best reasons to sell.

2. The company is being acquired

Another potentially good reason to sell is if one of the companies you invest in has agreed to be acquired. When an acquisition is announced, the stock price of the company being acquired typically rises to a level that is close to the agreed-upon price. In most cases, it's wise to lock in your gains in a case like this, as your upside potential can be quite limited.

There are three potential ways a company can be acquired -- cash, stock, or a combination of the two.

In an all-cash acquisition, the stock typically gravitates toward the acquisition price. For example, a few days after it agreed to be acquired for $145 per share in cash, Tech Data (NASDAQ:TECD) was trading for about $144.20. Upon the successful completion of the sale, shareholders will receive $145 for every share, but is that extra $0.80 in upside really worth keeping your money tied up for months? And if the deal falls apart, shares could come crashing down. In all-cash acquisitions, it's rarely worth holding onto your shares.

In stock or cash-and-stock deals, it can be a little trickier, and your decision comes down to whether you have any desire to be a shareholder in the acquiring company. For example, AK Steel Holding (NYSE:AKS) agreed to be acquired by Cleveland-Cliffs (NYSE:CLF) in an all-stock deal. AK Steel shareholders needed to decide whether they wanted to become Cleveland-Cliffs investors. If your answer in a similar situation is no, it's perfectly acceptable to cash out.

3. You need the money, or you will soon

It's generally a good rule of thumb to keep any money you'll need within the next few years away from the stock market. So, needing the money is certainly a good reason to sell. And that applies whether you need the money now or for a predetermined expense within the next few years.

As an example, a friend of mine recently purchased a house and sold most of his favorite stock position to cover the down payment. It's not that he really wanted to sell -- he just needed the money.

Another example is if you plan on using your investment portfolio to send your kids to college. While they're young, it's completely fine to invest that money in the stock market, but once they're a few years away, it's wise to move that money into cash or equivalent investments such as CDs.

4. You need to rebalance your portfolio

Rebalancing your portfolio is another good reason you might want to sell a stock (or several). There are two main situations where this might be necessary.

  • High-performing stocks: I invested about 10% of my portfolio's value in Bank of America (NYSE:BAC) stock in early 2016. The shares proceeded to nearly triple over the next couple of years, and ended up accounting for over 20% of my portfolio's value at one point. Although this was a good problem to have, I simply wasn't comfortable having so much of my money invested in a single company. Therefore, I sold about half of my position and redeployed the money for other opportunities.
  • Reducing stock exposure: As you get older -- specifically, as you get closer to retirement -- it's smart to gradually reduce your exposure to stocks. While stocks have excellent long-term return potential, they are also volatile, and capital preservation becomes more important as you near retirement age. One popular rule of thumb is to subtract your age from 110 to determine the percentage of your portfolio that should be invested in stocks. If it's been a few years since you've adjusted your asset allocation, it can be a smart idea to sell some of your stock holdings and move the money into fixed-income investments (bonds).

5. You see a better opportunity to invest elsewhere

In a perfect world, you'd always have spare cash to invest every time you identify an attractive investment opportunity. However, that's likely not the case.

Here's a real-world example. When I put 10% of my money into Bank of America stock in 2016, I didn't just happen to have 10% of my portfolio sitting in cash. However, thanks to a short-term panic that was specific to the financial sector, some banks were trading for ridiculously low valuations -- Bank of America was trading at a roughly 40% discount to its book value, and I knew this wasn't going to last. So I sold some shares of a broad-market exchange-traded fund (ETF) that I owned. There was nothing wrong with the ETF, but I saw an excellent long-term opportunity that was more compelling to me.

In other words, sometimes you have a great investment, but notice an even better opportunity. That can be a perfectly valid reason to sell a stock.

When not to sell a stock

Here's one of the most important things to notice. None of the reasons I mentioned have anything to do with the share price of the stock itself, or how much it gained or lost since you bought it.

This is because the dollar value of each share should play virtually no role in your decisions to sell or hold onto a stock. In other words, "it went up 20%" is a bad reason to sell, unless it's combined with one of the good reasons on the list, such as "you need the money" or "the company is being acquired."

In fact, making investment decisions based solely on price changes can be dangerous. Too many investors decide to sell simply because their stocks go up, only to realize too late that they went up for a reason and still had tremendous growth potential. And it's a common mistake to sell simply because stocks go down, "before things get any worse." The majority of stock investors underperform the market over time, and over-trading is one of the key reasons.

It's also a bad idea to sell stocks simply to lower your taxes. There's a popular tax strategy known as tax-loss harvesting, which essentially involves selling losing stock positions in order to reduce your taxable capital gains on other investments. And to be clear, this can be a smart strategy, but only if the stock you sell is one that you already wanted to sell for other (valid) reasons.

The bottom line is that there are some very good reasons to sell stocks; many long-term-focused investors sell stocks frequently. Just be sure that you're selling for the right reasons, and not to simply to lock in a profit, prevent further declines, or to save money on taxes. If you do that, you're not investing, you're trading, and there's a big difference between those two concepts.