Gas prices were at their highest level since 2014 over the Memorial Day holiday weekend. That could put the squeeze on consumers, but Piper Jaffray's Craig Johnson says one retail stock is set to benefit: Costco.

"One of the things that we've noticed with this stock over time is that when we see gasoline prices move above $3, as they've just recently done, we actually start to see the same-store sales comp numbers really start to move up," Johnson, the firm's chief market technician, said Friday on CNBC's "Trading Nation."

Johnson's theory posits that when gas prices are high consumers tend to shop more at retailers like one-stop Costco to limit driving. In the past, Johnson says he's seen that trend give a lift of 200 to 400 basis points to same-store sales.

Shares of Costco rallied more than 100 percent from late 2010 to early 2014 the last time the average U.S. gas price rose to above $3 a gallon, according to Johnson. Over that same period, the and the XLP staples exchange-traded fund both gained more than 70 percent.

Gina Sanchez, CEO of Chantico Global, sees the same kind of gas trends benefiting Costco sales.

"The general consensus is that a penny at the pump hurts a dramatic level of consumption but when that happens, you'll also see people go down in terms of price point," Sanchez told Friday's "Trading Nation." "So, Costco is pretty well-placed to be a beneficiary of consumers basically looking to save money."

The charts also suggest Costco is at an "interesting inflection point," according to Johnson.

"We're very close to breaking out to new highs," he said. "Any sort of close above $200 would suggest another leg higher and I could see a measured objective on the charts that could put the stock up toward about $220 so a nice 10 percent increase."

Costco shares are currently trading just below $199. They hit an all-time high of $201.77 on May 22.

The wholesale club chain is set to report earnings Thursday. Analysts surveyed by FactSet anticipate a 20 percent increase in earnings and 7.1 percent rise in same-store sales for its fiscal third quarter.