I think we've destroyed lots of the support structures that at other times would have helped. So yes, first of all - it's not necessarily just you, the environment is involved too.
I think there's a wise route out, and people do get there. I don't know what it is. Some things that might help in case you haven't tried:
1. Psycotherapy. Even if you don't have clinical depression, this can still be valuable. Look for a practice (better than a single person as they're vetted, can find the best person for you, and mentor each other) and words like "integrative therapy" and "transactional analysis". It can be expensive. I've a friend who goes for a few months every two years even if mentally well, as it helps. Like a very emotionally aware life coach.
2. Life changes. Things like meditation are so popular to almost be a cliche, but I think they can help. If you're more philosophical maybe things like https://meaningness.com/ will inspire more than more hippy materials. Getting just a bit healthier, sounder sleep, improved diet but do so in a simple way by following someone non-obsessive, non-fadish - I recommend podcast and books by https://drchatterjee.com/
Good luck! You're not alone.
All I can suggest is that you look at how you can help some people or causes you care about - I don't know what those would be... sick kids, kids in distress, animals, old people, culture, education, the environment, but something that matters to you. Perhaps this won't work, but at the worst I can't imagine it would be any less than neutral.
"I felt trapped, waiting for the descent, wondering how steep, prepared somewhat for its arrival because it had never not come. Now, though, here was a PhD telling me the altruistic acts Buy Nothing Bainbridge enabled me to perform spurred production of chemicals that actually helped heal my misfiring synapses."
Sometimes science and religion do converge around the same truth. Some form of meaningful (to the recipient) giving is one path that would restore the "lost direction and belonging" mentioned in the top parent.
[1] https://buynothingproject.org/2013/12/23/my-buy-nothing-expe...
People tell me to get out and I do, tried surfing for example, didn't really appeal to me. Tried dancing, same. Did lots of traveling but it's not so fun alone for a 50 yr old guy.
I mostly feel now it's partly about luck as well. Meeting the right people, having the right support groups is invaluable. Pretty much everyone I meet that I might work with though is just looking for cheap labor as "I have this idea, you're an engineer, how about you do all the work for free and I'll take all the money if we make any" or at least that's how it feels.
As for as whether or not 52 is old sure it's not as old as 70 or 90 but ... society in general labels me as old. Various forms require an age listed and 45+ or 50+ is the last group. HN tells me I'd have trouble being hired. Not yet my experience but certainly on my mind. Going to almost any bar, club, meetup, hackathon and I'm the oldest one there.
I don't feel I've lost my ambition. If I had then maybe I'd be content. Rather I just lost direction and belonging.