The first-principles calculation is performed to explore the mechanical properties and electronic structures of transition elements X (X = V, Mn, Fe, Ni) doped WCoB (tungsten cobalt boron), which has shown high oxidation resistance and melting point under high pressure. The energy analysis indicates that the high pressure leads to the lower lattice constants and less stable structures. The deviation of cohesive energy and formation enthalpy between doped and undoped structures indicates that W4Co3FeB4 and W4Co3NiB4 have similar stability. The high pressure contributes to the increasing of elastic, shear, and bulk moduli, which indicates the increase of covalence. The increase of Poisson's ratio, B/G ratio, and anisotropy index AU indicates the higher ductility and higher anisotropy under high pressure. Based on bulk modulus and shear modulus, the hardness of W4Co4B4, W4Co3FeB4, and W4Co3NiB4 increases under high pressure, which consists of the variation of electronic structures. The density of states (DOS) and partial DOS analysis indicate that the high pressure leads to lower density around Fermi level and higher hybridization. W4Co4B4, W4Co3FeB4, and W4Co3NiB4 show similar variation of mechanical properties, which is determined by the similar atom properties of Co, Fe, and Ni. Similarly, W4Co3VB4 and W4Co3MnB4 also imply similar variation of mechanical properties and electronic structures.