Dynamic optimal trend