All are correct, but I'd use #2 rather than #3.
The progressive tense in #2 gives the sense of time passing until "I" arrived. In #3, it's not clear if he "had waited" (and then left) or if he "had waited" and was still waiting.
1. When I arrived at the station, the train had alrready left.
2. When I arrived at the station, he had been waiting for me for half an hour.
3. When I arrived at the station, he had waited for me for half an hour.
(Are they all grammatical? Which expressions should I use, #2 or #3? Thank you for your help.)
2 answers
1 and 2 are acceptable; 3 is ambiguous.