The worst case if you invest in a hot stock market

stock market fall 2

"I'm your worst nightmare."

That's what Sylvester Stallone's Rambo tells his foes. In investing, most people think the equivalent torment is a dramatic stock market fall.

It's human nature to get antsy about when that next plunge could come, especially when the U.S. market is in the midst of its third-longest upswing in history. At some point the party has to end, right?

But it's worth asking: What exactly is your "Rambo nightmare" if you have the worst timing ever and get into the stock market the day it peaks?

Anthony Valeri at LPL Financial ran the numbers.

Related: Nasdaq finally tops its March 2000 record

Worst case scenario: In nearly 90 years of market history, if you bought stocks on the absolute worst day, the average time to make your money back was 3 years. That's less time than it takes most people to get through high school or college. It's doable. It shouldn't make you shy away from investing in stocks.

"Obviously, to live through that is painful," says Valeri, an investment strategist. "But when you think about what you're investing for -- and for most people it's at least 10 or 20 years out -- you will get past that."

His analysis looked at the S&P 500 -- the most common index that investors own. He accounted for every downturn of 10% or more, what is known in Wall Street speak as a "correction."

Of course, while most of us can tolerate 3 years to get our money back, you're probably thinking, "What about the big, big drops?"

Related: If you own mostly U.S. stocks, think again

The big crashes: Take the 2008 financial crisis. If you got in at the peak, it would have taken 5.5 years to recoup your money.

Want to feel even gloomier: If you invested the day before the 1929 crash, it would have taken you 25 years to be back in the positive. That's a long time, even for a "long-term investor."

But before you decide to exit stocks, remember that in 90 years of stock market history, only the Great Depression took longer than a decade to recoup your money. And only four times did it take longer than 5 years to get back to gains.

Furthermore, most people don't put their money in on the worst day ever. In fact, most investors -- especially those with a 401(k), pension or other retirement plan through their work -- are putting money into funds every few weeks. That spreads out the risk and means it takes even less time to make your money back.

And most people understand the need to diversify. While they own a lot of stocks -- a main driver of growth in portfolios over time -- they also own some bonds and other investments like real estate. A more balanced portfolio shouldn't fall as much during the downturns and thus should be able to bounce back faster.

Related: New investors are putting billions in this fund

Records usually follow records: Another encouraging fact is that when the stock market hits a high -- the Nasdaq just hit one Thursday -- Valeri found that there is an 68% probability that the market will hit an all-time high within the next year.

"When stocks hit new record highs, investors should take that as a positive sign, not a negative sign," says Kate Warne, an investment strategist at Edward Jones.

"The first question investors should be asking is: are the highs based on fundamentals or are they based on emotion?" Warne says.

Right now, most expert say that the economy is improving and businesses (generally) are growing. That's why stocks are going up.

Related: These Nasdaq stocks are even better than Apple

Can you really time the market? As much as investors want to be sure to get out of the market before it drops, an even worse problem is not being in the market when it's going up. If you've been sitting mostly in cash in the past six years, you've really lost out.

Missing the upswings is more of a Rambo-style nightmare to your portfolio than missing the downturns.

"You have to get two decisions right: You have to get out at the right time and get in at the right time," says Scott Clemons, chief investment strategist at BBH. "And human nature is to get both decisions wrong."

Being patient is the key to successful investing. History is on the side of optimists, even if you're timing isn't great.

"It obviously pays to buy at a lower price," says Valeri. "But [the recent stock market highs] shouldn't dissuade anyone from investing in the market."

CNNMoney Sponsors