If your favorite store was offering 13% off the merchandise, chances are you'd be filling up your shopping cart. But if you're like many Americans, you may find you're not quite as enthusiastic about a markdown when it comes to buying stocks.The S&P 500 — a common proxy for the broad U.S. stock market — is down 13% in 2022, but folks aren't buying more stock at cheaper prices. Just 1 in 4 Americans say it's a good time to invest in the stock market, according to a recent survey from Allianz Life, and 65% say they are keeping more money than they should out of the market out of fear of investment losses.Those fears aren't entirely unfounded: Any investment has the potential to go down, and investment losses can be painful — especially for people who plan to live on their investment income in the short term.If you're investing for a goal that's years away, however, letting fear keep your money out of the market is a big mistake, says Kelly LaVigne, vice president of consumer insights at Allianz Life."When the market is doing well, people are throwing their money at it. When it's doing poorly, they're keeping their money out," he says. "It's doing the exact opposite of what you're supposed to be doing."Here's why investing experts say it's unwise to keep your money out of the market now, even though things look scary.Young investors: Time is on your sideMaybe you're keeping money on the sidelines because you're waiting for the market to calm down. But unless you're on the cusp of retirement, you're sacrificing your most valuable asset as an investor: time."The younger you are, the more you need to be in the market," says LaVigne. That's because the further you are from your investing goal, the more time your portfolio has to recover from dips in the market. And given the market's long-term historical upward trajectory, starting earlier and staying invested means taking the fullest advantage of compounding returns.Say a 22-year-old who plans to retire at 67 initially invests $1,000 into the stock market, followed by $100 each month. If her portfolio earns an annual return of 7%, she would retire with nearly $405,000, according to CNBC Make It's compound interest calculator. If she starts just five years later and the other conditions remain the same, her total plummets to $280,000.Timing the market: 'You're going to miss the uptick'"But wait," you may be thinking. "I'm not going to wait five years to get my cash back in the game. I'm just waiting until the market hits bottom so I can ride it back up."Here's the problem: In order to earn long-term gains, you need to be invested on the market's best days. And those often come right after the worst ones.Over the 20-year period ending December 31, 2021, the S&P 500 returned an annualized 9.52%. Remove the 10 best days from that period, and the return drops to 5.33%, according to analysis from J.P. Morgan. Over that period, seven of the market's best days occurred two weeks after one of the 10 worst days."We have no idea where the bottom of this downswing is, but we know almost for sure that if you're keeping money out of the market you're going to miss the uptick," says LaVigne. "The worst thing you can possibly do is not be in the market when it starts to turn around."Invest consistently through down marketsNo one enjoys the feeling of seeing big red numbers on their portfolio page. But if you're invested for the long term with a broadly diversified portfolio, it's not necessarily a bad thing, says Jeremy Finger, a certified financial planner and founder of River Bend Wealth Management in Myrtle Beach, South Carolina."You should want the market to be down, down, down so you can buy at low, low prices," he says. "Then, if you could snap your fingers like a genie, you'd want the market to go up right before you retire."No one is able to magically control the stock market, but as an investor you can control how you handle its ups and downs. One way to avoid getting caught up in what the market is doing is to invest a set dollar amount at consistent intervals. This strategy, known as dollar-cost averaging, virtually guarantees that you buy more shares when they're cheaper and fewer when they're more expensive — effectively, buying low and selling high.Right now, the market is skewing more to the "buy low" side of things, points out Aaron Clarke, a CFP and founder of Gig Wealthy. "You get a great entry point for the next 30 years of investing," he says. "And if it goes down a little more, fine. It'll be an even better time to get your money in."Sign up now: Get smarter about your money and career with our weekly newsletterDon't miss: I spent 5 years interviewing 225 millionaires. Here are the 4 types of rich people and their top habits
65% of Americans are doing 'the exact opposite of what they're supposed to,' says investing expert—here's what to do instead.