Indicators · condition block
ADX and DMI (trend strength)
The ADX block uses Wilder's Directional Movement system. ADX measures how strong a trend is, whatever its direction; the +DI and −DI lines show which side is in control.
How the engine evaluates it
+DM is the rise in the high when it beats the fall in the low; −DM is the fall in the low when it beats the rise in the high. True range, +DM and −DM are smoothed with Wilder's running sum over N candles.
+DI = 100 × smoothed +DM / smoothed TR and −DI likewise. DX = 100 × |+DI − −DI| / (+DI + −DI). ADX is the average of the first N DX values, then Wilder-smoothed.
adx > and adx < compare ADX with the level (states). dmi crosses bullish fires when +DI crosses above −DI; crosses bearish when it crosses below. ADX needs about twice its length to exist. Before your start date the engine loads extra history (at least 50 candles, up to 5,000, scaled to the longest indicator in the bot) so the indicator has settled by the first candle of the run.
+DI = 100 × S(+DM) / S(TR), −DI = 100 × S(−DM) / S(TR)
DX = 100 × |+DI − −DI| / (+DI + −DI)
ADX = Wilder average of DX over N
Botscript syntax
In the Lab you pick this block from the Indicators group and fill in its fields. In the code view the same condition is written like this:
adx(14) > 25
adx(14) < 20
dmi(14) crosses bullish
dmi(14) crosses bearish
Settings
| Setting | Values | Default | Notes |
|---|---|---|---|
| Condition | adx >, adx <, dmi crosses bullish, dmi crosses bearish | adx > 25 | — |
| Level | 0 – 100 | 25 | Above 25 is usually read as trending, below 20 as ranging. |
| Length | 2 – 5,000 | 14 | — |
| Timeframe | the run's candles, or 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1w | the run's candles | Optional. At least the run's candle size and a whole multiple of it. |
On a higher timeframe
Add a timeframe at the end to read ADX / DMI from bigger candles than the run uses, for example adx(14) > 25 on 4h. The engine builds those candles from the run's own candles (UTC, weeks start on Monday) and evaluates the block only on candles that have closed, so there is no look-ahead. Lengths and lookbacks count the bigger candles.
On a higher timeframe dmi(…) crosses bullish and dmi(…) crosses bearish are events: they fire once, on the run candle that closes the bigger candle where they happened. adx(…) > and adx(…) < are states that hold until the next bigger candle closes.
The timeframe must be at least the run's candle size and a whole multiple of it; otherwise the run stops with an error and is not charged. Multi-timeframe conditions covers the details, including warm-up.
How traders use it
- Regime filter: trend systems with
adx(14) > 25, mean-reversion systems withadx(14) < 20. - Direction signal:
dmi(14) crosses bullishas an entry,dmi(14) crosses bearishas an exit.
Example bot
bot "Strong Trends Only"
when dmi(14) crosses bullish and adx(14) > 25
then buy 100%
when dmi(14) crosses bearish
then sell 100%
- Buys when +DI crosses above −DI while ADX says the trend is strong.
- Sells on the opposite DI cross.
Pitfalls
- ADX rises in strong downtrends too. It measures strength, not direction.
- ADX is slow: by the time it is high, part of the move is over.
ADX / DMI: frequently asked questions
Does a high ADX mean price will rise?
No. ADX is direction-free. Use the DI lines or another trend block for direction.
Why is ADX missing for the first candles?
ADX averages DX, which itself needs N candles, so it takes about 2 × N candles to appear. Warm-up history covers this before your start date.
What levels are standard?
Above 25 is commonly treated as a trend and below 20 as no trend.
Is this Wilder's original method?
Yes: Wilder's running-sum smoothing for TR, +DM and −DM and Wilder averaging of DX.
Related blocks
Simulated results are hypothetical. They include only the fee and slippage you set on the bot, not every real-world cost or market condition, and past performance does not guarantee future results. Nothing here is financial advice.