My all-time favorite piece of stock-market wisdom dates back to 1940. But it seems so exactly to the point today that I'll quote it in full. It's from one of the funniest books ever written about Wall Street, Fred Schwed Jr.'s "Where Are the Customers' Yachts?"

"When the market is doing well and your friends and neighbors are buying stock," he wrote, "sell and put your money in the bank. The market will go higher -- maybe quite a bit higher. Ignore it. "Eventually there will be a recession. When it gets so bad as to arouse the politicians to make speeches, take your money out of the bank and buy stock. The market will go lower -- maybe quite a bit lower. Ignore it.

"This investment advice always works," he concluded, "but the procedure is so difficult that almost no one can do it."

As you've probably noticed, this is one of those moments when all of your friends and neighbors are buying stock. The market is booming, and investors are piling into equity mutual funds.

To any follower of Fred Schwed -- and I'm one -- that's a sure sign to sell and put your money in the bank. Your objective, after all, is to buy stock when the market is hitting new lows (hence ready to expand) rather than when it is hitting new highs (hence riding for a fall).

It's tough to sell into a rally as explosive as this one. The market letters are all jubilant, looking ahead to 2,000 on the Dow Jones industrial average. Most economists forecast ongoing growth in business and profits.

So Schwed's advice to sell may sound like the worst you have read in any year. But I can give you a couple of good reasons for it.

First, let's assume that the economists are right and that growth and profits will pick up. That means more business-loan demand and upward pressure on interest rates.

One of the fires under this soaring stock market has been falling interest rates -- because as rates declined, stocks looked relatively more attractive. The reverse will happen if interest rates edge up again. Money will flow back into bank accounts and money funds, and stocks will fall.

The business recovery is entering its fourth year, which means by historical standards that it should be close to petering out. "The stock market always tops out well in advance of any recession," says Irwin Kellner, chief economist at Manufacturers Hanover Trust in New York.

"The only times stocks have continued to rise during the fourth year of an economy recovery has been in wartime -- the Korean War and the Vietnam War," he points out. That would argue that today's market is in its final fling, rather than in the first leg of another long rise.

Alternatively, let's assume that most economists are wrong and the economy will fall into recession early in 1986. In that case, interest rates would continue to decline, which ought to make stocks more attractive.

But corporate earnings and dividends also would decline -- and that would send investors running for cover. So whether you are a bull or a bear on the economy, there is reason to be enormously cautious about stocks.

What if the mutual funds you've been buying invest in bonds or Ginnie Maes instead of stocks? If the economy collapses and interest rates continue to fall, your bond funds will prove to be a splendid buy. You'll get high interest rates, while the market value of your fund shares will go up.

But you're in a weaker position if the economic consensus is right and the economy improves. Rising interest rates -- which are consonant with the end of a business-recovery cycle -- will send the value of bond-fund shares into the cellar.

So just as it may be the time to sell stocks, you might also think about selling your bond-fund shares. A professional wouldn't sell everything, but he would reduce the level of his stock and bond investments, just in case.

What would you buy, if you expected renewed vigor in the business recovery? Money-market mutual funds and bank accounts, whose interest rates would rise along with market rates, and gold. Improved business and rising interest rates run hand in hand with a pickup in the inflation rate, which is always good for precious metals, Kellner says.

Back for a moment to Fred Schwed. When you sell stock and put your money in the bank, he said, the market, at first, will keep on going up -- thumbing its nose at the cowards who got out. But no one ever picks the perfect market top. It's better to sell too soon than to sell too late.