If youre nervous about the stock markets nosedive and are considering moving to cash until you think the worst is past, you might want to think twice.

Although its impossible to predict what stocks will do next, research shows that missing out on the best-performing days of the market — regardless of when the bad days are — can wreak havoc on your long-term returns. And the easiest way to miss those gains is by fleeing the market after youre spooked by a downturn.

The stock market has been in a free-fall this week as spread of the coronavirus brings with it concerns of global economic slowing.

On Thursday, the Dow Jones, S&P 500 and Nasdaq all closed down more than 10% from their intraday all-time highs set earlier this month, entering correction territory. The Dow experienced its worst one-day point drop ever, shedding nearly 1,200 points.

Traders work through the closing minutes of trading Tuesday on the New York Stock Exchange floor on February 25, 2020 in New York City.

Scott Heins | Getty Images

Nevertheless, for long-term investors, the expert advice is typically to remain invested through the markets dips and drops.

The younger person with stronger earning potential and years to invest can probably ignore the noise and stay the course, said Kathryn Hauer, a certified financial planner with Wilson David Investment Advisors in Aiken, South Carolina.

The chart below shows how $10,000 invested in the S&P 500 index, for the 20-year period of 1999 through 2018, would have performed under various scenarios.

If the $10,000 remained fully invested, it would have grown to $29,845 with an average annual return of 5.6%.

In comparison, missing out on just the best 10 days in that time period would have reduced the growth of the initial investment by more than half: After 20 years, that $10,000 would be just $14,895 with a 2% average yearly return.

And if the best 20 or more days were missed, the returns over that 20-year period are in the red.

Even if you think youll just wait it out for a few weeks to see what happens, be aware that six of the S&Ps 10 best-performing days during the 20-year period occurred within two weeks of the 10 worst days, according to J.P. Morgan.

For example, the worst single day in 2015 — Aug. 24, when the S&P dropped nearly 4% into correction territory — was followed two days later by the years best day of returns (again, nearly 4%).

Additionally, if you own stocks that pay dividends, youll also miss out on those periodic payments.

Of course, theres always the chance that you could get the timing right — i.e., you sell at the top of the market and buy at its bottom.

For illustration purposes only: Say you had sold 10 shares of an S&P 500 fund when the index peaked in October 2007 at 1,565, and then repurchased shares when it bottomed in March 2009 at 666. In that case, your money would buy 23 shares — more than double the amount you sold.

At the same time, though, you would have missed five dividend payments and, once reinvested, their future gains, as well.

More importantly, recognizing both the top and bottom is tricky. Additionally, if your money is in a portfolio that is based on your risk tolerance — generally a combination of how well you sleep at night when the market gyrates and how long until you need the money — your exposure to stocks may not be as high as you assume.

More from Invest in You:
Demand for travel insurance spikes amid virus outbreak
Me & the Bees Lemonade founder started out at 4 years old.
The five things every first-time business owner needs to know

However, generally speaking, the longer until you need the invested money — say, its for a retirement decades away — the more likelihood that youll need to out-earn cash-like returns to meet your goals over time. That means holding investments that outperform over the long term but might go up and down a lot in the short term — i.e., stocks.

SIGN UP: Money 101 is an 8-week learning course to financial freedom, delivered weekly to your inbox.

CHECK OUT: How to avoid getting ghosted after a job interview via Grow with Acorns+CNBC.

Disclosure: NBCUniversal and Comcast Ventures are investors in Acorns.

Say hello

Find us at the office

Overmann- Mucha street no. 55, 74667 Papeete, French Polynesia

Give us a ring

Juanfrancisco Develder
+76 987 423 417
Mon - Fri, 8:00-17:00

Reach out