I'm new to pandas and trying to compare peak/trough values in time series price data to determine whether they are higher or lower than the previous peaks/troughs. I'd like to find three consecutively higher peaks and three consecutively higher troughs, and vise versa. If this is true, I'd perform some function. 

I've used the code in the Research file to create a dataframe with additional columns that shows whether the value of the close is the weakly peak/trough. 

cR7H1.png

I've used the agrelextrema function from scipi to do this. Is it possible, in the case of higher highs for example, to locate the weekly_ maxs which return True, then compare the close value of these rows to the last two preceeding values that were True? 

Regards,

Nick

Author