Reversion Speed Gauge
Most mean-reversion tools pick a lookback and a threshold once and leave them fixed forever, even though the actual speed of reversion drifts as the market's regime changes. This indicator instead fits an Ornstein-Uhlenbeck model to the trailing closes on every closed bar - a plain OLS regression of the bar-to-bar change against the current level, dx = a + b*x - and converts the fitted slope into a half-life in bars: the number of bars it typically takes a deviation from equilibrium to close half the gap. The regression is not always trustworthy, and the indicator says so rather than guessing. A non-negative slope means no mean reversion was detected at all; a slope at or beyond the unit circle makes the half-life mathematically undefined; a half-life longer than the fitted window is not a reversion speed worth reporting; and a fit whose R-squared falls below the input threshold is judged too weak to trust. Any of these produces a gap in the plotted line rather than a stale or interpolated number - a flat line during an unmeasurable regime would be actively misleading to a trader reading the gauge at a glance. The same AR(1)-slope technique is already used in this catalogue by the HalfLifeReversionSystem Expert Advisor and the MeanReversionHalfLife script; this indicator is the same measurement made into a continuously plotted gauge rather than a trading decision or a one-shot report. Notes and limitations This is a diagnostic gauge, not a trading signal generator - it does not draw entries, exits or alerts. The half-life is a backward-looking statistical fit and can change abruptly when the underlying regime does; treat a sudden jump as a signal to re-check, not as an error. Every bar in the plotted history is refit from scratch on each new closed bar (bounded by InpMaxPlotBars), so the whole visible line can shift slightly as history extends - this is expected, not a bug. Does not repaint the current closed bars' values once plotted, but the still-forming bar 0 is excluded from the fit entirely, matching the same discipline used elsewhere in this catalogue.
Indicator · MT4 · v1.0 · Free
About Reversion Speed Gauge
Reversion Speed Gauge is an indicator for MetaTrader 4. It has 3 settings, such as Lookback bars, Min r squared and Max plot bars. MQL source code included.
Files in the download: ReversionSpeedGauge.mq4, ReversionSpeedGauge.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Lookback bars | 150 | Bars used to fit the AR(1) regression each recompute |
| Min r squared | 0.10 | Minimum regression R-squared required to trust the fit |
| Max plot bars | 300 | History bars to keep recomputed (performance cap) |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Trailing Stop & Break-even · MT4 Indicator · MQL4 Source Code