APA-Adaptive, Ehlers Early Onset Trend [Loxx] — Indicator by loxx — TradingView
- Detects the onset of new trends in financial data.
- Utilizes autocorrelation periodogram algorithm to determine the dominant cycle period.
- Applies high-pass filtering and super-smoothing to extract the underlying trend.
- Incorporates adaptive gain control (AGC) for noise reduction and signal amplification.
- Adjustable parameters for fine-tuning the indicator's performance.
The AEOT indicator can be applied to various financial instruments, such as stocks, currencies, commodities, and cryptocurrencies. It is particularly useful for identifying potential trend reversals or the beginning of new trends, enabling traders and investors to make informed decisions about entering or exiting positions.
To use the AEOT indicator, you need to provide the following inputs:
input_data
: The time series data (e.g., stock prices) you want to analyze.auto_avg
: The averaging period for autocorrelation calculations.auto_min
: The minimum period for the dominant cycle detection.auto_max
: The maximum period for the dominant cycle detection.K
: The smoothing factor for the quotient calculation.
The indicator will output two arrays:
Q
: The AEOT indicator values.dominant_cycles
: The dominant cycle periods for each data point.
You can then plot the AEOT indicator values alongside the original time series data to visualize the identified trends and make trading decisions based on the indicator's signals.
The AEOT indicator is implemented using the Numba library for numerical computing in Python. Numba is a just-in-time (JIT) compiler that translates a subset of Python and NumPy code into fast machine code, providing significant performance improvements compared to pure Python implementations.
The implementation includes several helper functions:
nz
: Replaces zeros and NaN values with a small number to avoid division by zero errors.high_pass_filter
andhigh_pass_filter_2nd
: Apply high-pass filtering to the input data.super_smoother
: Applies a super-smoother filter to the high-pass filtered data._auto_dom_imp
: Calculates the dominant cycle period using the autocorrelation periodogram algorithm.agc
: Performs adaptive gain control on the filtered data.quotient
: Calculates the final AEOT indicator values using the AGC output and a smoothing factor.
The main AEOT
function orchestrates the execution of these helper functions and returns the AEOT indicator values and dominant cycle periods.
What is Ehlers Early Onset Trend? The Onset Trend Detector study is a trend analyzing technical indicator developed by John F. Ehlers, based on a non-linear quotient transform. Two of Mr. Ehlers' previous studies, the Super Smoother Filter and the Roofing Filter, were used and expanded to create this new complex technical indicator. Being a trend-following analysis technique, its main purpose is to address the problem of lag that is common among moving average type indicators.
The Onset Trend Detector first applies the EhlersRoofingFilter to the input data in order to eliminate cyclic components with periods longer than, for example, 100 bars (default value, customizable via input parameters) as those are considered spectral dilation. Filtered data is then subjected to re-filtering by the Super Smoother Filter so that the noise (cyclic components with low length) is reduced to minimum. The period of 10 bars is a default maximum value for a wave cycle to be considered noise; it can be customized via input parameters as well. Once the data is cleared of both noise and spectral dilation, the filter processes it with the automatic gain control algorithm which is widely used in digital signal processing. This algorithm registers the most recent peak value and normalizes it; the normalized value slowly decays until the next peak swing. The ratio of previously filtered value to the corresponding peak value is then quotiently transformed to provide the resulting oscillator. The quotient transform is controlled by the K coefficient: its allowed values are in the range from -1 to +1. K values close to 1 leave the ratio almost untouched, those close to -1 will translate it to around the additive inverse, and those close to zero will collapse small values of the ratio while keeping the higher values high.
Indicator values around 1 signify uptrend and those around -1, downtrend.
What is an adaptive cycle, and what is Ehlers Autocorrelation Periodogram Algorithm? From his Ehlers' book Cycle Analytics for Traders Advanced Technical Trading Concepts by John F. Ehlers, 2013, page 135:
"Adaptive filters can have several different meanings. For example, Perry Kaufman's adaptive moving average (KAMA) and Tushar Chande's variable index dynamic average (VIDYA) adapt to changes in volatility. By definition, these filters are reactive to price changes, and therefore they close the barn door after the horse is gone. The adaptive filters discussed in this chapter are the familiar Stochastic, relative strength index (RSI), commodity channel index (CCI), and band-pass filter. The key parameter in each case is the look-back period used to calculate the indicator. This look-back period is commonly a fixed value. However, since the measured cycle period is changing, it makes sense to adapt these indicators to the measured cycle period. When tradable market cycles are observed, they tend to persist for a short while. Therefore, by tuning the indicators to the measure cycle period they are optimized for current conditions and can even have predictive characteristics.
The dominant cycle period is measured using the Autocorrelation Periodogram Algorithm. That dominant cycle dynamically sets the look-back period for the indicators. I employ my own streamlined computation for the indicators that provide smoother and easier to interpret outputs than traditional methods. Further, the indicator codes have been modified to remove the effects of spectral dilation. This basically creates a whole new set of indicators for your trading arsenal.