Define "long-term uptrend (not necessarily monotonic)" algorithmically. Maybe "in the last 30 candles, at least in 20 of them the EMA went up"?
Same with "short-term downtrend" for candles? - "In the last 6 candles, at least 5 were up, and the last one was up"?
You will find that once you define these things for yourself, writing the scan becomes a lot simpler.