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 four 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.