I think you have Excel 2021.
If so, try this:
=LET(downtrend,FILTER(C15:D374,D15:D374<=179),uptrend,FILTER(C15:D374,D15:D374>179),
direction,IF(H6="Uptrend",uptrend,downtrend),type,IF(H6="Uptrend",1,-1),
XLOOKUP(H7,INDEX(direction,,1),INDEX(direction,,2),"",1,type))