Generally, wind speed alters continuously during a day and lead to fluctuating output power of a wind farm. Connecting such a wind farm to the transmission line of grid causes a malfunction in the performance of the backup zone of the distance relays due to the random nature of generation and the number of connected wind turbines (wind farm penetration). In this study, a new adaptive setting groups-based method has been proposed to set the second zone of the distance relay in the grid with a wind farm equipped with a doubly fed induction generator (DFIG). In this method, we also taken into account the uncertainty of wind fluctuations and the availability of wind turbines. A Markov model is developed to implement these features. To determine the impedance setting of each of the set groups of the second zone in the distance relays of the remote bus, the obtained impedances are clustered in four clusters by using the combination of K-means and particle swarm optimization (PSO) algorithms. Finally, details of the analysis results of this issue have been compared with other methods available in the literature. The validity and accuracy of the proposed approach also have been assayed and confirmed.