I couldn't find any code to do this, so I wrote a crude way of algorithmically finding "turning" points in time series data.
Summary of the code:
- Smooth the time series using curve fitting
- Find first derivative using forward difference method
- Find bottoms and tops by iterating and looking for crosses in the 1st derivative from - to + and + to -.
This could be extended to automatically detect support and resistance levels in a trading strategy.
Check out the attached notebook!