Half Life Tuned Oscillator
A fixed-period oscillator is tuned for one particular reversion speed and stays tuned for it even after the market's actual reversion speed has drifted - a 14-period oscillator built for a market reverting on a 10-bar half-life reads noisily once that same market starts reverting on a 40-bar half-life instead. This indicator removes the guesswork: on every closed bar it fits the same AR(1)-slope Ornstein-Uhlenbeck half-life already used elsewhere in this catalogue (HalfLifeReversionSystem, Reversion Speed Gauge), then uses that fitted half-life - scaled by an input multiplier and clamped to a sane range - as the window length for a plain z-score of price against that window's own mean and standard deviation. When the half-life regression itself is unmeasurable on a given bar (no detectable reversion, a degenerate fit, or R-squared below the input threshold) the oscillator plots a gap rather than falling back to a guessed period or a stale reading - the same no-guess discipline the half-life estimator uses everywhere else it appears in this catalogue. Notes and limitations This is a reading tool, not a trading signal generator on its own - it draws no entries, exits or alerts. Because the period genuinely changes bar to bar, the same price move can produce a different-looking oscillator swing depending on what half-life was measured at the time; this is the deliberate point of the indicator, not inconsistency. Every plotted bar's half-life and z-score are refit from scratch on each new closed bar within InpMaxPlotBars, so the visible history can shift slightly as new bars extend the fit range - expected, not a bug.
Indicator · MT5 · v1.0 · Free
About Half Life Tuned Oscillator
Half Life Tuned Oscillator is an indicator for MetaTrader 5. It has 6 settings, such as Fit lookback, Min r squared and Period multiple. MQL source code included.
Files in the download: HalfLifeTunedOscillator.ex5, HalfLifeTunedOscillator.mq5, HalfLifeTunedOscillator.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Fit lookback | 100 | Bars used to fit the AR(1) half-life regression |
| Min r squared | 0.10 | Minimum regression R-squared required to trust the fit |
| Period multiple | 1.0 | Oscillator period = round(half-life * this multiple) |
| Min period | 5 | Floor on the derived oscillator period |
| Max period | 100 | Ceiling on the derived oscillator period |
| Max plot bars | 250 | History bars kept recomputed (performance cap) |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 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: Oscillator · MT5 Indicator · MQL5 Source Code