CYCLE MEASUREMENTS
by
John Ehlers
Source: MESA Software Technical Papers
INTRODUCTION
There's no doubt about it. Market cycles are difficult to identify. However, if they can be measured the payoff is substantial. By measuring cycles we have an independent parameter that frees us from using static indicators like Stochastics, RSI, MACD, or even Moving Averages with fixed settings. The measurements enable us to make these indicators be dynamically adjusted to current market conditions.
There are currently three popular methods to identify market cycles. These are cycle finders, Fourier Transforms, and MESA (Maximum Entropy Spectral Analysis). Cycle finders are included in virtually all indicator toolbox software programs. They basically measure the spacing between successive lowest lows (or other identifiable places in the cycle) and generally depend on finding an average value across a number of cycles. Fourier Transforms have long been a scientific analysis tool, but suffer from resolution difficulties in an attempt to satisfy stationarity constraints. That is, market cycles don't exist for a long enough period to make a good Fourier Transform measurement. We have adapted the MESA approach for market analysis from siesmic exploration for oil, when obtaining information from a short burst of data is mandatory. This article discusses these measurement techniques.
FOURIER TRANSFORMS
Fourier Transforms enable scientists and engineers to work interchangeably in the time and frequency domains. That is, the shape of a waveform also describes the frequency components that comprise the waveshape. Fourier Transforms are not just limited to time and frequency. For example, the relationship between the illumination of a beacon, like in a lighthouse, and the light beam that is formed is also a Fourier Transform. The ability to use time and frequency interchangeably open our vision in the way we view the market. For example, J.M. Hurst[1] has shown the only difference between a Head-And-Shoulders pattern and a Double Top pattern is the phasing of the cyclic components. In this sense, it is often easier to think in terms of the cyclic components rather than memorizing a wide library of chart patterns.
The Fourier Transform method of measuring cycles is subject to several constraints. First, when the data sample is taken it is viewed as a window in a long data string. The assumption is that this window is a sample of the entire data string that can be recreated by laying the window head-to-tail both into the infinite past and into the infinite future. That assumption is clearly violated when market data is windowed, but it is still necessary that the data be stationary (i.e. the cycles be consistent in frequency, amplitude, and phase) within that window. There is another constraint. This second constraint is that only an integer number of cycles within the window can be analyzed. For example, if we have a 64 day data window the longest cycle we can analyze is a 64 day cycle. Following the integer number of cycles rule, the next longest analysis cycle is a 64/2=32 day cycle. Continuing, the other cycles we can identify are 64/3=21.3 days, 64/4=16 days, etc. Our problem is that we have a lack of resolution. There is more than a 5 day gap in the periods we can identify precisely in the range where we would prefer to work. We don't know if a cycle period is 16, 18, or 20 days long. The only solution to this dilemma is to increase the size of the window. If we increase the window to 256 days (about a year's worth of daily data), we can now obtain a 1 day resolution in the vicinity of a 16 day cycle. But such a long window would require that the 16 day cycle be present and consistent for over a year. That clearly will not happen because traders could see such a cycle by casual observation, and by trading it, cause it to cease.
|
Figure 1. Spectrum Amplitude versus Cycle Period |
A spectrum display often consists of a plot of the amplitude of the cyclic components versus the frequency or cycle period. Such a display is shown in Figure 1. This display shows amplitude on a logarithmic decibel scale to capture as wide a range as possible. Each 3 dB decrease in amplitude reduces the power by half. The 20 dB range of the graph means that amplitude is depicted over a 100:1 range. On the right hand side of the chart each 3 dB increment is identified by a color. Think of the colors going from white hot to ice cold. We can use the colors to show the spectral estimate below a barchart as a colorized contour plot, thus picturing the spectral estimate in time synchronism with the price action. Doing this, we see both a theoretical 24 bar cycle and its Fourier Transform in Figure 2. Since the maximum cyclic energy is splattered across a broad range of cycle periods we cannot identify even the theoretical cycle from its Fourier Transform. The lack of resolution is also evident in Figure 3, a Fourier Transform of real-world data.
|
Figure 2. Fourier Transform Resolution of a 24 Bar Cycle |
|
Figure 3. Fourier Transform Resolution for March 96 Treasury Bonds |
MESA (Maximum Entropy Spectral Analysis)
Entropy is a measure of disorder. With some poetic license, the MESA technique extracts cyclic information from a data set, leaving the residual with a maximized noise, or disorder. There are no constraints regarding windowing or the length of cycles that can be analyzed. The operation of MESA is described with reference to Figure 4. The windowed data is fed into one input of a comparitor as a serial data stream. The other input of the comparitor is the output of a tunable filter. The comparitor output is fed back to tune the filter in such a way that the filter output replicates the real data in the window as best it can. The filter is fed from a white noise source (white noise consists of all frequencies). So the filter extracts the frequencies it needs and adjusts phase and amplitudes to generate the time waveform replica. When the filter tuning process is complete, a sweep generator can be applied to the filter to measure the filter's transfer response. This transfer response is exactly a measure of the frequency content of the time waveform.
|
Figure 4. How MESA Works |
The advantage of the MESA cycle measurement is that a high resolution measurement can be made with a very short amount of data. We dynamically adjust the data length to be only one cycle. Since the dominant cycles usually shift slowly, the previous day's measurement serves to set the length of the current day's data window. The resulting measurement resolution of the theoretical 24 bar cycle is shown in Figure 5. The impact of improved resolution can be made by comparing Figure 5 with Figure 2 and Figure 6 with Figure 3.
|
Figure 5. MESA Spectral Resolution of a 24 Bar Cycle |
The MESA-measured cycles in Figure 6 clearly identify the ebb and flow of the cycle periods. It is precisely this ebb and flow that shows market cycles must be treated dynamically. Averaging cycle periods across a number of cycles is certainly bound to produce inaccurate results at the right hand side of the chart where all trading is done. Since the cycle lengths are variable, adjustment to these lengths must be dynamic. For this reason, setting oscillator parameters based on a cycle measurement averaged across a large data span is bound to be inaccurate even when a Maximum Entropy measurement is used.
|
Figure 6. MESA Spectral Resolution for March 96 Treasury Bonds |
USING MEASURED CYCLES IN TRADING
It is not enough to just accurately measure market cycles. They need to be put to work to implement trading tactics based on an overall strategy. It is not sound strategy to solely trade the cycles because, as both Hurst and I have pointed out, tradable cycles are present only about 15 percent of the time. So, a sound trading strategy must incorporate trend mode techniques. The problem here is to identify when the market is in a cycle mode and when it is in a trend mode. Cycle measurement can help here also.
One fundamental definition of a cycle is a phenomena that has a constant rate change of phase. There are 360 degrees of phase in a complete cycle, so a 10 day market cycle varies at a constant rate of 36 degrees per day. We can measure phase[2]. When market is in the cycle mode the rate-change of phase is consistent with the measured cycle period. However, when the market is in a trend the phase almost stops changing. It turns out that the failure of correlation of the rate-change of phase and the measured cycle period is a powerful and consistent early indicator of the onset of a trend. Also, correlation is an early indicator that the trend is over. Of course, the lack of correlation cannot tell you whether the trend is up, down, or sideways; but it can save you from being whipsawed by being too early or too late. You would need a trend-following tactic, such as moving averages to implement trend mode trades.
Oscillators should be employed when the market is in a cycle mode because this type of indicator has a low amount of lag. Our favorite oscillator is the Sinewave Indicator, formed simply by plotting the Sine of the measured phase[3]. Crossover entry signals can be created in anticipation of the cyclic turning points by adding 45 degrees to the measured phase and taking the Sine of this leading argument. Advancing the phase produces a leading indicator without increasing its noise content, as is the case with momentum functions. An additional advantage of the Sine and LeadSine curves is that they seldom cross when the market is in the trend mode. This is because the phase is not varying during the trend mode and so that indicator lines remain separated by their phase difference.
|
Figure 7. Using Spectral Estimates to Dynamically Adjust Indicators |
Figure 7 is a revisit of the measurements of Figure 6 with the indicators added. During October, November, and December the trend mode is identified by the violet price bars. Highly profitable trading resulted during this period by following the adaptive moving averages. In January and February the rate change of phase is consistent with the measured dominant cycle. The cycle mode is identified by the blue price bars during this period. During this cycle mode, not only are whipsaw losses avoided, but profitable trades are made by trading the crossovers of the Sinewave Indicator.
CONCLUSIONS
A high resolution spectral estimate is necessary to dynamically adjust to market conditions. The required resolution is not available from Fourier Transforms. Cycle Finders rely on longer term correlation of several cycles and therefore do not have the agility required for dynamic adaptation. The Maximum Entropy measurement has both the required resolution and dynamic response necessary to support today's computerized trading. High quality cycle measurement has the ability to both establish trading strategy and to implement it with dynamic tactics.