With online savings accounts and money market funds offering attractive returns for the first time in years, some investors may be considering increasing the cash holdings in their portfolios. Stock market returns have been volatile over the past year and with a possible recession on the horizon, some may view cash as a safer alternative to stocks.

However, selling stocks to hold cash isn’t a decision you should take lightly. If you’re considering withdrawing cash from the stock market, carefully evaluate these 5 factors before doing so.

What to consider before taking money out of stocks

1. Short-term and long-term goals

Before you ditch stocks in favor of cash, it’s probably worth reminding yourself why you invested in stocks in the first place. Stock market investments should be held as part of a long-term investment plan, which means you shouldn’t expect to need the money for at least five years, if not longer.

However, sometimes goals change, so it’s important to reevaluate them periodically. Stocks are often held as part of retirement planning, which for many people will still be decades away. In this case, selling stocks in favor of cash could be detrimental to your long-term returns and runs the risk that you won’t meet your investment goals.

Safety should always be top of mind for money held in an emergency fund, however. The goal for an emergency fund is that the money is there when you need it, so it’s best to hold these funds in FDIC-insured accounts. High yield savings accounts are great options and typically offer higher annual percentage yields (APYs) when compared to brick and mortar banks. Check out Bankrate’s list of best high-yield savings accounts to find the best online savings account for you.

Lastly, ask yourself or a financial advisor if your overall portfolio is still aligned with your goals. If it is, you’re likely better off sticking with your plan rather than jumping in and out of the market. Time in the market is better than timing the market.

2. Tax implications

If you hold stocks in a taxable brokerage account, selling them will likely have tax implications. Stocks sold for gains will require you to pay capital gains taxes, which will eat into the profit you earned. Selling investments for a loss may generate tax savings, but you’ll also be locking in those losses and won’t be able to recover unless you get back in at the right time.

You won’t have to worry about the tax impact if your investments are held in tax-advantaged accounts such as traditional or Roth IRAs, but there are still things to consider before you decide to move all or a portion of your portfolio to cash.

3. Market timing is difficult

Often, the reason for wanting to move money out of stocks and into cash is because you think the market is headed for a downturn and you think you can avoid it by holding cash. But this strategy is known as market timing, which has not been a successful investment approach over the long-term.

Market timing refers to the idea that you can avoid losses and fully participate in the market’s gains by buying and selling at exactly the right times. It sounds great in theory – who wouldn’t want to buy low and sell high all the time? In reality, it’s next to impossible to actually do. People worry about more recessions than actually occur, and stocks often turn positive before the economy actually improves following a downturn. You’re mistaken if you think you can predict every move in the stock market.

Sticking to a long-term investing approach and making regular contributions to retirement accounts is likely to be a more successful strategy than market timing. Train yourself to understand that market downturns are a normal part of long-term investing, and try to take advantage of them by increasing investments during these times rather than trying to avoid them altogether.

4. Inflation

With high-yield savings accounts offering yields around 4 percent and other short-term fixed-income securities also offering higher rates than they have in a long time, it’s natural to be drawn to the decent returns offered by these safer investments. But it’s important to remember that as long as inflation remains above these levels, you’re actually losing purchasing power by holding them.

Of course, earning 4 percent when inflation is 5 percent is better than earning nothing, but your real return is still negative. With a potential recession looming, people often talk about the need to hold cash as a way to prepare for the downturn, but cash has a poor record as a long-term investment.

“The one thing I will tell you is the worst investment you can have is cash,” legendary investor Warren Buffett told students in the aftermath of the 2008 financial crisis. “Cash is going to become worth less over time.”

5. Alternatives to holding cash

If your exposure to the stock market is making you nervous or you want to position your portfolio for some protection in the event of a downturn, there are some other steps you can take besides moving to cash.

  • Defensive stocks: Shifting your portfolio away from areas that may be hardest hit during a recession, may help you avoid some pain without getting out of the market completely. Moving away from cyclical stocks and increasing exposure to relatively safer industries such as consumer staples or utilities would be one strategy to pursue.
  • Asset allocation changes: You might also consider reevaluating your overall asset allocation. If your current level of stock holdings makes you uncomfortable, consider increasing exposure to bonds or other assets such as real estate through real estate investment trusts (REITs).
  • Portfolio rebalancing: Regular portfolio rebalancing can also be a way to take advantage of market downturns. When stocks fall, they become a lower percentage of your overall portfolio, all things being equal. By rebalancing to a certain percentage of your portfolio, you can take advantage of low prices without moving to cash.

Bottom line

Moving your portfolio from stocks to cash is an understandable instinct when savings rates are high and there are concerns about a possible recession. But it’s important to remember that stock market investments are part of your long-term plan, and selling could have tax implications. Jumping in and out of the market has not been a successful strategy over the long-term and cash is virtually certain to be a losing investment over time.

If you’re looking to reduce risk in your portfolio, consider shifting your asset allocation toward defensive sectors of the economy or other assets that may perform better than stocks in a downturn.

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.