Uncertainty over the costly trade conflict between the U.S. and China has clouded the outlook for trade as well as company profits. But stocks shook off an early wobble on Wall Street as solid earnings from Walmart encouraged investors to bid up other retailers and consumer goods companies. Communication services stocks and banks also contributed to the broad gains.

Roughly 81 percent of S&P 500 companies have reported results for the last three months of 2018, delivering earnings growth of 13.1 percent versus a year earlier, according to FactSet. First-quarter snapshots are expected to result in a 2.5 percent decline in earnings, however.

The benchmark S&P 500 index gained 0.1 percent to 2,779.76, while the Dow Jones Industrial Average was almost flat at 25,891.32. The Nasdaq composite added 0.2 percent to 7,486.77. The Russell 2000 index of smaller companies picked up 0.3 percent, to 1,574.47.

Major European indexes finished mostly lower.

Investors are keeping a close eye on talks between U.S. and Chinese negotiators in Washington that are aimed at ending a trade war between the world's largest economies.

JAPAN TRADE: A 17 percent drop in Japan's exports to China and 13 percent decline in exports to the rest of Asia including China helped drag overall exports sharply lower. Japan's imports fell 0.6 percent, leaving a deficit of 1.4 trillion yen ($12.8 billion), up 50 percent from a year earlier. The weak numbers suggest China's slowdown and trade tensions with the United States are hurting demand.

CURRENCIES: The dollar rose to 110.79 yen from 110.63 yen on Tuesday. The euro strengthened to $1.1345 from $1.1343.

ENERGY: U.S. benchmark crude gained 22 cents to $56.67 per barrel in electronic trading on the New York Mercantile Exchange. It rose 0.8 percent to settle at $56.45 a barrel on Tuesday. Brent crude, the standard for international oil prices, added 7 cents to $66.52 per barrel.