I realize this 8-year-old plus script could do with some tidying after surviving being updated through the progressive versions of Pinescript and after various tweaks and fixes over that time. Although I have felt no great need to do the tidying and add one or two new features (vol on the current wave), I decided to heed the warnings generated when V5 is compiled regarding the misuse of integers that are implied as boolean parameters within conditional statements.