Stocks turned higher in the final minutes of trading Friday, with the S&P logging its sixth-consecutive rally, despite a disappointing Chinese trade report that raised worries over slowing global growth.
The Dow and S&P 500 posted their fifth-straight winning week.
The Dow Jones Industrial Average rose 42.76 points, or 0.32 percent, to close at 13,207.95, led by H-P and Alcoa.
The S&P 500 edged up 3.07 points, or 0.22 percent, to finish at 1,405.87. The Nasdaq squeezed out a gain of 2.22 points, or 0.07 percent, to end at 3,020.86.
The CBOE Volatility Index, widely considered the best gauge of fear in the market, finished below 15.
For the week, the Dow gained 0.85 percent, the S&P 500 rallied 1.07 percent, and the Nasdaq jumped 1.78 percent. H-P was the biggest weekly gainer, while AmEx lagged.
“When your investment strategy is anchored by hope that the central bank does something, that shows times are pretty tough,” said Lawrence Creatura, portfolio manager at Federated Investors. “We’re moving towards the tail end of the earnings season and the equity market will be increasingly driven by macro data, which haven’t been particularly uplifting.”
China's July exports rose just 1 percent from a year earlier, disappointing estimates by a wide margin and adding expectations that the Chinese central bank will take further policy stepsto support an economy that has seen declining growth for six-consecutive quarters.
Also on the economic front, import prices fell 0.6 percent in July for the fourth straight month, according to the Labor Department. Analysts had expected a gain of 0.1 percent. The unexpected decline could give the Federal Reserve more reason to ease monetary policy. (Read More: Do Global Equity Markets Need a Reality Check?)