My horse gets stiff a lot too. I feed him a senior feed (it doesn't matter if you're horse isn't a senior, it'll still help) and powder glucosamine to help his joints. When I go to ride him, I warm him up for about 20 minutes. This means WALKING only. I usually do this leading him, not while riding. Then I stretch his legs, you just pick up his front leg (while facing his chest) and pull his leg as far out as he'll let you comfortably. Then slowly move it up higher until you can feel it can't easily move up anymore (don't force it) and then move his leg back as if you were going to pick it and try to make his hoof touch his belly. Same thing with the other front leg.
Then for his back legs get him to stand squared (so that none of his legs are really far back or forward like resting or anything) and take his back leg and pull it forward until it feels like you can't move it anymore without him trying to step forward, and then place his foot on the ground. So now his one back leg will be kind of underneath him. I usually give the horse a little massage, starting at the top of his hindquarters and just really pushing on his muscles all the way down to his hock, then work your fingers down to his fetlock. Repeat with the other back leg.
Hope this helped! Sorry if I explained it terribly.