Traders work on the trading floor of the New York Stock Exchange. / David Karp, AP

by David Carrig, USA TODAY

by David Carrig, USA TODAY

Stocks broke a two-day losing streak and closed higher Friday in a volatile week that saw major indexes hit record highs and then tumble. The Dow posted a loss for the week, the S&P 500 was basically flat and the Nasdaq advanced.

The major indexes earlier bounced back and forth between small gains and losses throughout the session before a late-afternoon rally boosted stocks.

For the week, the Dow fell 0.6%, the S&P 500 dipped 0.03% and the Nasdaq gained 0.5%.

Investors were searching for direction after a volatile week saw the Dow and S&P 500 hit record closing highs on Tuesday and then drop sharply two days in a row.

Mixed economic data added to Friday's lackluster performance. The housing market saw a sign of encouragement on news that home building surged in April. Housing starts rose to a seasonally adjusted annual rate of 1.07 million, up from 947,000 in March, the Census Bureau said.

But a monthly gauge of U.S. consumer sentiment fell in May as a gloomy view on income growth clouded an otherwise positive economic outlook, a survey showed.

The Thomson Reuters/University of Michigan's preliminary May reading on the overall index on consumer sentiment came in at 81.8, down from 84.1 the month before. It was also below the expectation of 84.5 among economists polled by Reuters.

In corporate news, Darden Restaurants fell 4.3% to $48.49 after the company said it's selling its Red Lobster chain to Golden Gate Capital for $2.1 billion.

The Sensex stock index in Mumbai rose 0.9% to 24,121.74 after earlier touching an all-time high of 25,375.63. India's opposition Bharatiya Janata Party looked set to earn enough parliamentary seats to create a government without forming a coalition with regional leaders.

Thursday, the Dow tumbled 167 points, dropping 1% to 16,446.81. Wal-Mart was the biggest loser of the Dow 30 as the retailer reported a 5% drop in profits in the first quarter and missed analysts' estimates. The Standard & Poor's 500 index plunged 0.9% and the Nasdaq composite index shed 0.8%.