OPEN-SOURCE SCRIPT

Adaptive Ehlers Filtered Percentile

8 774
Adaptive Ehlers Filtered Percentile is a trend-regime indicator that combines a volatility-adaptive moving average, a displacement-weighted nonlinear filter, and percentile-based price-deviation bands.

The indicator is designed to separate three tasks: adapt the baseline response to changing price variability, further filter that baseline according to historical displacement, and derive regime thresholds from the observed distribution of price-to-trend deviations rather than from a fixed percentage or standard-deviation multiplier.

🟣How It Works
The first stage measures the standard deviation of one-bar price changes.

That volatility measurement is compared with a rolling reference range. The resulting position inside the range determines the effective moving-average period between the user-defined Minimum MA Period and Maximum MA Period.

Higher volatility favors the shorter period, while lower volatility favors the longer period.

The adaptive period is converted into a smoothing coefficient and applied recursively to produce the Adaptive MA.

🟣Displacement-Weighted Filter
The Adaptive MA is then processed through a nonlinear weighted filter.

For each observation in the filter window, the script compares the current Adaptive MA value with another Adaptive MA value separated by the Momentum Length.

The absolute displacement between those observations becomes the weighting coefficient.

Observations associated with larger displacement therefore contribute more heavily to the final filtered trend value, while observations with little displacement contribute less.

If valid weighting coefficients are unavailable, a simple moving average of the Adaptive MA is used as a fallback.

🟣Percentile Bands
The indicator measures the absolute distance between price and the filtered trend:

Absolute Deviation = |Price - Filtered Trend|

These deviations are ranked over the selected Percentile Length.

The chosen Percentile Level determines the historical deviation used as the base band distance.

Unlike standard-deviation bands, this approach does not assume a particular distribution of deviations. The band width instead comes directly from the ranked historical observations.

Separate upper and lower multipliers allow the two sides of the structure to be adjusted independently.

🟣Regime Logic
A bullish regime begins when the selected source moves above the upper percentile band.

A bearish regime begins when the selected source moves below the lower percentile band.

When price remains between the two bands, the previous regime is retained.

LONG and SHORT markers are therefore displayed only when the persistent regime changes rather than on every bar that remains outside a threshold.

🟣Main Settings
Minimum MA Period / Maximum MA Period define the response range of the volatility-adaptive moving average.

Volatility Period controls how much recent price-change history is used to determine the adaptive response.

Filter Length determines how many Adaptive MA observations contribute to the displacement-weighted filter.

Momentum Length determines the historical separation used when measuring displacement for the filter weights.

Percentile Length defines the sample of historical price-to-filter deviations.

Percentile Level determines which ranked deviation becomes the base band width. Higher percentiles generally create more selective thresholds.

Upper Band Multiplier / Lower Band Multiplier independently scale the bullish and bearish thresholds.

🟣Design Purpose
The indicator uses each component for a specific role:

Price-change volatility → Adaptive MA response
Adaptive-MA displacement → Nonlinear filtering weights
Historical absolute deviation → Percentile band width
Band breakout → Persistent market regime

The percentile stage is applied to the actual distance between price and the adaptive filtered baseline. This allows the threshold structure to adjust to the historical distribution of deviations rather than relying only on a fixed volatility multiplier.

The asymmetric upper and lower multipliers also allow the bullish and bearish breakout requirements to be configured independently.

🟣Limitations
This indicator is a trend-regime tool and not a complete trading system. LONG and SHORT labels identify changes in the indicator's internal regime; they do not imply guaranteed trade outcomes or future performance.

Percentile thresholds are based on historical observations within the selected lookback. A change in market behavior can therefore alter the band width as new deviations enter the sample.

The adaptive moving average and nonlinear filter are derived from current and historical price information and remain dependent on the selected parameters.

The script does not use higher-timeframe requests or lookahead logic.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.