Trend regime
Whether trend strength (ADX) is above the threshold: 1 means trending, 0 means ranging.
TrendRegime takes one input, an ADX line, and outputs 1 when ADX is above the threshold (25 by default) and 0 otherwise. ADX is the standard 0-to-100 measure of how strong a trend is, but it does not say which way price is heading, so 1 means trending up or down. The class docstring mentions directional indicators, but the code never reads them.
How to read it
- The line sits in its own pane below the price and only takes the values 0 and 1, so it reads as a step chart.
- 1 means ADX is above the threshold, so the market is trending. 0 means it is ranging or choppy.
- On SPY one-minute bars for September 2026 at the default 25, it read 0 on half or more of the bars, so trend readings are the minority.
- A jump from 0 to 1 is the moment ADX rises through the threshold. A step back to 0 means trend strength has faded below it.
What it outputs
- Trend regime
- 1 when ADX is above the threshold (trending), 0 when it is not (ranging). Blank until ADX has a value.
Settings
- threshold
- The ADX level a trend must exceed to read 1. Raising it, say to 40, admits only strong trends, so 1 shows less and the line sits at 0 through ordinary moves. Lowering it, say to 15, counts weak trends too, so 1 shows more and flips more often.
Pitfalls
- The docstring says it uses directional indicators, but the code reads only ADX. A 1 means a strong trend up or down, and does not show the direction.
- ADX is smoothed over its window, so 1 arrives after a move is already under way. It confirms a trend rather than calling its start.
- The output has no hysteresis or smoothing. Near the threshold the line flips between 0 and 1 on one-minute noise.