Technology and health care companies led U.S. stocks higher Friday, giving the S&P 500 index its fourth straight weekly gain.

The broad rally came as investors grew hopeful that talks between the U.S. and China would defuse a costly trade war between the two countries. High-level talks between U.S. and Chinese negotiators were slated to continue this weekend.

On Friday:

The S&P 500 index rose 17.79 points, or 0.6 percent, to 2,792.67.

The Dow Jones Industrial Average gained 181.18 points, or 0.7 percent, to 26,031.81.

The Nasdaq composite climbed 67.84 points, or 0.9 percent, to 7,527.54.

The Russell 2000 index of smaller companies picked up 14.51 points, or 0.9 percent, to 1,590.06.

For the week:

The S&P 500 rose 17.07 points, or 0.6 percent.

The Dow added 148.56 points, or 0.6 percent.

The Nasdaq gained 55.13 points, or 0.7 percent.

The Russell 2000 picked up 20.81 points, or 1.3 percent.

For the year:

The S&P 500 is up 285.82 points, or 11.4 percent.

The Dow is up 2,704.35 points, or 11.6 percent.

The Nasdaq is up 892.27 points, or 13.4 percent.

The Russell 2000 is up 241.50 points, or 17.9 percent.