Ronald Reagan has done the right thing twice in a row -- on taxes and Taiwan -- and is being punished for it.

He has buried John Foster Dulles' old fantasy about "unleashing" Taiwan on the People's Republic of China and been castigated by longtime allies who accuse him of dishonoring his campaign pledge of "no more betrayal of our friends."

He went on national television to plead for a tax increase that goes against the grain of Reaganomics and his own passionate convictions about an unfettered economy.

He is hearing the jarring sounds of cheers from the left wing and boos from the right wing of his own party. House Majority Whip Thomas S. Foley (D-Wash.) praised him on two networks Monday night during the time offered the "opposition" after the president's appearance.

The real opposition, led by his former acolyte, Rep. Jack Kemp (R-N.Y.), demanded and got equal time the following evening.

As luck would have it, the announcement of limitations on arms sales to Taiwan broke on the morning after the tax speech, sending new shock waves through the conservatives.

Ronald Reagan reads editorials in praise of his statesmanship in the papers of the Eastern Establishment. He reads diatribes about his "sellout" in Human Events and other publications that used to serve him as court circulars.

No wonder he is seeking reassurance and redress. Tuesday morning, he surprised a group of tourists toiling through the White House and asked them how they had liked his speech. Tuesday evening, he called Dan Rather, anchorman of the CBS Evening News, to complain about the network's coverage on Taiwan, specifically those passages that had the president flip-flopping.

Rather patiently explained to him that CBS was just reporting what members of his own party were saying about him.

The president is suffering because his own are estranged. The conservatives are his people. He is -- or was -- their god.

They can forgive him more easily for taxes than Taiwan. Taxes, one mourned, were at least explainable in economic terms. Taiwan was a pillar of the temple. Reagan has kowtowed to the red devils in Peking, betrayed the rich merchants of the little police state in Taiwan.

Jack Kemp's lieutenant in the rebellion, Rep. Newt Gingrich (R-Ga.), exulted that "Taiwan slowed the momentum of the tax speech."

Rep. Gerald B. Solomon (R-N.Y.), an ardent Reaganite since 1964, had agonized about going against the president on the proposed tax increases. The Taiwan announcement liberated him to a degree.

"When I heard that, it made me slightly less uncomfortable," Solomon says.

The tax speech has generated a mere ripple compared to the flood of popular support that followed the president's plea in July a year ago for support on tax cuts.

"We were braced for a tidal wave," Gingrich said happily in the House lobby. "But look at me, I'm not wet."

Reagan said a little disingenuously in his speech Monday that he had been "told by many that this bill is not politically popular." What he meant was that tax increases are opposed by about two-thirds of the American voting public. Ronald Reagan hates going against the majority, which in this case includes the Moral Majority.

The week has brought the first note of ambivalence into the gung-ho, right-on administration. This novel quality was faithfully reflected by budget director David A. Stockman, who, since his Trojan Horse indiscretion, has been more careful. He preemptively forgave Republican congressmen who desert their leader on the issue, saying morosely at a press breakfast:

"They don't feel they should be asked to walk the plank in an election year to pay for spending programs they do not support."

Ronald Reagan is not the only one discovering that virtue is its own reward. Democrats are swallowing hard, too. Some facing tight races against Republicans chosen and financed by the Republican National Committee balk at bailing out Reagan -- and then getting drubbed for it by well-heeled conservative rivals.

If they succumb to the plague of patriotism sweeping Capitol Hill and go for the fairest tax bill they may ever see -- not to mention their last pre-election chance to vote for extended unemployment benefits -- "we will get no credit," they complain to their whips, who in this case are working for Reagan.

How well Reagan understands that. He would rather not have credit for what he angrily denies is the "biggest tax increase in history."

But one group he really cares about liked his tax speech, the "compromise" he so reluctanctly embraced: Wall Street staged the biggest rally in its history on hearing it.

This bit of news, which could be retroactively rationalized as evidence that his theories were beginning to work, so assuaged him that he invited Tip O'Neill and Teddy Kennedy to the Rose Garden. If bipartisanship is inevitable, he seemed to say, why not relax and enjoy it?