A method is proposed to calculate the microscopic residual stresses in extruded cylindrical samples of non-ageing aluminium alloy 5083 (Al–Mg), arising from quenching in fresh water from 530°C. We start from the premise that the alloy is single-phase and non-isotropic on a microscopic scale; it consists of many grains that exhibit different mechanical response depending on their crystallographic orientation and neighboring grains. Microscopic residual stresses depend on the applied heat treatment, microstructure and mechanical strength of the individual grains. The stresses were calculated from neutron diffraction data. Genetic programming algorithms were used to calculate microscopic residual stresses, considering that each diffraction peak describes the stress distribution of a group of grains having a certain orientation, size and environment. The algorithm assigns a stress value to each grain according to the distribution of the diffraction peaks and the microstructural parameters of these grains.