Abstract The photoelectron boundary (PEB) at Mars is defined to be the boundary separating the photoelectron-dominated ionosphere from the external plasma environment. Extensive studies have been presented to analyze the PEB variation in the Martian dayside ionosphere. However, the PEB was identified manually in previous studies because of the difficulty in detecting the faint photoelectron features at high altitudes. In this study, we develop an algorithm to detect these faint features and identify the location of PEB from energetic electron measurements automatically. We apply the algorithm to the measurements by the Solar Wind Electron Analyzer instrument on board the Mars Atmosphere and Volatile Evolution mission and identify a total number of 15,681 PEB crossing events accumulated from 2015 January to 2019 October, of which 9169 PEB are on the dayside and 6912 are on the nightside. Our analysis indicates that the altitude of the identified PEB tends to increase with solar extreme ultraviolet radiation and crustal magnetic field strength, in agreement with previous findings. By contrast, the PEB altitude on the nightside tends to increase dramatically with solar zenith angle but is found to be weakly influenced by the crustal magnetic field strength.