U.S. equities traded in a wide range on Wednesday after reaching all-time highs as tech stocks declined. The market's high valuation also made some investors nervous.

The Dow Jones industrial average closed 41.31 points higher at 26,252.12, managing intraday and closing records. The 30-stock index rose as much as 182 points and briefly fell 104 points.

The finished just below the flatline at 2,837.54 and fell as much as half a percent. The broad index had risen as much as 0.5 percent. Tech stocks declined 0.9 percent.

The Nasdaq composite dropped 0.6 percent to 7,415.06.

Tech stocks were led lower by Apple, which fell 1.6 percent after Bernstein analyst Toni Sacconaghi predicted iPhone sales growth could be weak this spring. Shares of Facebook, Amazon and Alphabet also traded lower.

Equities have kicked off 2018 with strong gains. The major indexes are up at least 6 percent year to date as strong earnings and a lower corporate tax rate help maintain optimism in the economy.

But Jeff Kilburg, CEO of KKM Financial, said "the air is getting pretty thin up here," adding: "This has truly been an extraordinary rally."

Worries about further U.S. protectionist policies also gave investors jitters. Earlier on Wednesday, Commerce Secretary Wilbur Ross suggested the U.S. was ready to enter a trade war.

"In general, it's starting to feel like you have four things. You have tariffs placed on solar panels and washing machines. You have the Treasury Secretary touting a weaker dollar," said Art Hogan, chief market strategist at B. Riley FBR.

"You have Wilbur Ross talking about how trade wars are normal and the U.S. is willing to fight to the them, and you have NAFTA negotiations going on in real time." Hogan said. "That's enough for the markets to pause."