That I thought, Pythonized:
upw = dtr==false and dtr[-1] and utr dnw = utr==false and dtr[-1] and dtrMeaning upw is true if current dtr is false and utr is true and the previous dtr is false. This would mark an upward trend change.
The same
upw = (not dtr) & dtr[-1] & utr dnw = (not dtr) & dtr[-1] & utrIn Metastock:
Assignation :=
Comparison =