US stocks Thursday snapped a three-day losing streak, catalyzed by stronger Chinese trade data and better sentiment on the European economy.

The Dow Jones Industrial Average gained 27.65 (0.18 percent) at 15,498.32.

The broad-based S&P 500 tacked on 6.57 (0.39 percent) to 1,697.48, while the tech-rich Nasdaq Composite rose 15.12 (0.41 percent) to 3,669.12.

Hugh Johnson, chief executive of Hugh Johnson Advisors, said the market was primed for a jump after notching three straight declines.

Chinese trade data for July showed that exports increased 5.1 percent year-on-year to $186.0 billion, while imports rose 10.9 percent to $168.2 billion, revealing some ongoing strength in the Chinese economy.

Johnson also cited remarks from European Central Bank President Mario Draghi that the European economy appeared to be stabilizing and fresh German trade data that showed a pickup in exports.

These were "a catalyst for an oversold bounce," Johnson said.

Dow component Microsoft rose 2.6 percent after Evercore Partners upgraded the stock to "buy." Evercore cited a solid outlook for some key divisions and said very low expectations for PC-related revenues have been priced in, according to

Electric car manufacturer Tesla soared 14.3 percent after reporting a 20 cents per share profit, compared with an expected loss by analysts of 19 cents per share.

Online coupon company Groupon powered 21.6 percent higher after announcing a $300 million share repurchase program, and naming cofounder Eric Lefkofsky as its next chief executive.

Miner Freeport-McMoRan Copper & Gold picked up 4.7 percent after copper prices rose on the better Chinese data. Barrick Gold Corp. rose 10.0 percent.

Dow component Caterpillar, whose sales of heavy equipment are also heavily leveraged on trends in the mining industry, gained 1.9 percent on the better outlook for metals demand from China.

JPMorgan Chase, another Dow component, gave up 0.9 percent after disclosing that it faces civil and criminal investigations over its sale of mortgage-backed securities.

Slumping retailer JC Penney shot up 6.7 percent on reports that the company is searching for a new chief executive in response to pressure from activist investor Bill Ackman.

Telecommunications company CenturyLink dropped 5.6 percent after lowering its 2013 earnings forecast due to a bigger decline in some data services and slower growth in data hosting revenues.

Bond prices rose. The yield on the 10-year US Treasury slipped to 2.59 percent from 2.60 percent, while the 30-year fell to 3.67 percent from 3.69 percent. Bond prices and yields move inversely.