It’s a classic mistake. The stock market’s chugging along and then suddenly drops. You panic. You sell. Then the market rallies.

Now you’re faced with a dilemma. Not only did you lose money selling shares that had dropped in value since you’d bought them, but getting back into the stock market while it’s climbing will end up costing you more. Still, you don’t want to miss out on more gains.

Sound familiar? If so, you’ve got a lot of company.

“The most common mistake investors make is to sell low and buy high,” says Certified Financial Planner Brad Klontz, author of “Mind Over Money” and co-founder of the Financial Psychology Institute. The remedy? Play the long game, and don’t let emotions get in the way. Easy, right? Actually, maybe not. If it was, after all, that mistake wouldn’t be so common. So, what’s going on here? Sometimes it’s just a matter of perspective. Historically, the stock market’s recovered from downturns, and gone on to new highs, turning dips into buying opportunities for many investors. But unless you’re up on your market history, you may not be aware of that. Even if you are, though, emotions and biases can still get in the way of good judgment. Take these common offenders. Herd Mentality “When we see the herd run in one direction, it creates a panic—that’s what is so difficult to restrain,” says Klontz. “You tell yourself this will be the one time when the market doesn’t come back.” Loss Aversion As several studies have shown, we feel the pain of loss more acutely—some researchers say twice as powerfully—as we feel the pleasure of gain. “Loss aversion tends to keep investors from jumping back into the market as it starts turning around and…many miss out on returns as a result,” says Certified Financial Planner Angela Coleman, a Fiduciary Investment Advisor at Unified Trust Company. Overconfidence Rui Yao, an associate professor of personal financial planning at the University of Missouri, also found a strong correlation between overconfidence and selling low (maybe as a result of trying, and failing, to time the market correctly). “It is illogical, but common,” she says. Overconfidence can work on the flipside, too, prompting investors to make investments that aren’t a good fit for their portfolio or risk tolerance. “Sometimes they think they know better and have an edge,” says Coleman. (Data shows most don’t.) FOMO Jay Hummel, manag­ing director of strategic initiatives at Envestnet, which works with more than 50,000 financial advisors, calls it “cocktail party” benchmarking. “You go to a party with your neighbors and someone says they got 12 percent last quarter and you only got 8 percent and now you feel like you’re missing out.” And you start taking bigger risks—that don’t necessarily pay off. Okay, so how do I not do that? Stay laser-focused on long-term goals, says Coleman, and set up guidelines based on your risk tolerance and goals to get you through the ups and downs. In other words, once you’ve set your strategy, step away from the “sell” (or withdraw) button till you hit your goal. “Sometimes it’s just about putting some distance and time between your impulse to do something and actually pulling the trigger,” says Klontz. It also helps, he says, to look at your brain as being “a highly dysfunctional” money manager. “Know that any impulse you have to do anything with your money is probably wrong,” he says. “Only after careful consideration and consulting with multiple experts should you take actions.” This article was updated in January 2017.