We investigate the ruin probability when the surplus process is governed by a generalized perturbed risk model with a Markov-switching compensator. We suppose that the jump component of the perturbed risk model is specified by a completely random measure process with the compensator switching over time according to the states of an economy described by a continuous-time hidden Markov chain model. Accordingly, we assume that the force of interest, the rate of premium and the diffusion volatility rate switch over time according to the states of the economy. A simulation experiment will be conducted.