Cycle Analytics for Traders + Downloadable Software: Advanced Technical Trading Concepts (Wiley Trading) by John F. Ehlers

Cycle Analytics for Traders + Downloadable Software: Advanced Technical Trading Concepts (Wiley Trading) by John F. Ehlers

Author:John F. Ehlers [Ehlers, John F.]
Language: eng
Format: mobi, epub, pdf
ISBN: 9781118728604
Publisher: Wiley
Published: 2013-12-10T00:00:00+00:00


■ Discrete Fourier Transform (DFT)

The DFT is accomplished by correlating the data with the cosine and sine of each period of interest over the selected window period. The sum of the squares of each of these correlated values represents the relative power at each period from the familiar trigonometric equation:

The code to compute the DFT is shown in Code Listing 9-1. The only user input is whether to select Spectral Dilation compensation. The default selection is to use the compensation. The default window length is 48 bars, selected to be one full cycle period of the longest cycle period to be computed. The arrays are sized for the longest cycle period's being 48 bars. After declaring the variables, the data are prefiltered in a high-pass filter having a 48-bar cutoff period to be consistent with our longest computed cycle period and then smoothed in the SuperSmoother, described in Equation 3-3, and having a 10-bar cutoff period to be consistent with the shortest cycle period of interest.

EasyLanguage executes the entire code from top to bottom for each new bar of data from oldest to newest. Computation of the DFT for each new data bar starts by multiplying the data with a sine wave and a cosine wave, respectively, divided by the period being calculated and summing the products over the window length. In this case, the window length was made to be equal to the period of the longest cycle period to be computed. The sine part and cosine part of the wave at each period are squared and summed to compute the power at each period. The wave amplitude of each period computation was divided by the value fractal dilation compensation. If the spectral dilation compensation input is set to false, the wave amplitudes are simply divided by 1, with the effect that there is no compensation.

In the next block of code, a fast attack−slow decay automatic gain control (AGC) is used to normalize the spectral components and to minimize the variance of the spectral power over time. The AGC concept was introduced in Chapter 5 of this book; however, in this case, we are scaling on the basis of power rather than on wave amplitude. Therefore, the correct decay factor is the square root of 0.991, or 0.995. If the current power is greater than the variable MaxPwr, then the variable MaxPwr is immediately set to the value of the current power. However, if the current power is less than MaxPwr, then the MaxPwr is allowed to decay to 0.995 of its previous value.

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. It is computed by summing the Y values and independently summing the X * Y values. Dividing the latter by the former yields the average position along the X axis where all the Y values reside. In the case of computing the dominant cycle, the Y values are power and the X values are the periods.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.