When things are going well: Don't compare yourself to others, compare yourself to your past self so you can see how far you've come.

When things are going badly: You're doing better than most people, most people can't do what you do, you're in better shape than... whoever.

You need to accept your regression as well as your progression. Comparing yourself to your past self can be effective whether you're on a peak or in a trough. If you compare yourself to others there will always be someone worse off or someone better who is buoyed by some invisible force. It's all excuses.

Years ago I worked with someone who was notorious for taking all the credit when things went well and emphasising the team effort when things were bad. It's exactly the same thing.