Range Boundary Tracker
- Indicators
- Version: 1.0
- Activations: 5
# Range Boundary Tracker - Edges that do not follow price
*Category: Support and Resistance | Difficulty: intermediate | Window: chart window (overlaid on price) | Markets: Universal (Forex, indices, commodities, crypto, stocks) | Suggested timeframes: M15, M30, H1, H4, D1*
## Short description
> Recognises when the market enters a range, fixes its two extremes and holds them still while the range lasts, as a trader would draw them.
## Full description
### Overview
A channel that follows price bar by bar is not a range: it is a moving average by another name. A true range has two fixed edges, which the trader draws once and does not touch again until price breaks them. This indicator replicates exactly that behaviour. It checks whether price, for a sufficient number of bars, stayed inside a band narrow relative to its own volatility; when the condition is met it fixes the two edges and freezes them. From that moment the two lines stay still, regardless of what price does inside them. The range is declared over only when price closes beyond an edge with a sufficient margin, and the indicator returns to waiting to recognise a new one. The duration check prevents two coincidentally close bars from being mistaken for a range.
### How the calculation works
1. A candidate range exists when the high and low of the last InpDetectBars bars are less than InpMaxRangeAtr times the ATR apart.
2. The condition is also checked over the previous InpMinDuration bars: a two bar range is not a range.
3. When both checks pass, the two edges are fixed at their current values and frozen.
4. While the range is active the indicator no longer updates the edges: it only checks whether they have been broken.
5. A break requires a close beyond the edge by at least InpBreakAtr times the ATR, to exclude marginal overshoots.
6. After the break the indicator returns to searching and the edges disappear from the chart.
### How to use it
- Buy at the lower edge and sell at the upper one while the range is active.
- The midline is the equilibrium reference: price tends to return there when it strays too far from both edges.
- The disappearance of the edges signals the range has been broken and that range strategy must be suspended.
- The range width is the natural target measure for a trade from one edge to the other.
- A range lasting many bars tends to produce a wider break: the visible duration is a hint.
### Who it is for and on which timeframes
It targets range traders who need stable edges to place orders on, instead of lines shifting on every bar. It works from M15 to D1. The frozen edge behaviour is the distinguishing feature and must be understood: anyone expecting lines that follow price will find the indicator static, but that stillness is exactly the point. It also suits breakout traders, because frozen edges are reliable break references.
### Practical example of reading a signal
On EURGBP H1 price enters a compressed phase. After eleven bars inside a twenty five pip band the condition is met and the two edges are fixed at 0.8620 and 0.8645. Over the next thirty two bars price touches the lower edge four times and the upper one three times, reacting each time. The lines never moved, so the trader could leave pending orders on both edges without having to shift them. On the thirty third bar price closes at 0.8654, beyond the required margin: the range is over, the lines disappear and range strategy is suspended.
## Input parameters
| Parameter | Default | Description |
|---|---|---|
| `InpDetectBars` | 20 | Bars over which the range condition is checked. It defines the scale of range to be recognised. |
| `InpAtrPeriod` | 50 | Reference ATR period for judging whether the band is narrow. |
| `InpMaxRangeAtr` | 3.00 | Maximum range width, in ATR. Lowering it recognises only the most compressed ranges. |
| `InpBreakAtr` | 0.30 | Margin beyond the edge required to declare a break and exclude marginal overshoots. |
| `InpMinDuration` | 8 | Minimum bars for a range to be recognised. It prevents two coincidentally close bars from being mistaken for a range. |
## Advantages / strengths
- The edges stay still, as a trader would draw them, and can therefore be used for pending orders.
- The duration check prevents recognition of spurious ranges of a few bars.
- The disappearance of the edges is a clean end of range signal, not an ambiguous gradual transition.
- The ATR width criterion works with no calibration on any instrument.
## Limitations and warnings
- Recognition arrives late: the range has already been under way for several bars when the edges appear.
- Frozen edges mean a range widening slightly is declared broken instead of being updated.
- In strongly directional markets the indicator stays empty for long stretches.
- The double duration check makes the computation heavier than a simple check on the current window.
**No repaint:** values printed on a closed bar are never modified afterwards.
**Disclaimer.** This product is a technical analysis tool, not an automated trading system, and it offers no profit guarantee whatsoever. Financial markets carry the risk of total loss of the invested capital. Past performance is not indicative of future results. Every signal must be confirmed with your own analysis, a money management plan and prior testing on a demo account. The author is not responsible for trading decisions taken on the basis of this indicator.
## Suggested tags / keywords for MQL5
`range`, `consolidation`, `support resistance`, `boundaries`, `mean reversion`, `breakout`, `no repaint`, `levels`