Commodity industry lobbyists are trying to build an escape hatch that will permit professional speculators to evade congressional efforts to close commodity tax loopholes that cost the government billions of dollars a year.

It's all right to prohibit doctors, dentists and other private investors from using commodity futures transactions to avoid taxes, the trade representatives are saying, but industry insiders ought to be exempt from such a law.

If professional speculators are not allowed to continue to use specially structured commodity trades to shelter their income from taxation, they will pull out of the commodity markets, industry lobbyists contend. The lobbyists are warning Congress that the efficient operation of the nation's grain markets and other commodity exchanges will be jeopardized by closing all the tax loopholes.

The industry is promoting what it terms a compromise on legislation that would outlaw a variety of exotic tax avoidance schemes.

Known as spreads and straddles, the commodity tax tricks make it possible to create artificial tax deductions and to convert ordinary income, taxed at rates up to 70 percent, into long-term captial gains on which the maximum tax is 28 percent.

The so-called compromise would in effect prohibit taxpayers from using such commodity trades to reduce the income tax due on profits made on other kinds of business.

But it would permit any profits made in commodities to be offset by other commodity losses, effectively restricting the commodity deduction schemes to industry insiders.

"The basic concern was that spreads are being used to shelter some other types of income," said Thaddeus Davis, a lawyer who lobbies for the commodity industry. "We all agree we've got to get rid of the sheltering of unrelated income."

But for professional commodity traders, Davis said, "It's not a question of shelter; it's a question of how they; make their living. People in the commodity business are subject to the highest tax rates, up to 70 percent" on their short-term trading profits, he explained. The business is too risky to attract speculators unless they can use special trading techinques to convert their earning to long-term gains, taxed at the lower rate.

"Without long-term capital gains, the people who are providing the liquidity to the marketplace just won't be there," said Davis.

But sponsors of the commodity tax reform legislation, particularly Rep. Benjamin Rosenthal (D-N.Y.) believe professional commodity traders are the biggest beneficiaries of the commodity tax loopholes and ought to be taxed like everyone else.

The move to protect the graders in the pits from the congressional crackdown on commodity tax abuses provides a rare glimpse of how a powerful industry can exert its influence on legislation involving highly technical issues.

Aided by the firm of influential lobbyist Charles Walker, a prominent campaign adviser to President Reagan, the big New York and Chicago commodity exchanges have been making their case to members of the Joint Taxation, House Ways and Means and House and Senate agriculture committees. Several members of Congress have been given guided tours of the commodity markets as part of the pitch and others involved in the legislation reportedly have been invited to go sailing with Davis.

The plea for special treatment is being made in the face of growing demands on Capital Hill for changes in federal tax laws to eradicate commodity trading gimmicks that can be used to create artificial income tax deductions.

There was little support for such a move a year ago when a commodity tax reform bill was first introduced by Rep. Charles Vanik (D-Ohio) and Rosenthal.

After Vanik retired, the measure was picked up by Rep. William Brodhead (D-Mich.), an influential member of the House Ways and Means committee, and others in the House. A companion bill was filed in the Senate by Daniel Patrick Moynihan (D-N.Y.). The Reagan administration also backs the idea and is budgeting more than $1 billion is extra revenue from closing the commodity loopholes.

The measures gained support from disclosures that commodity tax dodges were promoted by some of the nation's biggest brokerage houses, including Merrill Lynch, Pierce, Fenner and Smith, the firm previously headed by Secretary of the Treasury Donald T. Regan.

A highly publicized tax court trial involving two Merrill Lynch customers and congressional hearings on proposed tax law changes have disclosed half a dozen different ways in which commodity transactions can be used to avoid or reduce federal taxes.

Even farm-state legislators familiar with the workings of the grain futures markets were surprised to learn how commodity trading could be used to reduce taxes and in some cases defer them indefinitely.

The abuse of the commodity markets was news to Congress, but the federal agencies charged with regulating the commodity markets have known about it for at least 35 years, according the documents obtained by The Washington Post.

When the Commodity Futures Trading Commission was created in 1975 its first chairman, William T. Bagley, received two staff memos detailing how the markets were being used to avoid federal taxes and recommending the agency take action.

Many of the same techniques are spelled out in a report written in December 1947 for the old Commodity Exchange Authority, the agency of the Department of Agriculture that previously had jurisdiction over the markets.

"There is evidence of large use of futures trading for the purpose or postponing, reducing or even completely avoiding payment of income tax," the 1947 report begins.

Three years later, Congress outlawed the most blatant of the commodity tax gimmicks, but the 1950 reforms did not end commodity tax tricks.

When Bagley asked about the topic in 1976, the CFTC staff reported: "Currently futures trading cna be used to accomplish several tax avoidance objectives."

But the commodity regulators, who traditionally have had close ties to the industry they oversee, did nothing about the abuse of the income tax laws, despite warnings that the tax transactions were affecting the normal operations of the markets.

"Economic considerations rather than tax considerations should govern commodity futures trading," a 1976 CFTC staff memo urged. "The fundamental supply and demand factors should not be distorted by tax traders, neither should tax traders be allowed to shelter other outside income through economically unjustifiable futures transactions."

Last year Treasury Department officials expressed concern about potential distortion of the market of government bonds and Treasury bills because of "use of the market for speculative and tax purposes.

"Speculative activity can adversely affect Treasury's debt management responsibility to the extent that it disrupts the underlying cash market for Treasury securities," the agency said in a memo to a congressional committee.

The Treasury's concern is the way taxes are figured on Treasury bills and T-bill futures contracts. The law now specifies that profits and losses on Treasury bills are to be taxed as ordinary income. Gains and losses on T-Bill futures contracts are capital gains, long or short term depending on how long the contract was held.

The tax law sets a limit of $3,000 on the amount of short-term capital gains that can be deducted from other income, but no limit on deducting ordinary income losses.

An investor who loses money on a T-bill futures contract is generally better off getting an ordinary income deduction, so the whole thing can be deducted.

To convert the capital loss on futures into ordinary loss, simply requires waiting for the futures contract to expire and taking delivery of the T-bills. Hugh numbers of investors have been doing that recently, not only costing the Treasury tax revenue, but also disrupting the T-bill market.

The commodity tax loophole bill would prohibit the conversion of capital to ordinary loss by taking delivery of the T-bills.

Other, more complex commodity transactions make it possible to convert ordinary income into long-term capital gains, or to convert short-term capital gains into long-term gains.

Those tax schemes involve spreads or staddles -- simultaneously buying and selling contracts for future delivery of some contract in two different months. Regardless of whether the price of the commodity goes up on down, one contract will lose money -- which can be deducted -- while the other will make a profit.

If the profitable contract is held at least six months, the profits qualify for capital gains taxation at the 28 percent rate, while the loses are deducted from ordinary income taxed as high as 70 percent.

If the profitable "leg" of the spread is held into the following year, the taxpayer delays paying taxes on the earnings for a full year.

One reason commodities are used so frequently to convert ordinary income to capital gains is that commodity investments qualify as long-term gains after six months, while all other investments must be held a full year.

Congress extended the holding period from six months to a year in 1976, but specifically exempted commodities.

"This looks like a successful lobbying effort by some commodity traders to preserve the present framework though which tax straddles may be more easily worked," the 1976 CFTC report on commodity tax schemes noted.

Lobbyist Davis, the industry advocate in the present commodity tax debate, represented the Chicago Board of Trade, when the 1976 tax bill was drafted, and is credited by many in the industry with preserving the six-month holding period for commodities.