@pips_v1 has proposed an interesting idea that is it possible to code an "Adaptive Jon Andersen Indicator" where the length is determined by DCPeriod as calculated in Indicator? I agree with him and starting to construct this indicator. After a study, I found "(blackcat) L2 Autocorrelation Periodogram" script could be reused for this purpose because Autocorrelation Periodogram is an ideal candidate to calculate the dominant cycle. On the other hand, there are two inputs for indicator:
I used Autocorrelation Periodogram to produced a dynamic value of "Length" of indicator and make it adaptive.
One tool available in forecasting the trendiness of the breakout is the coefficient of determination ( ), a statistical measurement. The indicates linear strength between the security's price (the Y - axis) and time (the X - axis). The is the percentage of squared error that the can eliminate if it were used as the predictor instead of the mean value. If the were 0.99, then the would eliminate 99% of the error for prediction versus predicting closing prices using a .
When the is at an extreme low, indicating that the mean is a better predictor than regression, it can only increase, indicating that the regression is becoming a better predictor than the mean. The opposite is true for extreme high values of the .
To make this indicator adaptive, the dominant cycle is extracted from the spectral estimate in the next block of code using a center-of-gravity ( CG ) algorithm. The CG algorithm measures the average center of two-dimensional objects. The algorithm computes the average period at which the powers are centered. That is the dominant cycle. The dominant cycle is a value that varies with time. The spectrum values vary between 0 and 1 after being normalized. These values are converted to colors. When the spectrum is greater than 0.5, the colors combine red and yellow, with yellow being the result when spectrum = 1 and red being the result when the spectrum = 0.5. When the spectrum is less than 0.5, the red saturation is decreased, with the result the color is black when spectrum = 0.
Construction of the autocorrelation periodogram starts with the autocorrelation function using the minimum three bars of averaging. The cyclic information is extracted using a discrete Fourier transform (DFT) of the autocorrelation results. This approach has at least four distinct advantages over other spectral estimation techniques. These are:
1. Rapid response. The spectral estimates start to form within a half-cycle period of their initiation.
2. Relative cyclic power as a function of time is estimated. The autocorrelation at all cycle periods can be low if there are no cycles present, for example, during a trend. Previous works treated the maximum cycle amplitude at each time bar equally.
3. The autocorrelation is constrained to be between minus one and plus one regardless of the period of the measured cycle period. This obviates the need to compensate for Spectral Dilation of the cycle amplitude as a function of the cycle period.
4. The resolution of the cyclic measurement is inherently high and is independent of any windowing function of the price data.
DC --> dominant cycle.
AvgSqrR --> output of the indicator.
This is a Level 2 free and open source indicator.
Feedbacks are appreciated.
Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.
USDT TRC20: TWVYATJFN7SsbrmH8jLVrWHaV2aNruvvcT
USDT ERC20: 0xfd4d0eb131e81f44530849c1a966cb261dd6bda2