If you’re coming upon retirement age and have money invested in a volatile stock market, a sudden dip can put a damper on your nest egg that has long-lasting effects.

Oftentimes the advice you get when the market becomes volatile, like it has the past three months, is to hold your ground. But that’s not always an option for those looking to retire soon.

“That can really start digging a hole in your portfolio that becomes harder to dig out of,” said Wade Pfau, professor of retirement income at the American College for Financial Services, in an interview with The New York Times. “It is really the first 10 years of the market performance in retirement that are going to drive your outcome.”

The S&P 500 lost more than 6 percent of its value in 2018, with all of those losses coming in just the final three months. And it’s never clear where the market is poised to go next. Whether you’re getting close to retirement or just starting work fresh out of college, part of your future financial success or failure depends in large part on chance.

Let’s say a person saved 15 percent of her earnings — a flat salary that grew with inflation — during a 30-year career. If that person retired in 1982, she would have accumulated just over five times her final salary. If she retired in 2000, however, she would have amassed 17 times her salary.

The same type of variability can occur based on the sequence of your market returns in retirement — except it’s amplified because instead of adding to the money you’ve invested, you’re spending it.