Doesn't it seem like Sherlock was very "out in the open" and "exposed" at the cemetery for someone who was supposed to be in hiding? It may be possible to conceal oneself in a cemetery, to a degree, but if he heard John's plea for "one more miracle" he had to be standing pretty near-by.
And he was also risking that somebody allied with Moriarty would notice...