This paper deals with the optimization of maximum power point tracking when a photovoltaic panel is modelled as two diodes. The adopted control is implemented using a sliding mode control (SMC) and the optimization is implemented using an improved Pattern Search Method. Thus, the problem of maximum power point tracking is reduced to an optimization problem whose solution is implemented by Pattern Search Techniques, inheriting their convergence properties. Simulation examples show the effectiveness of the proposed technique in practice, being able to deal with different radiations. In addition, improved pattern search method (IPSM) is compared with other techniques such as perturb & observe and Particle Swarm optimization, after which IPSM presents lower energy losses in comparison with the other two algorithms, with the advantage of ensuring the location of the optimal power point in all cases.