That I thought, Pythonized:

upw = dtr==false and dtr[-1] and utr dnw = utr==false and dtr[-1] and dtr

Meaning 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] & utr

In Metastock:

Assignation :=
Comparison =