HOW-TO allow your indicators to adapt to market cycles

For many traders with a background in digital signal processing (DSP), John F Ehlers' cycle theory may be easy to understand. He sees the market as a discrete digital signal system and uses a lot of modern digital signal algorithms in his indicators. Among them, he believes that the market life is a variable cycle, rich in various harmonic components of the digital signal system. Since it is a variable cycle, if the parameters of many technical indicators are fixed, they can only conform to the market characteristics for a certain period of time and can correctly reflect the real state of the market at that time alone. Once the market frequency is adjusted, the "frequency" of the fixed parameter indicator will be "out of tune" with the market, and thus will be invalid. In short, it is like the FM radio used in daily life. If the frequency can be matched, you can enjoy wonderful music. Once the frequency is shifted, you can only hear noise. This is a truth for market as well. In addition, Ehlers' cycle theory holds that trends are just large cycles, with rising or falling phases dominated by the large-period component, and small periods of various rhythms mixed in with the large-period component. But in any case, it can be expressed by sine wave synthesis of many frequencies, but there are many components, and the frequency is changing. In fact, this not only corresponds to Dow Theory and Elliott Wave Theory, but also corresponds to the concept of "level/timeframe" of Chinese Zen Theory. This explains why many people still fail to invest in stocks after learning the Elliott wave or Zen theory, because this "dominant cycle/level/timeframe" is changing, not static. Most likely to lose money or being liquidated. If a sniper wants to hit a high-speed moving target, he must adjust the magnification of the magnifying glass. Using a fixed multiplier to shoot an out-of-range target will increase the probability of misses. It is reasonable to use technical indicators as well.
Technical indicators of automatic parameter adjustment
At present, many people try various methods to make technical indicators quickly adapt to market changes, that is, Adaptive Indicators. There is no shortage of traders using AI machine learning algorithms and even the latest Transformer algorithms (Google). However, traditional machine learning algorithm training requires a large number of samples and training to ensure that the algorithm converges and obtains effective parameters. But this response is often not enough to meet the rapidly changing market trends. At this time, some adaptive algorithms in the Ehlers cycle theory can be considered to adapt the index parameters.
For example, the figure below is an adaptive RSI that calculates the main control period through discrete Fourier transform and uses the main control period to "tune" the RSI indicator parameters. Simply put, the parameter of this adaptive RSI is neither 14 nor 7, but a dynamic parameter N is calculated according to market changes, you can set the range of this N, and the algorithm will automatically calculate the value of N, and Let RSI automatically adjust among different parameters.

لقطة
SZSE: 399006 ChiNext Index from TradingView

In order to compare and see the effect of adding or not adding self-adaptation on the indicators, I use the following ESCGO oscillator for comparison. The above is the ESCGO indicator with fixed parameters that I wrote, and the following is the ESCGO indicator with adaptation. Can you see the difference?

لقطة
SZSE: 399006 ChiNext Index from TradingView

I read 4 English books of J.F Ehlers, and after carefully studying all the published articles, I summed up 12 algorithms for calculating the Dominant Cycle of the market, and wrote them into the TradingView pine v5 library dc_ta to share publicly at TradingView community.

https://cn.tradingview.com/script/fFRrJMmA/

1. EhlersHoDyDC(). This is the algorithm that Ehlers uses Hilbert Transform combined with Homodyne Discriminator to calculate the main control period. Homodyne means that the market signal is multiplied by itself. More precisely, we want to multiply the complex value of the signal of the current bar with the signal of the previous bar. By definition, a complex conjugate is a complex number with the sign of its imaginary part reversed.

2. EhlersPhAcDC(). This is an algorithm that uses the Hilbert Transform combined with the Phase Accumulator to calculate the master cycle. The market master cycle measurement using the phase accumulation method always uses one full cycle of historical data. This is both an advantage and a disadvantage. The advantage is that the hysteresis in the obtained master period is directly related to the loop period. That is, short-period measurements have less lag than long-period measurements. However, the number of samples used to make the measurements means that the average period varies with the loop period. A longer averaging time will reduce the noise level compared to the signal. Therefore, a shorter period necessarily has a higher output signal-to-noise ratio (SNR). Therefore, this algorithm is more suitable for calculating small cycles to ensure less cycle calculation lag.

3. EhlersDuDiDC(). This is the way to calculate the main control period using the Hilbert Transform combined with the Dual Differential algorithm. The market signal components are complex averaged and smoothed in the EMA to avoid any undesired cross products in the subsequent multiplication steps. Periods are solved directly from the smoothed in-phase and quadrature components. The temporary calculation of the denominator is performed as Value1 to ensure that the denominator does not have a zero value. The sign of Value1 is reversed with respect to the theoretical equation because the difference is looked back in time.

4. EhlersCycPer(). This is Cycle Period. It shows how to calculate the current cycle period, which is the approximate number of bars between the current peak or trough and the next peak or trough.

5. EhlersCycPer2(). This is another version of Cycle Period.

6. EhlersBPZC(). This is the Bandpass Zero Crossings method. Traders who have a better understanding of digital filter theory will know that the main control period can be found by constraining the bandwidth of the bandpass filter, and other period components are filtered out, and then the output signal will be like a sine wave, when the sine wave starts crossing over from a zero point. It is a cycle to crossover zero to the next time.

7. EhlersAutoPer(). This is the Autocorrelation Periodogram method. The construction of the autocorrelation periodogram starts with the autocorrelation function using a minimum of three average candlesticks. Extract loop information using the discrete Fourier transform (DFT) of the autocorrelation results. Compared with other spectrum estimation techniques, this method has specific advantages (which do not mean that these advantages are more obvious in practical applications).

8. EhlersHoDyDCE(). This is an algorithm that Ehlers uses to calculate the main control period using Bandpass Filtering combined with Homodyne Discriminator.

9. EhlersPhAcDCE(). This is the algorithm that Ehlers uses Bandpass Filtering combined with Phase Accumulator to calculate the main control period.

10. EhlersDuDiDCE(). This is how Ehlers uses Bandpass Filtering combined with Dual Differential algorithm to calculate the dominant cycle.

11. EhlersDFTDC(). This is the method of extracting the dominant period by discrete Fourier transform.

12. EhlersDFTDC2(). This is a method of extracting the dominant period using multiple bandpass filters combined with discrete Fourier transforms.

The dc_ta library can enable traditional indicators, but there is also a difficulty here, that is, the problem of scaling dynamic adaptive parameters: which value is the benchmark, and how much amplitude is the best. I understand that the use of the dc_ta adaptive library can only undertake part of the work of tracking market changes by the algorithm, and it is still necessary to control the long-term drift of the algorithm. I am still in the research stage. At present, in addition to calibration, the calculated period lag still needs to be evaluated. That is to say, if the calculated cycle is already obsolete, it is of little significance to the current market. Who are interested in this topic are welcome to exchange relevant insights with me.
blackcat1402Trend Analysis

Avoid losing contact!Don't miss out! The first and most important thing to do is to join my Discord chat now! Click here to start your adventure: discord.com/invite/ZTGpQJq 防止失联,请立即行动,加入本猫聊天群: discord.com/invite/ZTGpQJq
يعمل أيضًا:

منشورات ذات صلة

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