In financial markets such as Tehran Stock Exchange, P/E coefficient, which is one of the most well-known instruments for evaluating stock prices in financial markets, is considered necessary for shareholders, investors, analysts and corporate executives. P/E is used as an important indicator in investment decisions. In this research, harmony search metaheuristic algorithm is used to select optimal variables affecting P/E and then, modelling is done through multivariate regression based on panel data. For this purpose, a sample of 87 companies has been selected from listed companies in the Tehran Stock Exchange during a 10-year period (2006-2015). The results indicate the effect of the variables of stock returns, stock price to book value ratio, price to net selling ratio, return on assets, earnings per share, market value to book value, money volume, operating return margin, return on capital, and current assets, as top ten variables, on P/E ratio, which estimates a total of 86% of the P/E ratio changes.