Traders work at Goldman Sachs booth on the floor of the New York Stock Exchange in New York.

In such a slowdown, investors should focus on companies with high and stable gross margins, also known as high pricing power, according to Goldman Sachs.

Investors are bracing for a drastic earnings slowdown headed into the first-quarter reporting season — Wall Street analysts are projecting a 3.9 percent earnings decline for firms in the first quarter, the first year-over-year drop since the second quarter of 2016, according to FactSet. That is a 7.2 percent drop from the previous quarter, the largest cut in three years.

Things are about to get dicey after the stock market's record quarter .

"All 11 sectors have experienced negative 2019 EPS revisions since the start of the year," Goldman chief U.S. equity strategist David Kostin said in a note Saturday. "As margin pressures mount, investors should focus on companies that have demonstrated the ability to maintain margins through pricing power."

Source: FactSet

As slowing demand and rising costs put pressure on companies, it becomes harder for them to generate additional sales growth. In fact, net margins for the S&P 500 companies are expected to fall to levels unseen since the financial crisis, Goldman said. This is why investors should be hiding out in stocks of companies that tend to be less affected by rising costs.

"Executives cautioned investors on margins as they reported 4Q 2018 earnings, citing both trade tensions with China and the continued tightening of the labor market as factors contributing to margin uncertainty in 2019," Kostin said.

Companies with big margins have a track record of outperformance in periods of profit margin pressure. They have beaten the market since at least 1985 whenever there was an expected margin decline, the bank said.

Goldman screened stocks for high pricing power by examining the level, variability and recent momentum or company gross margins relative to sector peers. It identified Nike, Home Depot, Coty and Adobe as companies with high pricing power.