It has been recently demonstrated that yttrium oxyhydride (YHO) films can exhibit reversible photochromic properties when exposed to illumination at ambient conditions. This switchable optical property enables their utilization in many technological applications, such as smart windows, sensors, goggles, and medical devices. However, how the composition of the films affects their optical properties is not fully clear and therefore demands an investigation. In this paper, the composition of YHO films manufactured by reactive magnetron sputtering under different conditions is deduced in a ternary diagram from time-of-flight elastic recoil detection analysis. The results suggest that stable compounds are formed with a specific chemical formula-YH2-delta O delta. In addition, optical and electrical properties of the films are investigated, and a correlation with their compositions is established. The corresponding photochromic response is found in a specific oxygen concentration range (0.45 < delta < 1.5) with maximum and minimum of magnitude on the lower and higher border, respectively.