The leaders of four major U.S. allies in Europe and the Mideast have agreed to meet with independent presidential candidate John B. Anderson at the same time the Republican Party is holding its national convention in Detroit.

Anderson's National Unity campaign released the details of the 12-day trip yesterday, a day in which the Republican congressman formally announced for the third time that he is a candidate for president.

Anderson plans to leave Sunday for Israel and travel to Egypt, Germany, France and Britain before returning to the United States on July 18, at the conclusion of the Republican convention.

Of the leaders of the five nations he will be visiting, only French President Valery Giscard d'Estaing has yet to agree to meet with Anderson. A scheduled meeting with Israeli Prime Minister Menachem Begin is in doubt because of the heart attack Begin suffered Monday.

Anderson told a news conference crowded with hundreds of supporters that he knew of no attempt by the Carter administration, which has waged a tough anti-Anderson campaign, to discourage allied leaders from meeting with him.

"I would be shocked beyond measure if any efforts of that kind would be undertaken," he said indignantly.

During his meeting with foreign leaders, Anderson said, "I want their appraisal, their perceptions of the present state of U.S. relations with those countries. I don't propose to sit down and lecture them on what their role with the United States should be.It will be an attempt to get to know these people on a personal basis."

Anderson's news conference in the Caucus Room of the Cannon House Office Building was his first meeting with the Washington press corps since he first announced his independent candidacy on April 24. Since then, he has concentrated on getting on the ballots of as many states as possible and building up the rudiments of a campaign organization.

Yesterday he said the support he has received "has far exceeded my expectations," and he hopes to be on the ballots of all 50 states and the District of Columbia Nov. 4.

"I now believe that an independent can win," he said.

But data his campaign staff distributed indicated Anderson still faces major obstacles. Although he has collected 305,526 signatures to gain ballot access in 14 states and filed court challenges to overturn early filing data requirements in four states, he is still formally on the ballot in only Massachusetts, Utah, Kansas, North Carolina and New Jersey.

Over the last 10 weeks, he has not advanced much in national polls, which put his support at from 18 to 23 percent of the American electorate.

Potentially more damaging Anderson's money situation. He was raised $2.6 million since he became an independent, or roughly $37,500 a day. If he continues at this rate, his campaign will have raised only $7.1 million by election day, or less than half the $15 million he has budgeted for the race.

Anderson, who was virtually unknown in much of the nation a year ago, has laid out a strategy that concentrates heavily on the industrial Northeast, California, the Pacific Northwest, Florida, and a handful of Midwestern states.

According to documents distributed yesterday, Anderson "has a realistic chance to win in 31 or more states, accounting for 408 electoral votes." To win, 270 electoral votes are needed.

In his news conference, Anderson said he will begin setting out specific proposals on a number of issues in coming weeks.

"I cannot ask Americans to vote for me because they dislike the other candidates," he said. "I must persuade them that I am competent to govern this nation, that I understand its problems and that my program of action will be both effective and fair."

"What I have to offer is common sense in economics, common decency in human rights and plain dealing in government."

Anderson is scheduled to be in Israel, his longest stop, until the morning of July 11; in Cairo, where he is to meet with President Anwar Sadat, July 11 and 12; in Berlin and Bonn, where he is to meet with West German Chancellor Helmut Schmidt, July 13 and 14; in Paris July 15 and 16, and in London, where he is to meet with Prime Minister Margaret Thatcher, July 16 and 17.

Last night, Anderson addressed the 71st annual convention of the NAACP in Miami. His appearance there was viewed as a major attempt to draw black votes from President Carter.

"I don't think that the blacks of this country have mortgaged their votes for all time to the Democratic Party," he told reporters before his speech.

Anderson said that if blacks really want to send the Democrats and Republicans a message, "they would go for an independent candidate like myself."

He criticized Carter for moving too slowly on a $2 billion jobs program and for not providing more funds for Miami's riot-torn Liberty City. Carter has proposed a $71 million aid package.

But these attacks did not appear to stir Anderson's audience.

However, he was warmly applauded when he advocated tax incentives for businesses that move to the inner city, and federal standards on the use of deadly force by police.

Speaking in a strong, forceful voice, Anderson was candid and direct about his previous distance from civil rights concerns. He acknowledged at the beginning of his speech that he grew up in "white America," had few black friends and could not pretend to know how it feels to be black and poor.

His first break from middle-of-the-road Republicanism on civil rights came in 1968, he said, when he voted for fair-housing legislation.

He said that earlier in his career he might have voted against such a measure, "not out of cruelty, but from ignorance, not out of any conscious impulse to oppress, but from unconscious habits of thought, never truly examined. But I am also grateful for the experience. It made me grow."