Markets managed to deny another sell-off even after President Donald Trump went after e-commerce giant Amazon for the fourth time in a week, closely followed trader Art Cashin told CNBC on Tuesday.

Stocks briefly fell early in the day after Trump took to Twitter to reinforce his assessment that Amazon's business is costing taxpayers "many billions of dollars" through subsidized rates by the United States Postal Service. The initially fell after the tweet before rebounding.

"It was dangerous to see the rollover and going negative. If they had gone seriously negative, it could have doomed the week," said Cashin, UBS director of floor operations at the New York Stock Exchange. "The key here is to hold on to the rally to some degree."

Worries over the technology sector and trade issues on Monday weighed on investor sentiment, sending the Dow Jones industrial average, S&P 500 and Nasdaq to close in correction territory. The Nasdaq ended in a correction for the first time since the aftermath of the Brexit vote in 2016.

Cashin said investors on Monday had hoped the market sell-off would get the White House's attention, and perhaps cause it to do some damage control. He cited the interview by Trump trade advisor Peter Navarro late Monday on CNBC as possible proof.

However, "we got the first tweet this morning, everybody said, 'Oh, no, we're back in the same spot.' They rolled over, the S&P went negative. No second shoe fell, so now we're trying to rebuild the rally here," Cashin told "Squawk on the Street."

"We went from being oversold to now getting mildly overbought on the rebound," he said.

Of course, it wasn't just Trump's tweet the caused the markets to sell off on Monday, Cashin said. "China came out with a list of new tariffs, many of which were directed at products that came from the states and the areas that Trump won. ... You had Tesla."

Cashin, 77, began his career at Thomson McKinnon in 1959. In 1964, at age 23, he became a member of the NYSE and a partner in P.R. Herzig & Co.