The strong magnetoelastic interaction in ternary X2YZ Heusler alloys is reponsible for the appearance of magnetostructural phase transitions and related functional properties such as the magnetocaloric and magnetic shape-memory effects. Here, X and Y are transition metal elements and Z is usually an element from the III–V group. In order to discuss possibilities to optimize the multifunctional effects, we use density functional theory calculations from which the martensitic driving forces of the magnetic materials can be derived. We find that the electronic contribution arising from the band Jahn–Teller effect is one of the major driving forces. The ab initio calculations also give a hint of how to design new intermetallics with higher martensitic transformation temperatures compared to the prototype alloy system Ni–Mn–Ga. As an example, we discuss quarternary PtxNi2−xMnGa alloys which have properties very similar to Ni–Mn–Ga but exhibit a higher maximal eigenstrain of 14%.