There are several ways to create rules that detect uptrends and downtrends.
You can for example use the moving average:
uptrend = close > sma(30);
downtrend = close < sma(30);
Or the Adx indicator:
uptrend = adx(10) > 25 and perf(close, 10) > 0;
downtrend = adx(10) > 25 and perf(close, 10) < 0;
ADX Value - Trend Strength
0-25 - Absent or Weak Trend
25-50 - Strong Trend
50-75 - Very Strong Trend
75-100 - Extremely Strong Trend