Animals, including humans, form oppositely valenced memories for stimuli that predict the occurrence versus the termination of a reward: appetitive ‘reward’ memory for stimuli associated with the occurrence of a reward and aversive ‘frustration’ memory for stimuli that are associated with its termination. We characterized these memories in larval Drosophila melanogaster using a combination of Pavlovian conditioning, optogenetic activation of the dopaminergic central-brain DAN-i1864 neuron, and high-resolution video-tracking. This reveals their dependency on the number of training trials and the duration of DAN-i1864 activation, their temporal stability, and the parameters of locomotion that are modulated during memory expression. Together with previous results on ‘punishment’ versus ‘relief’ learning by DAN-f1 neuron activation, this reveals a 2×2 matrix of timing-dependent memory valence for the occurrence/termination of reward/punishment. These findings should aid the understanding and modelling of how brains decipher the predictive, causal structure of events around a target reinforcing occurrence.