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 for when to sell stocks, and how to know if one of them applies to you.

Green button labeled Sell on a keyboard

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.

As long as your investment thesis still applies (and none of the other reasons we're about to discuss apply), there's really no good reason to sell. 

On the other hand, if something fundamental changes, it can be a good reason for selling stock. For example, this could mean:

  • The company's market share is falling, or a competitor is now offering a superior product for a lower price.
  • Sales growth has noticeably slowed. 
  • 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. Essentially, if something changes that contradicts your investment thesis, that'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. And if the deal falls apart, shares could come crashing down. In all-cash acquisitions, it's rarely worth holding on to 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 if you need the money, that's certainly a good reason to sell. 

As an example, a friend of mine recently purchased a house and sold most of his favorite stock position to cover the down payment. 

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 nearly tripled 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. 
  • Reducing stock exposure: As you get closer to retirement, it's smart to gradually reduce your exposure to stocks. 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, you may want to consider selling some of your stock holdings, to 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, some banks were trading for ridiculously low valuations 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.

When not to sell a stock

Take note: 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.

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." 

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.