Ehlers Reflex And Trendflex
Most oscillators force a single design choice: respond fast to cycle turns and get whipsawed by every strong trend, or track trend thrust cleanly and lag badly at every genuine turn. Ehlers' 2020 Stocks & Commodities article "Reflex: A New Zero-Lag Indicator" addresses this by publishing two oscillators from the same underlying filtered price rather than picking one compromise. Both start from a 2-pole SuperSmoother of price - the same Butterworth- style low-pass this catalogue's roofing filter and MESA Stochastic use. Reflex then measures how far the smoothed line has departed from a straight-line projection of its own recent slope, which lets it register a cycle turn even while price is still trending, because the comparison is against where the trend would have put price, not against price itself. Trendflex instead compares the smoothed line directly against its value one lookback period back, so it accumulates a reading during a sustained push and settles back toward zero inside a bounded cycle. Both normalise their own output by a running root-mean-square of themselves, which is what keeps the reading self-scaled across instruments without a fixed overbought/oversold band. Very few MQL4 ports of this pair exist, and the two-stage normalisation (mean-square smoothing at a fixed 0.04/0.96 blend, applied independently to each oscillator) is the detail that is easy to get subtly wrong - sharing one mean-square state between Reflex and Trendflex, or omitting the running normaliser altogether, both produce a plausible-looking but wrong output. Notes and limitations - Both oscillators are recursive and reach InpPeriod bars into history on top of the SuperSmoother's own one-bar lag, so the first InpPeriod or so bars after a fresh attach (or after changing InpPeriod) are a warm-up period seeded at zero, not a true reading. - The mean-square normaliser is itself a recursive smooth (0.04 new / 0.96 old each bar), so both lines still carry a small amount of lag from that stage even though the base filter is designed to minimise it - this is not a zero-lag indicator in the literal sense, only a low-lag one. - Because it is pure recursive arithmetic on closing price with no lookahead, it never repaints: every value shown for a closed bar is final. - Agreement between Reflex and Trendflex crossing zero together is a filter, not a guarantee - both are built from the same underlying SuperSmoother, so they are correlated by construction and can still agree on a false signal in a genuinely random stretch of price.
Indicator · MT4 · v1.0 · Free
About Ehlers Reflex And Trendflex
Ehlers Reflex And Trendflex is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Period and Alerts. MQL source code included.
Files in the download: EhlersReflexTrendflex.ex4, EhlersReflexTrendflex.mq4, EhlersReflexTrendflex.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Period | 20 | Lookback period for both the slope/offset window and the RMS normaliser |
| Alerts | true | Alert once per closed bar when Reflex and Trendflex agree on a zero-line cross |
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: Oscillator · Trend · Alerts · MT4 Indicator · MQL4 Source Code