The stock market took an 18-point joy ride yesterday on a wave of enthusiasm generated by the agreement to try to lower the value of the U.S. dollar in foreign exchange markets.

The move, which pleased both Wall Street and industry officials, held out the hope that a weaker U.S. dollar would improve the earnings of U.S. corporations by making their products more affordable to foreign buyers and more competitive at home.

As stocks rose, the dollar took a steep drop against major foreign currencies.

President Reagan, meanwhile, said he would ask Congress to provide $300 million for low-cost loans to selected exports in an effort to help U.S. industries hit by foreign competition.

With the market opening up 17 points, technology and pharmaceutical issues were among the largest gainers. Firms with significant overseas operations also saw their shares rise sharply. Some traders expressed disappointment that once the buying surge passed, prices firmed and the trading eased off.

The Dow Jones average of 30 industrials climbed 18.37 points to close at 1,316.31, the best gain since the indicator rose 24.75 points June 21. Gainers outpaced losers by more than 2 to 1. Volume for the day was 124.6 million shares. Institutional buying was considered moderate as the New York Stock exchange recorded 2,036 block trades -- 10,000 shares or more.

While Wall Street analysts agreed that yesterday's rally was sparked by the international effort on the dollar, they disagreed on how long the rally might last.

Prudential Bache economist Edward Yardeni said he thought the stock market rally, would be "fairly short-lived." He added, "The market is not going anywhere for a while."

Charles S. Comer, market analyst for Oppenheimer & Co., who expects the market to trend lower with the Dow Jones industrial average going to the 1,275 level, "I don't see the short-term picture being appreciably affected."

John Connolly, chairman of Dean Witter's investment policy committee, said the market rally was a "significant event" that is "right up our alley." The U.S. dollar, already down from its February peak, was dropping on its own, he noted, but "this speeds it up."

Action on the dollar, Connolly added, "doesn't cure everything. . . . The budget deficit still hasn't been addressed."

Corporate officials greeted the action with praise. Edward T. Sheehan, manager of foreign finance at General Electric, said, "Overall, it has got to be good for GE if a sustained weakening of the dollar makes our products more competitive overseas and in the U.S."

Bob Noyce, vice chairman of Intel, said, "I would applaud the move but it will be fruitless unless the fundamental issue is attacked." He described that issue as the "inadequate" level of personal and business saving. A savings increase is needed, he said, to help cure the U.S. deficit problem.

Among multinational stocks, International Business Machines rose 1 3/8 to 128 1/8, Digital Equipment jumped 2 1/2 to 111 3/8, Dow Chemical was up 1 at 36, Pfizer spurted 2 to 47 1/4 and Westinghouse gained 7/8 to 38 7/8. Other multinational issues that gained included Ford Motor, F. W. Woolworth and Upjohn.

Mining stocks advanced after the dollar's drop helped gold prices rise about $10 an ounce. ASA Ltd. rose 1 5/8 to 38 1/2, Homestake Mining moved up 3/4 to 25 5/8 and Campbell Red Lake gained 1 to 23.

Smithkline Beckman rose 1 5/8 to 65 1/8 after announcing that its board approved the repurchase of up to 5 million of the company's shares.

American Telephone & Telegraph was unchanged at 21 1/2 and topped the NYSE's active list. Trading included a 2.09 million-share block at 21 5/8 and a 1.42 million-share block at 21 3/8.

Peabody International edged up 1/8 to 10 5/8 after a 1.66 million-share block crossed at 10 1/2.