Almost any way you look at what happened to Washington area stocks in 1987, you come to the same conclusion. They moved up fast in January and February but fell even faster in October. By the time it was all over, most stocks were either back where they started or below where they started.

This conclusion is reinforced by the performance of the Defense and Technology Index, which is compiled quarterly by analyst May G. O'Leary of Baker, Watts & Co. The index is based on 20 area companies that sell high-tech services to industry and government -- especially to the Defense Department. At the beginning of 1987, the D&T index stood at 97.05. On April 3, it hit its high for the year at 135.79, for a gain of 40 percent.

After that, the stocks in the index meandered around for several months. But they plummeted along with the rest of the market in October. The index found its low point at 83.31 on Dec. 4. At that point, it had dropped 39 percent from its April 3 high.

By the time Dec. 31 arrived, all the ups and downs hardly seemed worth the trouble. The D&T index had opened at 97.05 and had closed at 92.41, down 4.8 percent for the year. That performance was worse than that of the blue-chip Dow Jones industrial average, which gained a modest 2.3 percent, or the Standard & Poor's 500 index, which gained 2 percent.

On the other hand, the D&T index drop of 4.8 percent was slightly better than the Nasdaq composite of over-the-counter stocks, which fell 5.26 for the year. The similarity was not surprising, since 14 of the 20 stocks in the D&T index are listed on Nasdaq.

What this all means, O'Leary concluded, is that many of those high-tech stocks are good bargains. They are selling well below their all-time highs. And they have fallen in price basically because the market has fallen, not because the companies are in any kind of trouble. In fact, some firms are doing quite well. If that spells opportunity, O'Leary said, it comes with one caveat.

"The psychology surrounding defense-related stocks continues to be negative," she said. "Budget reduction talk is the obvious reason." In short, the budget-cutting talk has made investors fearful that Washington's high-tech defense companies can be hurt by major cuts in military spending.

That pressure to make cuts is very real, said John J. Ford, former staff director for the House Armed Services Committee. In a report for the Washington Forum, Ford noted that Defense Secretary Frank Carlucci had ordered the military services to cut their fiscal 1989 budgets by 10 percent, or $32.9 billion. The military services also must trim their five-year plans by as much as $250 billion.

What will this mean to the typical Beltway high-tech company?

Ford said the answer would depend on the kind of work a company does in the defense arena but that some companies might be protected by their business niches.

Many Beltway companies, he noted, are involved in electronics and communications work. "That is the last thing the services will cut," he said. When a general or admiral is asked what he wants most, the answer is always the same, Ford said. "It's command, control and communications."

Moreover, Ford said, the services never seem satisfied with their communications systems, and are always trying to upgrade them, especially when new electronic programs are being delayed or stretched out.

Clearly, other observers report, the defense procurement climate is much tougher than it was several years ago. There is a greater emphasis on competitive bidding and reducing profit margins. Contracts tend to be larger and last longer. As a result, there is more "teaming" on contracts, and some firms have had to merge to stay alive.

Yet other companies report record backlogs of work and rising profits.

Obviously, an investor who is interested in local high-tech stocks is going to have to do some research to find companies that look like they can survive and prosper.

Fortunately, O'Leary already has analyzed several D&T stocks selling below their precollapse highs. Here are several she favors:

BDM International of McLean. BDM is the classic Beltway professional services company, deeply involved in defense, communications and space, with a five-year annual profit growth record of 27 percent.

O'Leary said she was disappointed with BDM's revenue growth in 1987 but noted, "We do not feel it was due to the loss of contracts but rather to delays and the stretch-out process by the government."

O'Leary said she had lowered her 1987 revenue estimate for BDM to $320 million to $325 million, about the same amount BDM took in in 1986. O'Leary expects that BDM sales in 1988 will total $390 to $400 million. The analyst predicted that the $1.21 a share BDM earned in 1986 will move up to $1.63 for 1987 and to $2.03 a share in 1988. These increases will be aided, in part, by declining tax rates, she said.

On the revenue front, O'Leary said that BDM booked $234 million in new business during the September quarter, bringing its backlog to $552 million, up 22 percent over a year earlier.

BDM shares, which sold at a high of $36.13 last year were cut in half by the time the October collapse was over. They have since moved back to $21.63, as of Friday, and are selling for a 40 percent discount to their earlier high.

American Management Systems of Arlington. AMS, which installs and operates computer software systems, has seen its profits grow at an annual rate of 38 percent during the last four years. AMS derives about 25 percent of its revenue from the Defense Department.

O'Leary estimates that AMS profits will total 70 cents a share for 1987, 95 cents in 1988 and $1.25 in 1989.

AMS shares, which were trading as high at $19.88 last year, hit a post-collapse low of about $10 and bounced back to the $15 level last week. On Friday, the shares closed at $13.50. At that price, AMS shares were selling 32 percent below their high -- a level O'Leary thinks is attractive.

Iverson Technology of McLean. Iverson works in the "hot" area of Tempest technology, a system for protecting computer data from electronic eavesdropping. Most of the company's revenue comes from U.S. government agencies, although the Defense Department apparently is not a major customer.

A major FBI contract will help Iverson boost its 1987 revenue to $41 million, well up over the 1986 sales of $23.3 million. Iverson sales should then rise to $55 million in 1988, O'Leary said. If so, the 60 cents a share booked in 1986 will go up to 90 cents for 1987 and $1.27 in 1988.

Iverson's stock, which topped out at $23 and fell to about $9 when the market plunged, has moved back to $17, but it still down 26 percent from its high.

QuesTech of McLean. A professional services company involved in electronic warfare and intelligence systems, QuesTech saw its stock price drop from a high of $15.25. It now sells at about $8, down 48 percent.

"We like the long-term outlook at QuesTech, especially after the recent award of the largest contract in the company's history ($45 million) and the addition of new management talent," O'Leary said.

O'Leary reminded investors that it might be difficult to trade in and out of the stock quickly. While there are about 1.5 million shares outstanding, she said, about 60 percent are owned by management. Thus, the "float" or the amount available for public trading is only about 600,000 shares. That could make the stock quite volatile.

QuesTech is a turnaround company that seems to be making a strong comeback. O'Leary estimates that operating earnings for 1987 will be $1.07 a share, compared with 83 cents in 1986. In 1988, O'Leary expects to see earnings of $1.40.

Sales in 1987 are expected to reach $65 million, up from $47.5 million in 1986. For 1988, O'Leary is looking for $80 million.