Self-praise when times go badly (7)
I believe the answer is:
egotism
'self-praise' is the definition.
Although both the answer and definition are singular nouns, I cannot see how they can define each other.
'times go badly' is the wordplay.
'badly' indicates anagramming the letters.
'times'+'go'='timesgo'
'timesgo' with letters rearranged gives 'EGOTISM'.
'when' acts as a link.
Can you help me to learn more?
(Other definitions for egotism that I've seen before include "Excessive conceit" , "Items go (anag.)" , "Self-obsession" , "Self-centredness" , "Extreme self-conceit" .)