How can you check in Minecraft whether an entity goes up or down?

Ma
1

Hello can someone please help me with the question, I need this detection urgently because I'm building a leisure park only with Commands and Redstone.

po

Whatever you mean ~ 5 is 5 up or right. ~ -5 is 5 down or left