Although stock prices are in the middle of a long-term climb, the next few months could be hard on the market, according to Robert Farrell, the chief market analyst for Merrill Lynch, Pierce, Fenner & Smith.

Farrell predicted that stock prices, as measured by the Dow Jones industrial average, could decline by as much as 15 percent before resuming their long-run upward climb.

Albert Cox, chief economist for Merrill Lynch, forecast that the economy will slide back into recession during the first half of next year and that for the year as a whole the economy will grow by no more than 1 1/2 percent.

Cox, speaking to the same breakfast seminar for reporters that Farrell addressed, said that the rate of inflation should come down to between 8 percent and 9 percent in 1981. The economy is expected to have grown about 0.7 percent by the time 1980 ends, and inflation will be about 13 percent for the year as a whole.

The 1981 downturn will be lead by the same stocks that have pushed the stock market up steadily since mid-April, Farrell said -- mainly oil and energy stocks and technology issues.

"It will not be a great year," he said. "It will be a disappointment. But any decline is an opportunity for investors," who can earn a better return purchasing lower-priced stocks that have yet to begin an upward climb.

Next year investors should be cautious and look to stocks that have not been in favor during the current rally, he advised, adding that bigger, more mature companies will do well after the 1981 "correction" is over, including appliance manufacturers, drug companies, merchandisers and "even some utilities."

"On technical grounds, I would be cautious about the recent enthusiasm for stocks," Farrell told reporters. "The instant-gratification crowd is surging into stocks today. Those who make money go in when things are quiet." s

Farrell, one of the most accurate forecasters of stock prices in recent years, said that new presidents "tend to be greeted" with stock market rallies that last one to three months -- "Then there is a reassessment."

"The record of markets in post-election years is not a good one," he said. In the last half century, stock prices have gained in only three post-election years. In two of those instances, stock prices fell during the previous year, Farrell said. In election year 1980, the Dow index has gained sharply.

Nevertheless, the long-term case for stocks "remains fairly persuasive," he continued:

"Both value and supply and demand make the case for stocks," Farrell said.