Loading…

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 · MT4 · v1.0 · Free

About Half Life Tuned Oscillator

Half Life Tuned Oscillator is an indicator for MetaTrader 4. It has 6 settings, such as Fit lookback, Min r squared and Period multiple. MQL source code included.

Files in the download: HalfLifeTunedOscillator.ex4, HalfLifeTunedOscillator.mq4, HalfLifeTunedOscillator.txt.

Settings

SettingDefaultWhat it does
Fit lookback100Bars used to fit the AR(1) half-life regression
Min r squared0.10Minimum regression R-squared required to trust the fit
Period multiple1.0Oscillator period = round(half-life * this multiple)
Min period5Floor on the derived oscillator period
Max period100Ceiling on the derived oscillator period
Max plot bars250History bars kept recomputed (performance cap)

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Oscillator · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria