Trend states
Labels uptrend and downtrend stretches from price pinned to its 100-minute range; as shipped it never draws.
Trend states is a three-state machine that starts in Unknown and reads each close against the highest and lowest close of the last 100 minutes. It enters Downtrend when a close sits within 0.1% of that window's low, and Uptrend when it sits within 0.1% of the high, unless both hold at once. A state ends after a 0.5% reversal off its extreme, or after 10 bars in a row that stay 0.1% clear of that extreme, and the machine drops back to Unknown.
How to read it
- Each output is on for every candle spent in its state, so markers appear as runs, not single dots.
- Uptrend markers mean price is pressing the 100-minute high and has not fallen 0.5% from it.
- Downtrend markers mean price is pressing the 100-minute low and has not rallied 0.5% off it.
- Choppy stretches where price sits in the middle of its recent range stay unmarked.
What it outputs
- Uptrend
- Marks every candle while the state machine sits in Uptrend. Uptrend ends after a 0.5% fall from the 100-bar high, or 10 bars in a row at least 0.1% below it.
- Downtrend
- Marks every candle while the state machine sits in Downtrend. Downtrend ends after a 0.5% rally off the 100-bar low, or 10 bars in a row at least 0.1% above it.
When it fires
Fires on every candle while a state holds. A state starts on the first candle that closes within 0.1% of the 100-bar high (uptrend) or low (downtrend). As shipped the states never advance in the standard run, so no candle carries a marker on SPY one-minute bars.
Pitfalls
- As shipped it never fires: both outputs stayed off on every SPY one-minute candle in September 2026. The state machine never advances in the standard run, so treat the empty chart as a bug.
- The 100-bar window and the 0.1%, 0.5% and 10-bar bands are fixed in code; the indicator has no parameters, so nothing on the chart can loosen them.
- A state only ends after a 0.5% reversal or 10 bars in a row clear of the extreme, so a smaller pullback leaves the old marker on.