On Oct. 19, the day that panic selling by investors collapsed the stock market in New York, stock index futures markets in Chicago suffered their first computer panic.

As stock prices plummeted, the Chicago Mercantile Exchange was hit by round after round of orders triggered by two separate families of computer trading programs -- one intended to sidestep fluctuations in stock prices, the other meant to profit from them.

The computer trading programs that were attempting to minimize the impact of falling prices through a technique called portfolio insurance started flashing sell orders early that Monday morning. That selling pushed down futures prices and set off the computers programmed to exploit changing prices using a procedure known as index arbitrage.

What happened after that depends on who you believe.

Leo Melamed, chairman of the executive committee of the CME, said the massive selling in the futures markets took pressure off the New York Stock Exchange and kept the 508-point plunge in the Dow Jones industrial average from being worse.

John S. Phelan, chairman of the New York Stock Exchange, said collapsing futures markets pulled stocks down with them, causing a "meltdown" that very nearly destroyed both markets.

Almost 10 percent of the shares dumped on the NYSE on Black Monday were sold under orders from computers doing arbitrage trading, according to government reports. Those trades triggered a nearly equal amount of activity on the CME. Additionally, as much as 24 percent of the CME's stock index trading that day was produced by computerized portfolio insurance.

The computer programs dumped sell orders for millions of shares of stock into an already overloaded market on Oct. 19, said Philip Erlanger, chief technical analyst for Advest Inc., a Connecticut investment advisory firm. "We really needed more sellers on the 19th" said the embittered Erlanger, a longtime critic of some computer trading techniques. "We got ourselves into a situation where, at the extreme, the programs changed the value of the market."

"You had computers spewing out orders like robots," said Jack Barbanel, a vice president of Granthal & Co., a New York trading firm. Barbanel said he believes computer orders triggered more computer orders, sending prices in both the futures and the stock markets much lower than they otherwise would have gone.

The impact of computerized trading techniques on the markets will be the first topic of debate when Congress tackles the question of what to do about the stock market collapse. Already, half a dozen studies have begun and members of Congress have begun to choose sides in the program trading battle.

Program trading is a catch-all concept that once referred to any technique for buying and selling large blocks of stocks, usually using computers to calculate possibilities and to execute complex transactions. Recently, the definition has narrowed to apply only to deals that combine trading in stocks with transactions in stock index futures or options.

Stock index futures are a five-year-old financial innovation that theoretically allow stocks to be bought or sold for future delivery, in the same way that corn and wheat have been traded for years. The futures contracts are based on baskets of shares that include all the stocks in the Standard & Poor's 500-stock Index, the Value Line Stock Index or some other stock market index.

Someone who buys an S&P 500 futures contract on the CME puts up a small deposit and agrees -- in theory -- to buy one share of each of the 500 stocks and to collect and pay for them months later. The purchase is only theoretical because the contracts are in practice settled with a cash payment, not by delivering the shares.

If stock prices go up, the futures contract increases in value and can be sold at a profit; if stock prices fall, the futures contract holder has to make up the losses.

Generally, traders who think stock prices will go up buy stock index futures, hoping to sell them for a profit. Traders who think prices are going down can sell futures contracts, hoping to repurchase them at a lower price later. Stock index options work in much the same way and are used in some program trading.

When trading in stock index futures and options was first proposed, critics said it was just a way to bet on the stock market without putting up all the cash needed to buy shares. Stock index futures might make money for Chicago commodity traders, it was charged, but they had nothing to do with the business of Wall Street.

Five years of stock index trading have proven those critics were off by 180 degrees. The criticism of stock index futures today is that they have become so entwined with the stock market that the Chicago futures markets are influencing the prices of stocks in New York.

Until the stock market collapsed, the CME was trading stock index futures worth $12 billion a day -- more than the value of the shares bought and sold in New York on most days.

The best-known program trading method is index arbitrage, a technique for making money from the difference between the price of stock index futures in Chicago and the price of the actual stocks in New York. On the day a stock index futures contract matures, its price is exactly the same as the price of the stocks it represents, and at other times the two prices usually are close. Occasionally, however, they diverge enough that it is possible to buy in one market and sell in another and make a profit if the transactions are done quickly.

Doing that requires computers capable of tracking the price of 500 stocks on a minute-by-minute basis, and constantly comparing them with stock index futures prices. The computer also has to be programmed to calculate the commissions, interest and other costs of trading the stocks and futures contracts and to factor in any dividends that will be earned on the shares.

The computer not only watches the two markets, but also executes the trades, dispatching 500 stock buy or sell orders at the press of a button. Because it is costly and cumbersome to buy or sell a single share of stock, most index arbitrage trades involve hundreds of shares of each stock and several hundred futures contracts.

These multimillion-dollar blocks of stock, however, are usually bought or sold through a special NYSE system designed to process "small" orders of 1,000 shares or less. The small-order system gives program traders one big advantage that makes the technique work especially well: The small orders are automatically filled at the last price quoted on the stock exchange's ticker, thus eliminating the risk that stock prices will change between the time the computer calculates an arbitrage opportunity and the few seconds it takes to put in the order.

