Grazing incidence technique can be used to study samples with important stress gradients. The stress can be measured at very small depths, of the order of a few μm. The penetration depth of radiation is almost constant in a wide 2θ range for a given incidence angle α. It can be changed by an appropriate selection of α angle. This enables the investigation of stress variation with depth below the sample surface. There are, however, some factors which have to be corrected in this technique. The most important one is the X-ray wave refraction: it changes the wave length and direction of the beam inside a sample. These two effects cause some shift of a peak position and they have to be taken into account. For small incidence angles (α≤100) the corrections are significant and can modify the measured stress even of 70 MPa. The refraction correction decreases with increasing of the incidence angle. The corrections were tested on ferrite powder and on the ground AISI316L steel samples.