Major U.S. stock indexes eked out modest gains on Monday, extending the market's winning streak into a fourth day.
Stocks wavered into the red at times before steadying late in the session. The price of oil also veered lower at times, but it ended higher.
Investors had their eye on the latest batch of company deal news and new data on housing that sent homebuilders broadly lower. Telecommunications services and healthcare stocks were among the biggest risers.
Monday's climb builds on the market's five-week string of gains and suggests an improved outlook by investors since the market's rocky start to 2016. Worries about the global economy prompted the Federal Reserve to slow the pace of interest rate increases this year.
"Investors have really come to terms with the fact that recession risks are receding in the U.S., and that certainly was helped by the Fed action last week," said Mike Baele, senior portfolio manager at U.S. Bank Wealth Management. "We likely move sideways until we get some clarity on earnings."
The Dow Jones industrial average rose 21.57 points, or 0.1%, to 17,623.87. The Standard & Poor's 500 index edged up 2.02 points, or 0.1%, to 2,051.60. The Nasdaq composite went up 13.23 points, or 0.3%, to 4,808.87.
Thanks to steady gains in recent weeks, the Dow is up 1.1% for the year and the S&P 500 is up 0.4%. The Nasdaq is down about 4%.
Early Monday, stocks had appeared to be headed for a down day.
Homebuilders fell broadly after the release of a report indicating that sales of previously occupied U.S. homes sank 7.1% last month. The trend could weigh on homebuilders, many of which rely on buyers who must sell their home before they can purchase a newly built one. William Lyon Homes was among the biggest decliners. The stock sank 4.9% to $13.88.
Several companies rose on deal news.
Starwood Hotels & Resorts Worldwide climbed 4.5% to $84.19. Its proposed buyout by Marriott International, which could be contested by China's Anbang, would create the world's biggest hotel company. That probably weighed on fellow hotel operator Wyndham Worldwide, which slid 4.6% to $77.07.
Paint maker Valspar vaulted 23.1% on news of its $9-billion sale to Sherwin-Williams. Valspar shares rose to $103.22. Sherwin slumped 5.3% to $273.29.
Traders also welcomed Markit's decision to combine with competitor IHS in an all-stock deal valued at more than $13 billion. Markit surged 13.6% to $33.51.
Embattled drug company Valeant Pharmaceuticals climbed 7.4% to $28.98 as investors cheered a boardroom shake-up that includes plans to replace CEO Michael Pearson and the addition of activist investor Bill Ackman to the board. The stock has slid 71.5% this year.
Oil prices also recovered after dipping earlier in the day.
Benchmark U.S. crude rose 47 cents, or 1.2%, to close at $39.91 a barrel in New York. Brent crude, the benchmark for international oils, gained 34 cents to close at $41.54 a barrel in London.
Several energy companies slumped as natural gas lost 8 cents, or 4.1%, to close at $1.83 per 1,000 cubic feet.
Williams Cos. sank 4.4% to $17.35, and Cabot Oil & Gas slid 4.3% to $21.79. Natural gas transport and storage company Oneok fell 3.7% to $29.69.
Market action overseas was mixed.
In Europe, Germany's DAX was essentially flat, while France's CAC 40 fell 0.8%. Britain's FTSE 100 slipped 0.1%. In Asia, South Korea's benchmark Kospi index slipped 0.1%, while Hong Kong's Hang Seng index rose 0.1%. Australia's S&P/ASX 200 dipped 0.3%. Markets in Japan were closed for a holiday.
In other energy trading, wholesale gasoline climbed 3 cents, or 2.2%, to close at $1.46 a gallon. Heating oil slipped less than a penny to close at $1.24 a gallon.
Among metals, gold dropped $10.10, or 0.8%, to $1,244.20 an ounce. Silver fell rose 4 cents, or 0.2%, to $15.85 an ounce. Copper rose a penny, or 0.4%, to $2.29 a pound.