Please give the code for "uptrend" and " downtrend " listed in artificial intelligence/pattern recognition in Pi. Thank you

trading strategy

As per the above query 

Up trend

TREND(CLOSE, 30) = UP

Down trend

TREND(CLOSE, 30) = DOWN

When using this TREND function, will it give a UP only if the CLOSE is “perfectly” trending up? Or does it allow for a “few” lower closes, but an overall up trend? Any quantification and/or control over that?