The output voltage-power curve exhibits multi-peak characteristics for the local shading of the PV array. The traditional particle swarm optimization algorithm will fall into the local optimal problem when the maximum power tracking is performed. In this paper, the weight index decreasing particle swarm optimization (PSO) algorithm is proposed. By changing the particle search method, the elite mutation is performed on the searched optimal particle before the end of each iteration, and the reverse direction space is searched; and the inertia weight adjustment parameter is added, and the inertia weight is exponentially increased with the number of iterations. Decrement, so that the ability of the algorithm to jump out of the local best advantage in the early stage and the later search is more accurate. The simulation results show that the algorithm can accurately track the maximum power point under the condition of shading or sudden change of light, which can effectively avoid the local best advantage, and the convergence speed is fast, which can achieve maximum power tracking under complex conditions.