Financial advisers have long urged investors to avoid shifting in and out of the markets. But a few top-performing funds do exactly that.

One of the winning funds was launched in 2003 when veteran portfolio manager Ralph Wanger made what seemed like a strange announcement. Stocks would churn up and down for the next decade, making little headway, he says.

To serve investors in difficult times, Wanger introduced a fund with a peculiar name,

Columbia Thermostat

(CTFAX) - Get Report

. The new fund would start by having half its assets in stocks and half in bonds. Thermostat would automatically increase its allocation to stocks when they fell and became cheaper. When the

S&P 500

rose, the fund would shift away from stocks and into bonds. By following this mechanical approach, Columbia Thermostat could make profits in markets that bounced up and down.

"You should not be completely invested in equities all the time," Wanger said.

Wanger's announcement was particularly noteworthy because he ranked as one of the top-returning managers of all time. For three decades, his Acorn fund outdid the S&P 500 by 3 percentage points annually.

Wanger, who is now retired, achieved his record by buying and holding a broad basket of stocks. With the introduction of the Thermostat fund, he signaled a change in his buy-and-hold outlook. Thermostat was going against the principles of many financial advisers who stress that investors should hold stocks consistently -- and not try to forecast when markets will rise and fall.

Since its launch, Thermostat has produced winning results. During the five years ending in June 2008, the fund returned 7.47% annually, outdoing 93% of its competitors in Morningstar's conservative allocation category.

Should you abandon buy-and-hold investing?

Not necessarily. Plenty of studies have shown that efforts to time the markets usually fail. Mark Hulbert, editor of Hulbert Financial Digest, found that 80% of market timers missed the mark. Still, there are a handful of mutual funds that have outdone their competitors by shifting between stocks and fixed income. These funds seem well-suited for the current bear market.

Among the top choices is

Vanguard Asset Allocation


, which has returned 4.49% annually for the past decade, compared to 2.88% for the S&P 500. Portfolio manager Tom Loeb makes dramatic calls, shifting allocations suddenly. Seeking to own undervalued assets, he often buys bonds when stocks are rising.

With the S&P 500 soaring in 1999, Loeb shifted to holding 60% in fixed income. He missed several months of the bull market, but stayed in the black in 2000, a year when the S&P 500 lost 9.1%. In 2006 and 2007, Loeb had more than 80% in stocks, a move that enabled the fund to outpace most competitors. Then, in March, Vanguard shifted to 100% in stocks. So far the fund appears off the mark. But history shows that Loeb often buys stocks when they are poised to outperform bonds.

"After the fund has shifted to 100% in stocks, the S&P 500 has risen an average of 22% during the next 12 months," says Joe Brennan, a principal at Vanguard Group.

Value Line Asset Allocation

(VLAAX) - Get Report

is another fund that made money in the downturn of 2000. The fund's stock allocation has gone as low as 40% and as high as 100%. Portfolio manager Steve Grant uses a model that takes into consideration the valuation of stocks and the direction of share prices. His ideal stocks would be cheap and heading higher.

During the past five years, Value Line has returned 10.04% annually and outdone 96% of its competitors in the moderate allocation category.

Currently, Value Line has 75% of its assets in stocks. "We are positive on stocks, but not as super bullish as we were a few years ago," says portfolio manager Steve Grant.

Some funds regularly sell stocks and shift to cash. The managers say that they are not making market forecasts. Rather the funds hold cash because there are not enough bargain stocks available. Such funds may not be true market timers, but several managers in the group have long achieved top records by holding big cash stakes in downturns.

The cash position in

FPA Crescent

(FPACX) - Get Report

has varied from 20% to 55% of the fund's assets. A big cash stake helped the fund return 3.59% in 2000. During the first six months of 2008, FPA returned 2.97%, a smart showing in a period when the S&P 500 lost 11.96%. The fund returned 9.58% annually during the past decade and outdid 97% of competitors in the moderate allocation category.

Portfolio manager Steven Romick follows an unorthodox style, buying whatever assets seem most undervalued. Besides cash, he often holds a mix of stocks, convertibles, and high-yield bonds. Romick's aim is outdo the stock market while taking less risk. Most often he succeeds. Gloomy about the market outlook, Romick has been holding 35% of assets in cash.

Big cash positions have helped

Mutual Qualified

(TEQIX) - Get Report

avoid losses in downturns and return 8.23% annually for the past 10 years. The fund typically holds between 5% and 20% of assets in cash. Lately the figure has been around the high end of the range because the fund managers have been hard-pressed to find compelling bargains.

"Share prices have declined, but earnings prospects have also come down," says portfolio manager Shawn Tumulty.

A deep-value investor, Mutual Qualified seeks stocks that sell for only 60% of their fair value. Besides stocks and cash, Mutual Qualified also holds distressed debt, bonds of shaky companies.

During the bull market of recent years, the fund had trouble finding tempting distressed bonds. But with the markets now facing difficult prospects, the Mutual Qualified managers are confident that there will be plenty of opportunities for investors seeking attractive fixed-income investments.

Stan Luxenberg is a freelance writer who specializes in mutual funds and investing. He was formerly executive editor of Individual Investor magazine.