Yes
It’s a spell of 4th level or lower, and includes a trigger predefined by the caster, so it meets the criteria. Indeed the optimum choice is to cast it at 4th level.
Spell Storing: A spellcaster who wears the Shield guardian's Amulet can cause the Guardian to store one spell of 4th level or lower. To do so, the wearer must cast the spell on the Guardian. The spell has no effect but is stored within the Guardian. When commanded to do so by the wearer or when a situation arises that was predefined by the spellcaster, the Guardian casts the stored spell with any parameters set by the original caster, requiring no Components. (MM, Shield Guardian)
Setting the predefined trigger
You cast that spell—called the contingent spell—as part of casting contingency, expending Spell Slots for both, but the contingent spell doesn’t come into effect. Instead, it takes effect when a certain circumstance occurs. You describe that circumstance when you cast the two Spells. (Contingency, PHB).