In a photovoltaic system, function of islanding detection is an essential part of inverter. The system should not only fast detect islanding, but also minimize the impact on power grid. The relationship between the output current THD and the time of detection is discussed. This problem is analyzed in this paper and a new algorithm is proposed. Based on the improved AFDPF algorithm, this method effectively regulate the relationships between the truncated coefficient (cf), current harmonic distortion and island detection time and on the basis of the results of simulation, the results of improved AFDPF algorithm are analyzed. Finally, the advantages and disadvantages are summarized.