Hi jonirrenicus .
I think you can using an array to check zigzag high and very low value.Then compare it to check if up tendency or down tendency.

...