Stock prices closed modestly higher on Wall Street yesterday after a flurry of profit-taking trimmed the early gains that greeted another sharp advance in the strength of the dollar.

The Dow Jones industrial average closed up 16.25 points at 2031.50, bringing its two-day gain to 92.67 points. On Monday, the first trading day of the year, the Dow soared 76.42 points amid signs that central banks were acting to stem the dollar's decline.

The Dow's move yesterday took it to its highest point since the stock market cracked on Oct. 19 and dropped 508 points.

Shortly after the opening bell yesterday, a flood of buy orders took the Dow up about 50 points. An hour before closing, it was still ahead about 30 points, but slipped late in the session on a round of profit-taking, analysts said.

Program trading, in which institutional investors bought stocks and sold stock index futures, was responsible for part of the flurry of early buying.

Speculation in drug stocks, linked to a bid for Sterling Drug by F. Hoffmann-La Roche Co., also produced higher prices and heavy volume.

The buying pattern was broad-based, with advancing stocks leading decliners by more than 3 to 1 on the New York Stock Exchange.

A total of 209.5 million shares changed hands on the Big Board.

Standard & Poor's 500-stock index gained 2.69 to close at 258.63, while the New York Stock Exchange composite index closed at 144.54, up 1.64.

The American Stock Exchange composite rose to 271.77, up 5.03.

The National Association of Securities Dealers index of over-the-counter stocks rose 5.59 to close at 344.07.

Good news on the dollar sent bond prices sharply higher. The Treasury's key 30-year bond climbed about $7.50 for every $1,000 in face value, as its yield slipped to 8.86 percent from 8.93 percent.

Market analysts, expressing varying degrees of certainty, said they expected the market's upward move to continue, but without the "locomotive" effect displayed during last January's rally, when the Dow advanced for 13 straight days.

Hugh A. Johnson, chief economist at First Albany Corp., in Albany, N.Y., said that while there were a few similarities between the trading climates this week and a year ago, "there was more reckless abandon last year."

In the wake of the October plunge, he said, investors are far more cautious about what they buy and what they are willing to pay. Unlike last year, when the bull market was going strong, Johnson said, "Investors are willing to wait for the next train."

Newton Zinder, market analyst for Shearson Lehman Bros. in New York, said, "I see further gains, but it is not going to be as easy as last January."

Zinder said he anticipated "heavy resistance" in the market at the 2050 to 2080 levels on the Dow.

But Don R. Hays, research director at Wheat, First Securities in Richmond, said, "The bruises are beginning to be healed. People are starting to believe in the stock market again."

Hays, noted for his bullishness, said he foresees the Dow reaching 3000 within the next 12 months to 18 months, based in part on a decline in interest rates.

The market's Oct. 19 plunge, Hays said, "served to lengthen the bull market, not end the bull market."

Hays said a decline in interest rates on commercial paper to 6.8 percent from 8 percent in the last several weeks was a harbinger of a move to lower interest rates.