The Dow Jones industrial average and the Standard & Poor’s 500 index closed at record highs Monday as the market delivered its fourth gain in as many trading days.

Pharmaceutical and technology stocks were among the big risers, while shares in energy companies fell sharply as the decline in oil prices deepened. Discouraging data on U.S. home sales failed to derail the “Santa” rally, what traders often call a pre-Christmas advance.

Trading volume was lighter than usual as many investors looked ahead to the Christmas holiday.

“We’re getting a good Santa Claus rally,” said Sam Stovall, U.S. equity strategist at S&P Capital IQ.

After a strong finish last week, investors remained mostly in a buying mood Monday. The major stock indexes drifted between small gains and losses in the morning, as traders digested the latest housing data.

The National Association of Realtors reported that sales of previously occupied homes fell 6.1 percent last month to a seasonally adjusted annual rate of 4.93 million. That’s the slowest pace in six months.

By late morning, the major indexes were rising and holding on to gains that were modest, but good enough for a new set of record highs.

The Standard & Poor’s 500 index gained 7.89 points, or 0.4 percent, to 2,078.54. The S&P’s most recent record close was 2,075.37, set on Dec. 5.

The Dow Jones industrial average rose 154.64, or 0.9 percent, to 17,959.44. Its last record close was 17,958.79 on Dec. 5.

The Nasdaq composite picked up 16.04 points, or 0.3 percent, to 4,781.42.

The Dow and S&P 500 are both up for the month, while the Nasdaq is down. The three indexes are up for the year.