Counting sprints by velocity trend

Greetings,
How could I create a custom measure that, given a set of X sprints, gives me back the number of consecutive sprints with - i.e. - increasing velocity starting from the last?

Sprint 1: 30 sp
Sprint 2: 20 sp
Sprint 3: 40 sp
Sprint 4: 50 sp
Sprint 5: 60 sp

measure: 4

thanks