Does Hornblower based on a true story?

No. Horatio Hornblower was a character created by author C. S. Forrester, who wrote a series of novels about him. There were some historical things in the novels which were true, as they were mainly set during the period of the Napoleonic Wars.