NEW YORK - A seesaw day for U.S. stocks ended with slight losses Thursday, giving the market its fourth drop in a row.

Edgy investors continue to monitor violence in the Middle East and the rapid ascent of the U.S. dollar, which is causing companies to pull back their profit forecasts for the year.

After hitting record highs earlier this month, stocks have been steadily declining this week. Strategists and traders said the strong dollar, geopolitical tensions, and a market that is already expensive have given investors little impetus to buy in recent days.

The Dow Jones industrial average lost 40.31 points, or 0.23 percent, to 17,678.23. The Standard & Poor's 500 index lost 4.90 points, or 0.24 percent, to 2,056.15, and the Nasdaq composite fell 13.16 points, or 0.27 percent, to 4,863.36.

The market has fallen every day this week, bringing the S&P 500 index and the Dow down 2.5 percent each and erasing their gains for the year. The Nasdaq composite has dropped even more this week, 3.2 percent, as traders targeted high-flying biotech companies for heavy selling. The Nasdaq is still up 2.7 percent for the year.

Most of the action Thursday was in energy markets. The price of oil rose sharply as mounting tensions in Yemen got traders worried that the flow of crude from the Persian Gulf region could be disrupted. Saudi Arabia and other Gulf states launched strikes on military installations in Yemen in an effort to oust Shiite rebels who forced the country's embattled president to flee.

U.S. crude rose $2.22, or 4.5 percent, to close at $51.43 a barrel in New York. U.S. crude oil has jumped 17 percent since hitting a low of $43.96 a barrel a week ago. It was the first time the benchmark U.S. oil contract closed at $50 or higher since March 9. Brent crude, a benchmark for international oils used by many U.S. refineries, rose $2.71, or 4.8 percent, to close at $59.19 a barrel in London.

For most investors, the main focus remains the U.S. dollar, which has appreciated 8 percent in the last three months. A stronger dollar tends to make U.S.-made goods more expensive abroad, making it more difficult for U.S. companies to compete. On Thursday, the euro fell to $1.0885 against the dollar, while the dollar declined to 119.18 Japanese yen. The full impact of the dollar's appreciation will likely be seen early next month, when U.S. companies start reporting quarterly results.

In the bond market, prices for U.S. government bonds fell. The yield on the 10-year Treasury note rose to an even 2 percent from 1.93 percent the day before.

In metals trading, gold rose $7.80 to $1,204.80 an ounce, silver rose 14 cents to $17.14 an ounce and copper rose two cents to $2.81 a pound.