Anyone saving for retirement has been tested twice in the past 18 months. In a three-month slide that ended on Christmas Eve 2018, the S&P 500 stock index avoided a bear market in name only; the 19.4% loss in the S&P 500 was just a hair less than the 20% loss that counts as an official bear market.

That turned out to be a short-lived test. In the following five months the S&P 500 gained more than 26% and ended 2019 up more than 31%.

The latest test is still ongoing. From Feb. 19 into the second week of March, the index fell more than 25% amid the realization that the spreading coronavirus is going to disrupt global economic growth.

Whether you ace these tests, or the ones guaranteed to occur in the future, is the key to your financial security. Stay calm, no matter your age.

Not yet retired? Reframe your angst into opportunity. Warren Buffett wrote in a Berkshire Hathaway shareholder letter, “Prospective (stock) purchasers should much prefer sinking prices.” In October 2008, in the depths of the financial crisis, he wrote in a newspaper column that he was buying more U.S. stocks. He shared a core investing principle: “Be fearful when others are greedy, and be greedy when others are fearful.”

Is this market swoon any different? Nope. Buffett was recently on CNBC making the same point. Over the short term nobody knows how bad it may get, but over time longer-term stock values will rise.

If you are saving in a workplace retirement plan that automatically transfers money from each paycheck into your retirement plan, don’t touch a thing. Contributions into stock funds are essentially buying stocks on sale. Might they get cheaper? Absolutely. That’s always in play, regardless if your focus is just a few months or a few years. But longer term, those cheaper shares you are buying will grow.

Retired? This is why you own bonds and cash. If retired, your long-term portfolio likely has at least — at least — half invested in high quality bonds, right? The recent market slide is exactly why you own a big chunk of bonds.

Focus on your overall portfolio, not just stocks. Your net loss is likely pretty small when you factor in the gain on bonds. Even if we find ourselves in a long bear market — and that’s a big if — you could make your required minimum distributions from bonds for a long time. Over the past 50 years, the longest it took for stocks to recover bear market losses was five years. Now take a look at the bond side of your portfolio. You’ve likely got way more than five years of bonds you could rely on if necessary.

If you’ve also followed the bucket strategy that suggests keeping at least two years of living expenses in cash (beyond what you get from guaranteed income sources such as Social Security and a pension), you’re in even better shape to ride this out.

Still considering taking money off the table? That’s understandable, but not smart.

As unpleasant as it is to watch your portfolio fall, patience is rewarded. Even when you factor in bear markets.

When you sell stocks, you have to at some point decide to get back into stocks. That’s where things get gnarly. If you’re on the sidelines for even just a few days, when stocks have a good run you will lose plenty.

For instance, in the 15 years through 2019, a $10,000 investment in the S&P 500 would have grown to more than $36,000. That includes big bear market losses during the financial crisis and the 2018 near-bear, as well as other smaller scares.

If you weren’t invested for the 10 best days for stocks during that 15-year stretch, your $10,000 would have grown to about $18,000. If you missed the 20 best days, your $10,000 would have limped to $12,000 over the 15 years.

Yes, in a perfect world it would be fantastic to sell right before stocks fall (or soon after) and then have the foresight to know exactly when the worst is over, as well as time to reinvest in stocks to ride their rebound. But as this example suggests, you need to be insanely fast, prescient and, likely, lucky to perfectly time when you get back in.

If you’re finding it harder and harder to stick to a long-term plan when the world, let alone stocks, gets scary, you might want to consider working with a financial adviser. Research has shown that having a pro help you navigate around the emotional traps of investing.

Carla Fried is a freelance personal finance journalist. Distributed by Tribune News Service.