Some time ago we have derived from the QCD Lagrangian an equation of state (EOS) for the cold quark matter, which can be considered an improved version of the MIT bag model EOS. Compared to the latter, our equation of state reaches higher values of the pressure at comparable baryon densities. This feature is due to perturbative corrections and also to non-perturbative effects. Later we applied this EOS to the study of compact stars, discussing the absolute stability of quark matter and computing the mass-radius relation for self-bound (strange) stars. We found maximum masses of the sequences with more than two solar masses, in agreement with the recent experimental observations. In the present work we include the magnetic field in the equation of state and study how it changes the stability conditions and the mass-radius curves.