By suitably adapting a recent approach [A. Laio and M. Parrinello, PNAS, 99, 12562 (2002)] we develop a powerful molecular dynamics method for the study of pressure-induced structural transformations. We use the edges of the simulation cell as collective variables. In the space of these variables we define a metadynamics that drives the system away from the local minimum towards a new crystal structure. In contrast to the Parrinello-Rahman method our approach shows no hysteresis and crystal structure transformations can occur at the equilibrium pressure. We illustrate the power of the method by studying the pressure-induced diamond to simple hexagonal phase transition in a model of silicon.