Image source: Getty Images

We investors tend to spend a lot of time thinking about whether and when to buy into various stocks, and much less time thinking about when to sell. Oftentimes, we sell when we shouldn't -- or hang on when we shouldn't. Those can be costly mistakes. Here are three tips on when to sell a stock and when to stick it out.

1. Don't sell just because the price shot up

Cory Renauer: Trading in and out of positions is a great way to underperform the market for more reasons than one. To use an example with a nice, round figure, consider Johnson & Johnson stock. Suppose you bought shares of the healthcare conglomerate near the beginning of the year for $100 per share.

JNJ Chart

JNJ data by YCharts.

Following an early dip, the stock has had a great year, and on the first of August you could have sold off your shares, locking in a juicy 25% profit. Instead you held on, and now the stock is only up 16% for the year. But don't kick yourself yet.

The best thing to do in this case is something many of us excel at: nothing. If you had sold in August, you would have realized a short-term capital gain -- that's accounting lingo for a profit made by selling an asset held for one year or less. In the U.S., short-term capital gains are generally taxed at your income tax rate. However, investments held longer than one year are taxed at a much lower rate -- for most people, just 15%.

You can realize the gain after one year or one century, but you'll be taxed only once. In the meantime, J&J will continue to return some profit to you in the form of dividends and share repurchases -- something the company does quite well.

Even if you trade stocks held within a retirement account that's not subject to capital gains taxes, statistics say you're better off holding on to shares for as long as the company's profits continue growing. Buy-and-hold investing is arguably the safest and most effective strategy for everyday investors. Remember that the majority of actively managed mutual funds, which have legions of well-paid analysts, fail to beat their benchmark indexes -- and those indexes contain companies without earnings growth. If they can't outperform a simple buy-and-hold strategy, then don't make the mistake of assuming that you can. 

Image source: Pixabay.

2. Don't sell just because the stock price falls

Brian Feroldi: If you pull up a long-term chart of any of the most successful stocks in history, you'll notice they all have something in common: At some point, their share price took a huge beating. Even stock market darlings like, Starbucks, Microsoft, Berkshire Hathaway, and many others have seen their share prices drop by at least 50%, which undoubtedly caused some shareholders to bail. While selling any of those stocks while they were dropping probably felt like a smart move in the short term, each of those companies went on to produce multibagger returns, and those who sold early missed out on massive gains.

I'm a firm believer that you should never sell a stock just because its share price is tumbling. Instead, the smarter play is to focus your attention on how the business itself is performing and do your best to ignore the short-term movements of the share price.

A good example of this principle in action is the recent history of Intuitive Surgical, the leader in robotic surgery. The company's shares traded for over $550 each in early 2013, but then the company's growth engine started to stall thanks to a temporary decline in sales of its da Vinci system in 2014. Traders slammed the shares, dropping them below $350 over fears that the company's days of high growth were over. 

While there's no doubt that Intuitive Surgical faced some real short-term challenges, the company's position as a leader in the robotic-surgery market was never really in question. Intuitive then went on to roll out a new da Vinci system that's been a hit with providers. Revenue is back to growing at double-digit rates, margins are expanding, and the company's lead looks as strong as ever. 

Given the company's recent results, shares have rebounded sharply, recently trading for over $680 each. Even those who bought at the peak in 2013 are now far into the green. 

The lesson here is clear: If you've bought shares of a strong company whose future you truly believe in, then don't be in a rush to sell just because shares take a short-term nose dive. Rather, keep your attention focused on the company's business and future prospects. As long as those things are still going well, then the share price will take care of itself.

Sometimes selling low is your best move. Image source: Getty Images.

3. Do sell when you've lost faith in the company

Selena Maranjian: Many times, investors hang on to a stock when they shouldn't -- because they've lost money in it and they're waiting for it to increase in price so that they can at least get their money back. That can sound kind of reasonable, but it isn't. Here's why.

Imagine that you bought shares in, say, Home Surgery Kits, Inc. (ticker: OUCHH) because you were bullish on the company's future and you believed its shares were undervalued. So far, so good. But the shares fell in value thanks to a series of gruesome and widely reported mishaps that consumers experienced with the kits, leading to a major sell-off. Many people have lost faith in the company -- and so have you.

Let's say you spent $5,000 for 100 shares of the stock when it was trading at $50, and you're now down $3,000 because shares are trading around $20 apiece. You can hang on and wait, hoping that the shares will inch up to $25, and then $30, and then maybe even $50 so that you can recoup some (or, ideally, all) of your loss. Remember, though, that you don't have much confidence in the company's prospects, so that recovery doesn't seem likely. You're really being more stubborn than sensible.

Instead, remember that there are thousands of companies to invest in, many of which are strong, growing, and undervalued. Sell your deflated shares and find one or more of those companies -- ones you're confident will grow for years to come. By moving your remaining $2,000 position into those potential winners, you'll stand a much better chance of recouping your loss.