TL;DR: No such code, but most equestrian statues at Gettysburg happen to match it by chance.
From http://www.snopes.com/military/statue.asp:
The hoof code mostly holds true in terms of Gettysburg equestrian statues, but there is at least one exception. James Longstreet wasn't wounded in this battle yet his horse has one foot raised.
(illustration from Longstreet page)
The article has a pretty good list of statues that do and don't match the "tradition".
Short version of the article -
Plenty of statues do follow this rule, but plenty of statues don't, even in Washington which has plenty (only 10 out of 30 are "correct").
No sculptor seems to be aware of this rule.
The odds of "correct" horse posture is 1 in 3 (remember Washington DC count above?), so all the "confirmations" of the rule are just statistical flukes that our brain are trying to make a pattern out of.
A separate investigation also reveals a negative: http://www.straightdope.com/columns/read/1093/in-statues-does-the-number-of-feet-the-horse-has-off-the-ground-indicate-the-fate-of-the-rider
No sources confirming the rule in sculpting related textbooks
A historian for the U.S. Army Center of Military History also dismissed the story as a myth.
Of 18 surveyed statues of famous people: 8 are "correct", 8 are "wrong", 2 are "not enough info about the person's death".
Augustus Saint-Gaudens, one of the most famous sculptors of his day, had 1 equestrian statue match the "code" and another one that did not.
As far as Gettysburg - which seems to be the origin of the myth:
"Gettysburg: The Complete Pictorial of Battlefield Monuments by D. Scott Hartwig and Ann Marie Hartwig (1988)" has 478 monuments and memorials, of them only 6 freestanding horse riders. They all match deaths/survival at Gettysburg.
However, General John Sedgwick's horse has all four feet on the ground, despite the fact that he was later killed in battle!
(source: Civil War Wiki.net)