Fixing a threshold to create contingency tables for Cochran–Mantel–Haenszel test

#1
I have two continuous variables, X, and Y, and create their contingency table by using the median of each variable as a threshold.

I repeat this process for different X and Y values to create a set of contingency tables, each with different X and Y thresholds.

Can I now compute Cochran–Mantel–Haenszel test on these tables?

That is:
- By using the actual data to determine the cells split in the tables, do I violate any CMH assumption?
- Do I have to use the same X-threshold and Y-threshold for all tables?

thanks