After Black Monday, the NYSE temporarily told its members to stop using the small-order system for program trading, effectively ending the practice. After the stock market calmed down, the stock exchange reopened the small-order system -- allowing index arbitrage to resume.

Index arbitrage became the first program-trading device to attract attention because it has been blamed for wild swings in stock prices on days when stock index futures and options contracts expire.

Fearing that other investors were being scared out of the stock market on days when big program trading was expected, both the NYSE and the CME changed their rules last year to minimize the last-minute buying and selling.

Because index arbitrage requires making multimillion-dollar investments, the business is dominated by a handful of large Wall Street investment houses. An even smaller number of firms are involved in portfolio insurance, the other computer-driven investment strategy linking futures and stock markets.

Portfolio insurance was invented by California college professors Hayne Leland and Mark Rubinstein as a way for pension funds and other big holders of stocks to hedge their portfolios against falling prices. The professors went into business with money manager John O'Brien, forming a company called Leland O'Brien Rubinstein Associates Inc. that now manages or advises billions of dollars of investments.

The obvious way to avoid losses when the market turns down is to sell your stocks, but selling stocks when prices are falling can drive them still lower. And some investors may want to hold their stocks for the long term, while avoiding short-term loses.

The answer, Leland and Rubinstein decided, was to create a method for hedging investments using a variation on a standard strategy used by many money managers.

Under that strategy, investors split their money into two piles, investing one in stocks, and putting the other in government bonds or some other safe investment. When stock prices are moving up, they shift a greater portion of the money into stocks to take advantage of the appreciation. When prices are falling, they tilt the balance of investment out of stocks and back into government bonds.

Leland O'Brien Rubenstein's new wrinkle in portfolio insurance was to sell stock index futures instead of stocks when the market heads down. Selling an S&P 500 stock futures contract today when the index is at about 245 means you'll get that price for your shares even if the index plummets to 230 next week. If stock prices go up, you'll lose money on the futures contract, but will make up for that on the increase in the value of the stocks you still hold.

The tricky part is to use stock index futures as little as possible, keeping as much money as you can invested in stocks when prices are going up, then selling more futures contracts when prices turn down. O'Brien told a government hearing recently that his firm's clients have been able to earn about 85 percent of the possible profits from rising stock prices while still protecting themselves against losses.

Portfolio insurance, however, proved able to provide far less protection than expected on Oct. 19.

Because Chicago traders expected stock prices to keep falling, the price of stock index futures went down even faster than the stock market did on Black Monday. The difference between stock and futures prices usually is a point or two on the S&P 500 index, but on that day index futures opened 20 points below stocks and the gap widened to as much as 28 points.

That meant the portfolio insurers had to accept a loss of 20 to 28 points on the S&P 500 just to sell their stock index futures. Because the S&P index dropped 58 points that day, the insurance cost one-third to almost one-half as much as the possible losses -- far more than any portfolio insurer ever expected. The cost of hedging stock investments with index futures proved to be so great that some portfolio insurers didn't buy all the "insurance" that their computer programs called for. The result was even heavier losses for clients.

This unexpected failure of portfolio insurance stunned companies like Leland O'Brien but was no surprise to veteran commodity traders. Years of experience in grain trading have shown them it can be very difficult -- if not impossible -- to hedge investments after prices have started to fall.

Even O'Brien has acknowledged that "the events of the week of Oct. 19 threaten the continued use of stock index futures for hedging purposes, at least to the extent previously believed to be appropriate."

O'Brien's solution is to change the rules of stock index futures trading to encourage the return of portfolio insurance. One of his recommendations is to lower the margin deposit, or down payment, that is required on stock index futures contracts, thus making it cheaper to hedge investments.

That suggestion is exactly the opposite of the result sought by the first legislation introduced in the wake of the stock market collapse. Similar bills introduced in the House by Rep. Jim Leach (R-Iowa) and in the Senate by Sen. John Heinz (R-Pa.) would for the first time give the Federal Reserve Board, rather than the commodity exchanges, the authority to set margin requirements for stocks purchased on credit.

decided it was not necessary for the central bank to set margins.

That decision sidestepped the issue of whether the Fed has the authority to do so.

"The case for outside intervention {on margins} was better before Black Monday," Leach said, because the commodity exchanges themselves already have raised margins, a step he called "an implicit acknowledgement" that margins were too low.

Raising the cost of trading stock index futures is one of several steps the CME is contemplating in response to Black Monday. "We can live with anything but margin" controls by the government, said Melamed, the father of financial futures trading.

Another possibility being considered by the exchange is setting limits on how far stock index futures prices can go up or down in a single day.

Daily price limits have been in effect for years on commodities such as corn, where prices can change by no more than 5 cents a bushel a day. When corn prices drop their daily limit, trading stops.

Melamed concedes that price limits on stock index futures might not work unless there also were limits on how much stock prices themselves could vary from day to day.

He said the exchange might also consider limits on how many stock index futures contracts a firm can hold.