It's been a rough ride for retail stocks.

The XRT, which tracks the biggest names in retail, is coming off its worst month in more than a decade after falling roughly 13% in May.

But the sector showed some signs of life on Tuesday, gaining almost 3% and posting its best day in about five months. While some investors may see this as a sign that it's safe to start shopping again in this space, Miller Tabak's Matt Maley says not so fast.

Based on the historical correlation between the stock market and consumer confidence, Maley argues consumer confidence may be about to dip, which could hit the retail space hard.

Maley points out that since the credit crisis, consumer confidence has moved virtually in lockstep with the market, just at a slight lag. In other words, when the market goes up, consumer confidence also rises.

Since Maley believes the stock market's strong start to the month may be short-lived — this week's S&P rally follows the index's first four-week losing streak in five years — he believes another downturn in the market could hit consumer confidence, and by extension retail stocks.

"Consumer confidence is holding up so far but if the stock market continues to roll over, which I think there's a good chance it will eventually even though it's seeing a little bit of a short-term bounce right now, I think that that will take it [consumer confidence] lower and that will cause problems for a lot of these retail stocks," he said Tuesday on CNBC's "Trading Nation."

Although he wouldn't be a buyer of retail generally, there are individual retail names he likes. He's specifically watching stocks that held up during the broader market sell-off such as Dollar General.

"Dollar General stands out in particular because it broke out to the upside to a new all-time high in a fairly significant way," he said. "It's a little overbought and may need to pull back a little near term, but that's holding up very well."

"You want to look at those names and maybe your traditional Amazon, which is a little oversold, rather than some of the ones that are really having a tough time fighting with Amazon, not only in the last few months but in the last few years," he added.

As Amazon's dominance in e-commerce has grown, traditional brick-and-mortar retailers have struggled to keep pace. In the last five years, Amazon's stock has soared more than 460%, while the XRT has lost 2%.

Washington Crossing Advisors' Chad Morganlander doesn't necessarily believe that it's a zero-sum game between Amazon and traditional retailers. He argues that retail stocks are "extremely cheap" at current valuations, and that the current economic backdrop of wage growth and a strong labor market will be beneficial for consumer discretionary names.

"Even though we are somewhat pessimistic about the US economy growing all that much in 2019, 2020, we do think that the consumer is going to be on strong footing ... because of [a] strong labor force as well as wage inflation. And you're also seeing the consumption where debt growth amongst households is continuing to increase. We think that's going to be a strong tailwind for many of the consumer stocks here in the United States, so we would be overweight the consumer companies at this inflection point," he said.