We present the discovery of four new long-period planets within the HARPS high-precision sample: object{HD137388}b ($Msin{i}$ = 0.22 $M_J$), object{HD204941}b ($Msin{i}$ = 0.27 $M_J$), object{HD7199}b ($Msin{i}$ = 0.29 $M_J$), object{HD7449}b ($Msin{i}$ = 1.04 $M_J$). A long-period companion, probably a second planet, is also found orbiting HD7449. Planets around HD137388, HD204941, and HD7199 have rather low eccentricities (less than 0.4) relative to the 0.82 eccentricity of HD7449b. {All these planets were discovered even though their hosting stars have clear signs of activity. Solar-like magnetic cycles, characterized by long-term activity variations, can be seen for HD137388, HD204941 and HD7199, whereas the measurements of HD7449 reveal a short-term activity variation, most probably induced by magnetic features on the stellar surface. We confirm that magnetic cycles induce a long-term radial velocity variation and propose a method to reduce considerably the associated noise.} The procedure consists of fitting the activity index and applying the same solution to the radial velocities because a linear correlation between the activity index and the radial velocity is found. Tested on HD137388, HD204941, and HD7199, this correction reduces considerably the stellar noise induced by magnetic cycles and allows us to derive precisely the orbital parameters of planetary companions.