Mean reversion regime
Flags a bar as 1 when the close sits more than the threshold number of standard deviations from its recent average.
For each bar, the indicator takes the last period closes, including the current one, and computes their average and population standard deviation. It then measures how many standard deviations the current close sits from that average. The output is 1 when that distance is greater than the threshold, and 0 otherwise, including while the window is still filling or the closes are perfectly flat. Despite the name, it does not classify a market regime; it is a plain distance-from-average flag.
How to read it
- The line sits in its own pane below the price and is 0 on most bars.
- A 1 means the close is further from the average of the last period closes than the threshold allows, in either direction.
- A run of 1s means price stayed stretched for several bars; a lone 1 is one stretched close.
- It says how far price is from its average, not which way it will move next.
What it outputs
- Stretched flag
- 1 when the close is further from the recent average than the threshold, in standard deviations. Otherwise 0.
Settings
- period
- Closes, including the current bar, that form the average and spread. Shorter windows flag more on noise; longer ones flag only larger departures. At 5 or less, nothing flags at the default threshold.
- threshold
- Standard deviations the close must sit from the average to flag. Raising it flags fewer bars; at or above sqrt(period minus 1), about 4.36 for period 20, it never flags. Lowering it flags more. Below zero, every bar flags once the window is full and not flat.
Pitfalls
- The current close is part of its own average and spread, so one bar cannot push the distance above sqrt(period minus 1). At period 20 the ceiling is about 4.36, so a threshold of 5 or more never flags.
- The name says regime, but the indicator knows nothing about trend. In a strong trend price runs away from its window average and gets flagged as stretched, even though it may keep going. Pair it with a trend filter.
- At defaults on SPY one-minute bars for September 2026, the median bar is 0 and at least 5 percent are 1. Its correlation with the close is about 0.005, so it carries no price-level information.