v2: In the last version, if there are less than two pivots within the search window, an incorrect trend line is produced. In this version, the default value for the search window has been increased from 50 to 100. In case that is insufficient, the user may now also custom define the search window.