Pretty big newbie looking for some guidance here...

I have a script already, but I am stuck at some basic calculations which are easy to do in other platforms like TradingView (but have their own limitations) which have me guessing at what to do next. I have the data frame of the security (date and close columns). Now I want to count the number of days the security closed below the previous day's close before it closed above it. 

For instance, Day 1: 192 Day 2: 191: day 3: 192 would be 2. 

How would I do this? 

Author