For those who studied Bazi before you probably know the 5 Heavenly Stems (HS) combination. They are Jia 甲 + Ji 己 = Earth 土, Yi 乙+ Geng 庚 = Metal 金, Bing 丙+ Xin 辛= Water 水, Ding 丁+ Ren 壬 = Wood 木, Wu 戊 + Gui 癸 = Fire 火.
But do you know that these HS combination existed long before the invention of Bazi? Infact, it's appearance was mentioned from the 皇帝内经 (one of the oldest Chinese medical book), in Chapter 五运行大论篇。
During one of the questions and answers sessions, a medical doctor said 鬼臾区曰:土主甲己,金主乙庚,水主丙辛,木主丁壬,火主戊癸。And Qi Bo 岐伯 further explain how this combination came about "臣览太始天元册文,丹天之气,经于牛女戊分;黅天之气,经于心尾己分;苍天之气,经于危室柳鬼;素天之气,经于亢氐昂毕;玄天之气,经于张翼娄胃;所谓戊己分者,奎璧角轸,则天地之门户也。娄胃;所谓戊己分者,奎璧角轸,则天地之门户也。"
Translated meaning based on the text of 太始天元册 (an astronomy text), The Qi of 丹天 passed through 牛女 (28 constellations) <at the direction of 癸 in the 24 mountains ring and 戊分, the Qi of 黅天 passed through 心尾 <at the direction of 甲> and 己分, the Qi of 苍天 passed through 危室 <at direction of 壬> and 柳鬼 <at direction of 丁>, the Qi of 素天 passed through 亢氐 <at direction of乙> and 昂毕 <at direction of 庚>, the Qi of 玄天 passed through 张翼 <the direction of 丙> and 娄胃<the direction of 辛>. And the meaning of 戊己分 (intersection of 戊己 ), is actually at the 奎璧角轸 (28 constellations) where it is also known as the Heaven and Earth Door.
丹天 refers to reddish light, 黅天 refers to yellowish light, 苍天 refers to greenish light, 素天 refers to whitish light, 玄天 refers to blackish light.
皇帝内经 was commonly thought to be written in the Spring-Autumn Warring Period 春秋战国时代。Which means that the astronomy book 太始天元册 was much earlier. It was suggested that 太始天元册 was probably written around the West Zhou (B.C 1046 - 771) 西周。
The creation of Bazi by Founder Li Xu Zhong 李虚中 was in 隋唐 (Around B.C 581 - 907) and Xu Zi Ping 徐子平 was in Song Dynasty (around the year of 960 - 1127).
And so the Heavenly Stems combination was created much earlier and was used in the application of Ba Zi. Infact, the reason why HS combination was mentioned was due to its application to 五运六气。五运 is related to the Heavenly Stems and 六气 is related to the Earthly Branches.
I will not go further into 五运六气 as it is another big topic in 皇帝内经. Nonetheless one interesting finding was often we hear the Chinese says 运气 (luck) actually refers to the influences of HS and EB on a person. Where 皇帝内经 refers to external environmental influences on the health of a person.