Try this: search backwards from end sample, looking for change in ADC value going below -2sigma (or -1sigma if -2sigma not found, or min value if -1sigma not found), then search forwards until change in ADC value goes +ve.