I put back the correct formula for trend detection.
Also, params are now read from the command line.