When the going gets rough in the stock market, it can be tempting to just sell and walk away. It’s tough to watch your investments decline week after week, and getting out – even at a loss – may make you feel better, if only so that you don’t keep watching your next egg shrink.

While selling stocks during a market downturn might make you feel better temporarily, doing so reactively because stocks are tumbling isn’t a good long-term investment strategy. Volatility is a normal part of investing in the stock market, so occasional market selloffs should be expected.

Knowing when to sell a stock for profit — or when to cut your losses — can be a tough decision, even for experienced investors. Let’s take a closer look at when you should and shouldn’t consider selling a stock.

When to sell a stock: 7 good reasons

1. You’ve found something better

Investing is ultimately about earning the highest rate of return possible while taking on a minimal amount of risk. As business characteristics and market prices change, investing opportunities change with them. If you own a stock, but find another investment — perhaps another stock or something else entirely — that you find more attractive, it could make sense to sell what you own in favor of the better opportunity.

2. You made a mistake

Mistakes happen, and the sooner you realize it the better. Sometimes it turns out that a business isn’t what we thought it was when we purchased the stock. Maybe it faces tougher competition than you thought or its positioning is getting worse, not better.

British economist John Maynard Keynes famously said that when the facts change, you should change your mind. Admitting mistakes can be hard, but you’ll be better off as an investor if you can realize them quickly and get out of your position.

3. The company’s business outlook has changed

Businesses are dynamic and their future success is far from guaranteed. Companies that earn high returns often face stiff competition that could bring their returns to more normal levels. Other times, businesses face total disruption from new technology that threatens the company’s very existence.

Traditional bookstores’ fortunes changed virtually overnight with the arrival of Amazon in the 1990s. If you had owned stock in Barnes & Noble or Borders Group back then, you would have been wise to sell your shares ahead of the eventual downturn in the business.

4. Tax reasons

If you have losses in some of your investments, you may want to consider selling them to take advantage of a strategy known as tax-loss harvesting. This approach allows you to save on your tax bill by offsetting income and capital gains with your losses.

The IRS allows you to claim up to $3,000 in net losses each year, which could save you a good chunk in taxes. If your net losses are beyond the $3,000 limit, you can carry over the additional losses to offset gains in future tax years. This strategy only makes sense in taxable accounts, not in retirement accounts such as 401(k)s or IRAs.

But try not to let tax breaks drive your investment decisions. Trading in and out of strong companies for tax purposes or other reasons can often leave you worse off than if you’d just held the stock for the long term.

5. Rebalancing your portfolio

If you’ve had a stock perform particularly well, you probably noticed that it accounts for a larger part of your overall portfolio than it did when you bought it. If it makes up an outsized portion of your portfolio, you might consider selling it back down to a lower weighting through portfolio rebalancing. This can help your portfolio maintain proper allocations and avoid having too much exposure to one stock.

But be careful not to rebalance too often, or you might find yourself repeatedly selling companies that are performing well and adding to ones that aren’t — a process some investors equate to “cutting the flowers and watering the weeds.”

6. Valuation no longer reflects business reality

Occasionally, markets can get overly optimistic about the future prospects for a business, bidding its stock price to unsustainable levels. When the price of a stock reaches a level that cannot be justified by even the best estimates of future business performance, it could be a good time to sell your shares.

There are countless examples throughout history of market prices getting ahead of the underlying business fundamentals, leading to underperforming stocks for years to come. In the late 1990s, many technology companies were pushed to levels that couldn’t be justified by their fundamentals. Companies such as Cisco and Intel still haven’t achieved their highs reached in early 2000, despite relatively good business performance.

7. You need the money

If you think you might need access to a hefty sum of money in the near future, it probably shouldn’t be invested in stocks at all. But things happen in life that could create a need for raising cash from a source you intended to be invested for the long term.

Building an emergency fund is an important first step in any financial plan, but sometimes that gets depleted and you need to access money quickly. If circumstances force your hand, you may have to consider selling a stock to meet an immediate need.

4 bad reasons to sell a stock

1. The stock has gone up

There’s an old saying that no one ever went broke taking a profit, but selling just because a stock has gone up isn’t a sound investment practice. Some of the world’s most successful companies are able to compound investors’ capital for decades and those who sell too soon end up missing out on years of future gains.

Companies such as Walmart, Microsoft and countless others have earned early investors many times their money. Don’t sell just because you’re sitting on a profit.

2. The stock has gone down

On the other hand , just because a stock has declined is no reason to sell, either. In fact, it may be a reason to buy more if your original reasons for buying the stock is still intact. If the facts haven’t changed, it might be an opportunity.

Markets rise and fall for a number of reasons in the short term, creating potential opportunities for true long-term investors. A stock that is attractively priced can always become even more attractively priced, and that’s a reason to buy, not sell.

3. Economic forecasts

There is never a shortage of things that markets and traders worry about. Someone is always predicting an economic recession or doomsday scenario. Most of the time these forecasts should be ignored. Famed investor Peter Lynch once said that “If you spend 13 minutes a year on economics, you’ve wasted 10 minutes.”

Remember that investing is a long-term game and don’t sell just because someone is predicting an economic slowdown.

4. Short-term concerns

Many market analysts are willing to offer their advice on what stocks are going to do tomorrow, next week or next month. The truth is that no one knows. Often these well-educated forecasters make very convincing arguments about why a stock will perform one way or another over the coming days.

The next week or month typically has almost no impact on a stock’s intrinsic value. Try not to get swept away by market commentators and their short-term predictions.

Bottom line

Deciding when to sell a stock isn’t easy, but try to focus on the performance of the underlying business, its competitive positioning and valuation. Try to avoid the predictions of so-called experts who claim to know what will happen in the near term. Ultimately, remember that stocks are ownership stakes in real businesses and their long-term earnings will drive your return as a shareholder.

— Bankrate’s Rachel Christian contributed to an update of this story.

Editorial Disclaimer: All investors are advised to conduct their own independent research into investment strategies before making an investment decision. In addition, investors are advised that past investment product performance is no guarantee of future price appreciation.