The Mathematics of Technical Analysis