Health care has been the best-performing sector between June and August since 1990, according to a new Oppenheimer note. But if the sector rallied this year, not all names in the group would participate, said the firm's top technician.

"The overall sector is very mixed," Ari Wald, head of technical analysis at Oppenheimer, told CNBC's "Trading Nation" on Monday. "You want to key on industry selection here."

A strong technical picture for the IHI iShares medical device ETF suggests it could be the best-performing slice of the health-care sector, said Wald.

"It's breaking out to the upside, it's been a source of leadership, it scores very well in our momentum ranks (we like high momentum), and it's broadly strong, too," said Wald. "There's a lot of medical device companies that are participating and acting as that leadership. That's what we want to own."

The IHI ETF hit an intraday record Tuesday in its third straight day of gains. The IHI ETF, which holds names like Medtronic, Abbott Laboratories and Thermo Fisher Scientific, is up 17 percent for the year. That is far better than the XLV health care SPDR ETF's 1 percent rise.

"Where we want to stay away from is a group like pharmaceuticals," said Wald. "Take for instance the iShares ETF, ticker IHE, it's still below its 200-day moving average, it's relatively weak, it's underperforming, it's a drag on overall sector returns, stay away from pharma."

The IHE pharma ETF broke below its 200-day moving average in mid-March, a level it has not been able to recover since. The ETF, which holds names such as Johnson & Johnson, Pfizer and Merck, is down more than 2 percent for the year.

The overall health-care sector is in good shape, though extraneous headwinds have kept it from gains this year, said Gina Sanchez, CEO of Chantico Global.

"The health-care sector looks very, very strong – they have strong balance sheets, they're good dividend payers but they haven't really performed all year," Sanchez said on Monday's "Trading Nation." "You continue to have political rhetoric around the Affordable Care Act and certainly [President Donald] Trump's announcement that he wants to lower drug prices also adds to the volatility of this sector."

The health-care sector is the fourth-best performer in the for the year to date. The XLV health-care ETF's 1 percent gain in 2018 is weaker than a nearly 3 percent advance by the S&P 500.