I have a list of closing prices for a symbol in python. I want to get the peaks and valleys – no problem – but I want to detect a break of a peak / valley that eiher made the last high / low. Here an example image:
The peaks inside the last high and low are only relevant, if a peak made a new low, then I want to be notified of the peak gets broken (bar close above). (vice versa for uptrend)