Ehlers Correlation Trend Indicator
Most trend-strength readings - a slope, a rate of change, a moving average distance - have no natural ceiling, so every implementation ends up inventing its own normalisation to make the number readable. Ehlers avoided that entirely for this indicator by reaching for the one statistic that is bounded by definition: Pearson's correlation coefficient. Each bar, the indicator compares the last InpPeriod closes against a perfectly straight line that rises steadily into the present. If price has actually been tracking that straight line - a clean uptrend - the correlation sits near +1. A clean downtrend correlates near -1. Anything choppy, cyclical, or directionless correlates near zero, because a wandering price series simply does not resemble a straight ramp in either direction. No scaling, no lookback-dependent rescaling, no separate "is this significant" step - the statistic itself already answers that. This is recomputed by direct summation on every bar rather than carried forward as a running filter. Correlation over a fixed window is not a recursive quantity - each new bar needs its own fresh sum against the ramp - and at the period lengths this indicator is meant to run at (10 to 30 bars) that costs nothing worth optimising away with an incremental update that would only add complexity and a class of bugs recursive filters do not have. Notes and limitations - This measures how well price fits a straight line over the window, not the size or speed of the move - a slow, steady creep and a fast, steady run can both read close to +1. - It says nothing about whether a trend will continue. A high reading describes the recent window, not a forecast of the next one. - The correlation denominator can legitimately be exactly zero (a perfectly flat window of identical closes); the indicator returns 0 for that bar rather than dividing by zero. - Every value is computed from closed bars only within the window ending at the current bar, so nothing here repaints once a bar closes.
Indicator · MT5 · v1.0 · Free
About Ehlers Correlation Trend Indicator
Ehlers Correlation Trend Indicator is an indicator for MetaTrader 5. 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: EhlersCorrelationTrend.ex5, EhlersCorrelationTrend.mq5, EhlersCorrelationTrend.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Period | 20 | Correlation lookback in bars |
| Alerts | true | Alert once per closed bar when CTI crosses +-0.5 |
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: Moving Average · Momentum · Trend · Alerts · MT5 Indicator · MQL5 Source Code