How to find the length of last trend in oscillator

 

Hi all, 

What's the best way to find the length of a trend in an oscillator?

For example when macd moves below zero for 4 bars the length of the trend will be 4.

Reason: