If I understand correctly what you want, it's quite easy to do :
Assumed you have a large historical data from every stock of your universe, you compute, as of today's close :
a/ the number of days it "dominates" backwards (i.e. the number of past consecutive days where the price was below...