Algorithmic Rules of Trendlines