Using a Monte Carlo method, we derive approximations to Green's functions for the Compton reflection of X-rays and gamma-rays by cold electrons. In Compton reflection, X-rays and gamma-rays emitted by a source impinge upon a slab (e.g., an accretion disc) and re-emerge with a spectrum altered by Compton scattering and bound-free absorption. The obtained Green's functions are dependent on the viewing angle of the reflecting slab, which extends the previous treatments of the problem, in which the reflected spectra were integrated over all viewing angles. The dependence on the viewing angle is especially important in hard X-rays and soft gamma-rays, in which regime the reflected spectrum strongly hardens with increasing viewing angle. This is an important effect for modelling gamma-ray spectra of active galactic nuclei and Galactic black hole candidates, where the presence of Compton reflection has been established before from X-ray data.