Catalyzes the SAM-dependent triple methylation of the alpha-amino group of histidine to form hercynine, a step in the biosynthesis pathway of ergothioneine. L-histidine + 3 S-adenosyl-L-methionine = 3 H(+) + hercynine + 3 S-adenosyl-L-homocysteine Amino-acid biosynthesis; ergothioneine biosynthesis. Monomer. Belongs to the methyltransferase superfamily. EgtD family.