Objective: Surface-guided radiation therapy (SGRT, AlignRT) was used to analyze motion during stereotactic body radiotherapy (SBRT) in lung cancer patients and to explore the margin of the planning target volume (PTV).Methods: The residual errors of the AlignRT were evaluated based on grayscale cone-beam computed tomography registration results before each treatment. AlignRT log file was used to analyze the correlation between the frequency and longest duration of errors larger than 2 mm and lasting longer than 2 s and maximum error with age and treatment duration. The displacement value at the end of treatment, the average displacement value, and the 95% probability density displacement interval were defined as intrafraction errors, and PTV1, PTV2, PTV3 were calculated by Van Herk formula or Z score analysis. Organ dosimetric differences were compared after the experience-based margin was replaced with PTV3.Results: The interfraction residual errors were Vrt(0), 0.06 +/- 0.18 cm; Lng(0), -0.03 +/- 0.19 cm; Lat(0), 0.02 +/- 0.15 cm; Pitch(0), 0.23 +/- 0.7 degrees; Roll(0), 0.1 +/- 0.69 degrees; Rtn(0), -0.02 +/- 0.79 degrees. The frequency, longest duration and maximum error in vertical direction were correlated with treatment duration (r = 0.404, 0.353, 0.283, p < 0.05, respectively). In the longitudinal direction, the frequency was correlated with age and treatment duration (r = 0.376, 0.283, p < 0.05, respectively), maximum error was correlated with age (r = 0.4, P < 0.05). Vertical, longitudinal, lateral margins of PTV1, PTV2, PTV3 were 2 mm, 4 mm, 2 mm; 2 mm, 2 mm, 2 mm, 3 mm, 5 mm, 3 mm, respectively. After replacing the original PTV, mean lung dose (MLD), 2-cm(3) chest wall dose (CD), lung V-20 decreased by 0.2 Gy, 2.1 Gy, 0.5%, respectively (p < 0.05).Conclusion: AlignRT can be used for interfraction setup and monitoring intrafraction motion. It is more reasonable to use upper and lower limits of the 95% probability density interval as an intrafraction error.