Range Compression Detector
This indicator answers one question before you take a trade: is the market currently trending, or is it going sideways? It does not generate entries. It classifies conditions, so you can tell whether the tools you are about to use are appropriate right now.
On the chart
Yellow marks a range, green an uptrend, red a downtrend. This is the 4-hour chart — the only timeframe whose thresholds were calibrated and tested.
Open the interactive chart on TradingView →
The measurement
Most traders identify a range visually, after it has already cost them several stops. There is an earlier and more mechanical signal: the distance between a fast and a slow moving average, expressed as a percentage of price.
In a trending market this number expands. Price pulls away from its own average and the two lines fan out. In a range it collapses toward zero — the averages sit on top of each other because price keeps returning to the same area.
Expressing it as a percentage rather than in points is what makes it portable. Fifty points of separation means something very different on an instrument priced at 4,000 than on one priced at 1.10.
Why it matters
Almost every pullback or trend-following system contains a version of this condition: fast average above slow means uptrend, below means downtrend. When the two averages are a fraction of a percent apart, ordinary noise flips that condition back and forth. The system declares an uptrend, fires a long, then declares a downtrend two bars later and fires a short. Both get stopped.
That is not a broken system. It is a system being asked a question it was not built to answer. This indicator is intended to tell you when you are asking it.
The three states
| State | Condition | Meaning |
|---|---|---|
| Range | separation ≤ compression threshold | averages converged — trend logic unreliable |
| Trend | separation ≥ trend threshold | direction from which average is on top |
| Transition | between the two | neither condition established |
The transition band exists deliberately: a single line would produce constant flipping at the boundary, which is the same problem the indicator is meant to diagnose. A state must also hold for a set number of consecutive bars before it is accepted — that adds lag, and removes almost all of the flicker.
Timeframes disagree, and that is the point
Running this on three timeframes of the same instrument at the same moment will often give three different answers. In testing on gold, the 15-minute chart read transition, the 4-hour read range, and the daily read trend — simultaneously, with the default thresholds.
None of those is wrong. A market can be trending on the daily while going nowhere on the 4-hour. The indicator reports the state of the timeframe you are looking at, which is the state that matters for the trade you are about to take on it.
Calibrating the thresholds
This is the part that requires work from you, and the defaults will not suit every chart. Add the indicator, open the Data Window, and watch the separation value through a period you already recognise as a clear trend, then through one you recognise as a clear range. The threshold belongs between those two observed bands.
| Timeframe | Compression | Trend | Status |
|---|---|---|---|
| 4-hour | 0.10% | 0.25% | tested |
| 15-minute | 0.06% | 0.18% | extrapolated |
| Daily | 0.40% | 1.00% | extrapolated |
Only the 4-hour pair was tested in depth. The other two are derived from observed readings and should be verified on your own chart before you rely on them.
Limitations — please read
- It is descriptive, not predictive. It tells you what conditions have been, not what they will be. A range can end on the next bar.
- It lags. The confirmation period means a state is recognised after it has already been in place for several bars — a deliberate trade-off against false classification.
- Thresholds are instrument- and timeframe-specific. Using the defaults on an unfamiliar chart will produce misleading classifications. Calibration is not optional.
- Two moving averages are a crude proxy. A market can trend slowly enough that separation stays low, and spike violently inside a range and briefly read as trending.
- Range boundaries reflect what has happened, not where the range will ultimately be contained, and are not redrawn retroactively.
- It produces no entries, no targets and no stops. Combining it with a signal system is left to you.
Originality
Moving-average separation is not a new observation. The original work is in the treatment: a normalised percentage measure rather than a raw distance, a three-state classification with an explicit transition band instead of a binary switch, a confirmation requirement to suppress boundary flicker, a minimum-duration filter so brief pauses are not drawn as ranges, and automatic measurement of the range that the compression identifies — its boundaries, its height in points and percent, and its duration.