Major U.S. stock indexes closed slightly higher Thursday, rebounding from a two-day slide, as investors looked ahead to the start of the next round of corporate earnings, beginning next week.

Traders drew encouragement from the latest economic data, particularly a government report indicating a steep drop in applications for unemployment benefits last week. That appeared to reassure investors that the government will report solid job growth for March.

"There is a little bit of an expectation that the jobs number will come in good," said JJ Kinahan, TD Ameritrade's chief strategist. That report is due out Friday, when the markets will be closed for Good Friday.

The Dow Jones industrial average gained 65.06 points, or 0.37 percent, to close at 17,763.24 Thursday. The Standard & Poor's 500 index rose 7.27 points, or 0.35 percent, to 2,066.96. The Nasdaq composite added 6.71 points, or 0.14 percent, to 4,886.94.

The price of oil fell back below $50 a barrel after the United States, five other world powers, and Iran reached an agreement that could soon lift sanctions on Iran and allow the country to export more crude.

Trading got off to a turbulent start. Major indexes briefly turned lower at midday before moving higher, a trend that held the rest of the day. Investors have been weighing mixed economic data as they try to gauge how corporate earnings will unfold in coming weeks.

Earlier in the week, they got a dash of positive data on consumer confidence, spending and home prices, but also discouraging reports on hiring, construction spending, and manufacturing.

Thursday's economic data gave investors more reasons to be optimistic.

The Labor Department said applications for unemployment benefits fell sharply last week to a seasonally adjusted 268,000, and the Commerce Department said factory orders edged up 0.2 percent in February, breaking a six-month losing streak. Excluding volatile transportation orders, factory orders rose 0.8 percent, the most since June.

Meanwhile, the Commerce Department said the nation's trade deficit plunged 16.9 percent to $35.4 billion in February.

Financial analysts anticipate that the Labor Department will report Friday that employers added 248,000 jobs last month, according to FactSet. Employers added 295,000 jobs in February.

On Thursday, the slide in crude oil deepened. Benchmark U.S. crude fell 95 cents to close at $49.14 a barrel in New York. Brent Crude, a benchmark for international oils used by many U.S. refineries, fell $2.15 to close at $54.95 in London.