5 1.00140 0.00105 +1.00
-2,00100 “3.0085 “4.0090 +5.00
  
{somason indicatorHALES LHHeHHHAAHHHEGHHHL ELGAR HEHEHE13957911111222223333344444555556666677777889889S7T9I35791357913579135791357913579135791
as80
Triangular MACD vs. MADL
 
 
 
 
Source: A. Bruce Johnson, “Finding cycles in time series data,” Technical Analysis of Stocks & Commodities, 8, no.8 (August 1990).© 1990 Technical Analysis, Inc. Used with permission.
stant @. Because the sine ranges from +1 to ~1, the new range will be +a to -@ (Figure8-6). This is written asin (ob +5). ~
There are few examples of price movement that can be represented by a single wave;thus, two sine waves must be added together to form a compound wave:
Y= Sin (M1 + By) + a2 Sin (W2 + 42)
Each set of characteristic variables, a1, ®1, 6, and @), @:, b2, can be different, but bothwaves are measured at the same point- at the same time. Consider an example that letsthe phase constants 5, and 5, be zero:196 CYCLE ANALYSIS
 
 
FIGURE 8-5 Sinusoidal wave.
 
y= asin (oo +b)
yn axis
360° /w
x —axis
 
 
 
yn =3 sin 46Jr = 5 sin 6b 'Vr tr
Figure 8-6 shows the individual regular waves y, and y2, and the compound wave y overthe interval 0° to 180°. Note that both y, and y, began the normal upward cycle at 0°; butby 180°, they are perfectly out-of-phase. During the next 180°, the two waves come backinto phase.
When combining periodic waves, it is useful to know the maximum and minimumamplitude of the resulting wave. Because the peaks of the two elementary waves do notnecessarily fall at the same point, the maximum amplitude of either wave may not bereached. A mathematical technique, called differentiation, is used to find the maximumand minimum amplitudes. The first derivative, with respect to angle $, is written dy/do ory’, where y is the formula to be differentiated. The rules are: .
XN
 
FIGURE 8-6 Compound sine wave.
 
     
Yn tH F2 © 6 sin 59
   
Von = sin 40\™
 
AMPLITUDE
5
25° 50° 75° 100° 125° 150° 175° 200°UNCOVERING THE GYCLE 197
 
S (sin 0) = cos 6; we (cos 6) =~sin 04 nos) =ab (si )) = © cos MbS (sin (@ + 4)) = @ cos (wp + 6)
a (4, Sin (Mo + by) + @ Sin (2 + b2))
= @,®, COS (Mp + B;) + 420; COS (Wz) + B2)Applying this method to the previous example,y=3sin 46 +6 sin 5o
Y _yad =y’ = 12 cos 46 + 30 cos 56
The points of maximum and/or minimum value occur when y’ = 0. For y} = 12 cos 46,the maxima and minima occur when 46 = 90° and 270° ( = 22%° and 67%) (Figure 8-6).For y; = 30 cos 5, the maximum and minimum values occur at 5 = 90° and 270° ( = 18°and 54°). It must be pointed out that the first derivative identifies the location of theextreme highs and lows, but does not tell which one is the maximum and which is the min-imum. The second derivative, y”, calculated by taking the derivative of y’, is used for thispurpose as follows:
If y’(x) = 0 and y”(x) > 0, then (x) is a minimum.If yx) = 0 and y”(x) < 0, then y(x) is a maximum.
Then, y, = 22%° and y, = 18° are maxima and y, = 674° and y, = 54° are minima.
Anyone interested in pursuing the analysis of extrema will find more complete discus-sions in a text on calculus. Rather than concentrating on these theoretical aspects ofcurves,® consider a practical example of finding a cycle in the price of scrap copper, shownin Table 8-1 and charted in Figure 8-7. The price peaks seem evenly spaced, occurring atmid-1966, January 1970, and January 1974, about 4 years apart. The solutions to theseproblems are tedious; therefore, calculations will be performed using the computer pro-grams in Appendix 4.
The results obtained by using actual copper prices will not be as clear as using ficti-tious data. It is important to be able to understand the significance of practical results andapply them effectively.
Because trigonometric curves fluctuate above and below a horizontal line of valuezero, the first step is to detrend the data using the least-squares method. This results in theequation for a straight line representing the upward bias of the data. The value of thedetrending line is then subtracted from the original data to produce copper prices thatvary equally above and below the line from positive to negative values.
The straight line y = a + 6x, which best represents the trend, can be found by solvingthe least-squares equations:
© A more specific presentation of trigonometric curve fitting can be found in Claude Cleeton, The Art of Indepen-dent Investing (Prentice-Hall, 1976, Chapter 8). The material covered in this section js carried further in thatwork,198 CYCLE ANALYSIS
 
 
TABLE 8-1 Dealer's Buying Price, No. 2 Heavy Copper Scrap at New York*
 
 
 
Average Quarterly Price (¢/Ib)Year Ist 2nd 3rd 4th1963 22.12 22.46 22.17 22.00(964 23.18 24.56 25.57 30.591965 28.23 33.77 35.90 40.051966 46.22 51.48 40.76 40.16(967 36.51 29.30 30.36 36.421968 39.75 30.07 29.08 32.131969 38.94 42.95 43.38 46.231970 47.70 46.98 35.78 27.35i971 25.40 29.45 27.15 28.481972 32.74 33.53 30.01 29.251973 36.82 45.07 55.13 65.511974 66.56 70.06 47.30 35.621975 32.06 31.46 . 35.75 36.461976 38.22 43.24 45.46 38.961977 37.08 38,72 34.01 33.00+ 1978 35.07 40.23 41.63 "44.951979 S112 63.71 59.56 63.38
 
*Based on prices from the American Metal Market.
NS ded?w5e-(Ss)a=3{S9-0 Sa]
To do this, let x be the date and y be the price on that date. For convenience, instead of let-ting x = 1967, 196714, 1967%, ..., letx =1, 2,3, .... The solution, using a computer pro-gram in Appendix 2 (also an integral part of the programs in Appendix 4) or thehand-calculation method, is
y = 28.89 + .267x
Figure 8-7 displays the original copper prices and the regression line. The original pricescan now be detrended using the equation above, subtracting the line values from the cor-responding prices. Complete step-by-step results for this example can be found in Appen-dix 4. The detrended data is now used in the general trigonometric single-frequencywave:
W=acos Of+6 sin ot — -
The variable ¢ replaces to express the angle in integer units rather than in degrees. Thiswill be more convenient to visualize and to chart.To find the frequency @, it will be necessary to first solve the equation:
1cos © — 5 Or= 0 -
using the system of equations,UNCOVERING THE GYCLE 199
—— ——  ———
ee
FIGURE 8-7 Copper prices 1963-1979.
(No. 2 heavy scrap)
 
 
Copperpricesa&8<Year2 =i +3
Ops =o + Ye
OWYn-1=In-2t In
This is expressed as a summation (similar to least-squares) in which the values for c and dmust be found: -
ay c= Sed
where c = y, and d = y,-, + Yn41. Summing the detrended values c? and cd gives ¥ c? =6338.4 and > cd = 9282.2, resulting in @ = 1.464. The value for @ is substituted into theintermediate equation and solved for the frequency :1 ~cos ® — z (1.464 =0cos ® = .732@ = 42.9
The period 7 is 360/42.9 = 8.4 calendar quarters. The last step in solving the equationfor a single frequency is to write the normal equations:
@ > cos’ wt + & > cos wt sin at = >) y,cos wt
a> sin @t cos wt+b > sintot = >" y, sin wt200 CYCLE ANALYSIS
 
and solve for a and 6, where ¢ = 1, ... , 40, and @ = 42.9. As in the other solutions, a com-puter program is best for finding the sums (using detrended data) necessary to solve theequations, The sums are
a > cos? @t Ss sin@tcosat > y, cos wt
y sin? wt y ye Sin wt
Then, @ and 6 can be found by substituting in the following equations:
> 9: sin wt S" cos’ wt ~ S° 9, cos we
S sin? wt Y cos? wt - > cos @¢ sin wt
b=
Sy cos of - 6S cos @f sin wt
2& cos ot
The results 4 = —.603 and 6 = 1.831 give the single-frequency curve as:
J = ~.603 cos 42.9¢ + 1.831 sin 42.1tTaking t = 1 to be 1967 and ¢ = 68 to be 1979% and adding back the trend, the resultingPeriodic curve is shown in Figure 8-8.
The single-frequency curve shown in Figure 8-8 matches seven out of the eight peaksin copper; however, it is not much more than could have been done using the Ehrlich
 
FIGURE 8-8 Copper prices 1963-1979: single-frequency copper cycle manually scaled toapproximate amplitude.
Price (cents/pound)
 
7 6!
8 69 70 71 72 73:74 75 76 77 78 79 80- Year
Copper prices 1963-1979UNCOVERING THE CYCLE 201
 
Cycle Finder mentioned in a previous section. A single-frequency curve can be created sim-ply by identifying the most dominant peaks, averaging the distance (period), and applyingthe single-frequency formula.
Two-Frequency Trigonometric Regression
The combination of more than one set of sine and cosine waves of varying amplitudes andfrequencies will create a better fit than a single-frequency solution, This is analogous to theuse of a second-order (curvilinear) solution instead of the first-order linear. The equationfor the two-frequency cycle is
Ys = A, COS Mt + B, Sin WM, t+ 42 COS Wot + by sin Wot
To find the results of this complex wave, apply the same techniques used in the single-frequency approach to the detrended copper data. The algebra for solving this problem isan expanded form of the previous solution, and the use of a computer is a requirement.The programs necessary to solve this one appear in Appendix 4. The frequencies @, and @,are found by solving the quadratic equation:
2x? — Ox — (1 + O/2) =0where x = cos ®, using the standard formula:
a, + Voa,? + 8(1 + o,/2)
x= 4
The same least-squares method as before can be used, derived from the general form:
O(n +Yne3) + Oz Yne1=Vn-1 t+ In+s
The least-squares equations for finding o, and @; are:> +0 > d= > epa, ed+0, > d?=S dp
where C= n+ Yn+2, 4 =Jner, and Pp =Yn-1+Jn+3- These equations can be solved for a, andQ, using:
Led e- dereyede-(Sai)Sp-e% Sed
Se
Then, w, and @, are calculated from the two solutions x, and x, of the quadratic equation.The next step is to solve the normal equations to find the amplitudes a), 6,, a2, and 6:
95
Oo
@, > cos’ wit +b, > cos Myf sin WE + a2 >) COS Mt COS Wet
+ b> COs Mf SiN Mot = Yn cos Wit202 CYCLE ANALYSIS
 
4, >" sin wit cos t+ 6, >. sin? wt + a2 >) sin @E cos Ost+h, > sin @,f Sin @2t = Yn sin Ot@, >\ COs Gt cos Wt + B1 >. COS Wat Sin Wit + a, >, COs? Ont+b, > COS Wot SiN Wat = Sn COS Wyt4, > sin wnt cos Wt +b, > sin wee sin Of + ay > sin wot cos Wat
+b, > sin’ @t = > y, sin ont
Once the sums are obtained, the final step is to create a 4 x 5 matrix to solve the four nor-mal equations for the coefficients @,, 61, 42, and b2. When plotting the answer it will be bestto plot the original two-frequency equation in its component forms as well as in combina-tion:
Ji = A, COS Mit + B, sin Mt
Yt = Gz COS Wet + bz sin Ot
Wetwhere a, = 3.635, b; =-.317, a, = —.930, and b, = .762. The solution to the two-frequencyproblem gives the following values: °
O%,=.535 2», =.830and
QO = 133 x = —.764and finally the frequencies:
O, = 33.9 and ®) = 139.8correspond to 10.6 and 2.6 calendar quarters (Figure 8-9).
Fourier Analysis: Complex Trigonometric Regression
Developed by the French mathematician John Baptiste Joseph Fourier, Fourier analysis isa method of complex trigonometric regression, which expresses any data set as a series ofsine and cosine waves of the same type as discussed in the previous section.
Assuming that there is a cycle and that there are N data points in each repetition of thiscycle, the Fourier method of analysis shows that the NV points lie on the regression curve:
 
=1u+s. 4, 5 Peet + Uy Si |PN Ee Oe aia PO ia) .where the regression coefficients 4, and v, are given by:& 2nki N= cos ——— k=1,2,...,>Me Nay oat? ay 21 2nki — ONy= sin ——— k=1,2,...,>= Buy 2 ova) 2
Ux2=0UNCOVERING THE CYCLE 203a
 
FIGURE 8-9 Two-frequency trigonometric approximation.
70
 
   
Two-frequencyapproximation
Trendline from50 linear regression
Oy e468 66 67 68 69 70 71 72 73 74 758 76 77 78 79 80 81Year (in quarters)
 
It is important to see that the mean of all the points on one cycle is equal to 1. The N val-ues of y; will have the property
NvSwanim
Applying the Fourier series to the seasonal component will help clarify this method.Seasonal data form the most obvious cycle. Using average monthly prices, detrended toavoid letting the trend overwhelm the cycle, let N = 12. It is also known that seasonallyadjusted prices will vary about the mean; hence, the weighting factors will have the sameproperty as the above equation. With this information, the trigonometric curve, whichapproximates the seasonals, can be generated and compared with the results of othermethods.” -
Spectral Analysis
Derived from the word spectrum, spectral analysis is a statistical procedure that isolatesand measures the cycles within a data series. The specific technique used is the Fourierseries as previously discussed, although other series have also been used.
When studying the cycles that comprise a data series, it is important to refer to theirPhase with respect to each other. Phase is the relationship of the starting points of differ-ent cycles. For example, if one cycle has the same period as another but its peaks and val-
7 4 continuation of this development can be found in Warren Gilchrist, Statistical Forecasting John Wiley &Sons, London, 1976, pp. 139-148); a more theoretical approach is to be fouiid in C. Chatfield, The Analysis of aTime Series: Theory and Practice (Chapman and Hall, London, 1975, Chapter 7).204 CYCLE ANALYSIS
 
leys are exactly opposite, it is 180° out-ofphase. If the two cycles are identical in phase,they are coincident. Cycles with the same period may lead or lag the other by being out-of-phase to various degrees.
A tool used in spectral analysis to visualize the relative significance of a series’ cycliccomponents is the periodogram. Weighting the cyclic components in the periodogram willgive the more popular spectral density diagram, which will be used to illustrate the resultsof the spectral analysis. Density refers to the frequency of occurrence. Figures 8-10a@ and8-10 show the spectral density of a series composed of three simple waves (D is theFourier series made up of waves A, B, and C).* The cycle length, shown at the bottom of thespectral density chart, corresponds exactly to the cycle length of the component waves A,B, and C. The spectral density, measured along the left side of Figure 8-108, varies with theamplitude squared of the cycle and the magnitude of the noise, or random price move-ments, which obscures the cycle. In Figure 8-108, the result is based on a series composedof only three pure waves. Had there been noise of the same magnitude as the underlyingcycle amplitude, those cycles identified by the spectral analysis. would have been com-pletely obscured. Readers who have studied ARIMA will recognize the similarity betweenthe spectral density and the correlogram.
As in trigonometric regression analysis, the other basic price components can distortthe results. A noticeable trend in the data must be removed or it will be interpreted as thedominant cycle. The familiar methods of first differencing or linear regression can be usedto accomplish this. The seasonal component is itself a cycle and does not need to beremoved from the series. Because spectral analysis will identify both the seasonal andcyclic components, the success of the results will depend on the strength of these wavescompared with the noise that remains. In applying this technique to real data, it would notbe surprising to see the results demonstrated in Figure 8-11. Three subcycles of length 10,20, and 40 days are shown as part of a 250-day (seasonal) cycle. Notice that, as the cyclelengthens, the width of the spectral density representation widens. This does not meanthat the wider peaks are more important.
The trader is most interested in those cycles with greater spectral density, correspondingto a larger price move. The minimum amount of data necessary to find these cycles mustinclude the full cycle that might be identified. For example, to see any seasonal pattern, a min-imum of 12 months is needed. More data is better when using spectral analysis to confirm theconsistency of the cycle. A single year is not adequate to support any seasonal findings.
Weighting FactorsThe most important part of spectral analysis is finding the proper estimators, or weightingfactors, for the single-frequency series of cosine waves. When looking for long-term cycles,it is worth being reminded that the trend and seasonal components must be removed,because the method of spectral analysis will consider these the dominant characteristics,and other cycles may be obscured.
As in the other trigonometric formulas, the basic time series notation is used, where y,,t=1,2,..., AN are the data points and #, will be the resulting estimated points on the spec-tral analysis. Then
’
1 NotPAO) = oa +2 > Ce COS ve)
hak
where
Ce
= On. -~ DOr +4 —P)=> arn
iL
* william T. Taylor, “Fourier Spectral Analysis,” Technical Analysis of Stocks & Commodities (July/August 1984).UNCOVERING THE CYCLE 205
 
 
FIGURE 8-10 Spectral density. (a) A compound wave D, formed from three primary waves, A,B, and C. (b) Spectral density of compound wave D.
soof TTrrrrtrr?s?) rt? Pt Trt475
450
425)
400
375) D
350)325300]275)250)225;20017511.ll
 
 
Price
eksas hs
aati
" 10 20 30 40 50 60 70 8090 §=110 =130Trading days
{a}
267000184000161000130000115000920005900046000.
Spectral density
29000 fl
~  o JI, a
0 10 20 30 40 50 60 70 80 90 100Cycle length
(b)
 206 CYCLE ANALYSIS
 
A
 
FIGURE 8-11 10-, 20-, and 40-day cycles, within a 250-day seasonal.z38g10 40 250 500Cycle length
 
Methods of performing spectral analysis vary due to the choice of weighting functionsthat compensate for the fact that the accuracy of c, decreases as k increases. The two mostpopular techniques for adjusting for this problem introduce an estimator A, called a /agwindow and a truncation point M < N so that the values of c, for M <k < N are no longerused and the values of c, for # $M are weighted by A,.
The spectral analysis approximation is then written:
PW) == (mc +2 S Dele COS at)
het
where A, can be either of the following:
(a) Tukey window
 
(b) Parzen windowk\ k\ M1-6{— —_ <ks—() +6(#) 0 5
32(1-4) MpcM 2
De =
Using a Fast Fourier Transform Program - -
There are computer programs that apply a Fast Fourier. Transform to perform a spectralanalysis and create a Fourier power spectrum such as the one in Figure 8-10b. AnthonyWarren’s approach’ can be found in Appendix 5 written in BASIC program code. The pro-
° Anthony Warren, “A Mini Guide to Fourier Spectrum Analysis,” echnical Analysis of Stocks & Commodities (Jan-uary 1983). A very useful series of articles on spectral analysis has been published in Technical Analysis beginningin January 1983, authored by both Anthony W. Warren and Jack K. Hutson, Much of the information in this sec-tion was drawn from that material.UNCOVERING THE CYCLE 207
 
gram detrends the data and reduces endpoint discontinuity, which can produce largeunwanted cycles. This is accomplished by multiplying the data by a bell-shaped windowand extending the endpoints to give a more definitive structure to the detrended data,without affecting the results (as discussed in the previous section).
A second filter is applied using selected moving averages. The moving average willreduce or eliminate the importance of those cycles, which are equal to or shorter than twotimes the length of the moving average, letting the more dominant cycles appear. Forexample, the use of a 10-day moving average will eliminate cycles of length less than 20days (frequencies greater than 12.5 per year). Figure 8-12 shows the output of the com-puter program.
Subsequent works by Warren and Hutson” present a computer program to calculatemoving average weighted filters using linear, triangular, and Hanning weights.
Interpreting the Results of the Fourier Power Spectrum
Both Figures 8-106 and 8-12 show a power spectrum resulting from a Fourier transform.Figure 8-106 is an ideal representation, in which the cycles stand out with no ambiguity;Figure 8-12 is more realistic, showing both the dominant cycles and a certain amount ofvariance around those values, In the power spectrum, the cycle power shown along the y-axis is the cycle amplitude squared. In Figure 8-104, cycle D peaks at a price of about 425,which yields a spectral density, or spectral power, of 180,625 when squared, correspond-ing roughly to the 40-day cycle in Figure 8-100.
Using the information from the beginning of this chapter, the frequency is the inverseof the cycle length; therefore, if the cycle length is 40 days, the frequency F = 360/40 = 9.
* anthony Warren and Jack K, Hutson, “Finite Impulse Response Filter,” Technical Analysis of Stocks & Com.modities (May 1983).
 
FIGURE 8-12 Output of spectral analysis program.
TITLE T BILLS §03/83 01/07/83FOURIER ANALYSIS OF 7-OAY MOVING AVG,9.88 Fourier N= 256 enum
427-DAY
Crees
      
T-DAY MOVING AVERAGE‘OF DAILY CLOSES (CENTERED)
'x oct NDYV DEC
Source: Jack K. Hutson, “Using Fourier.” Technical Analysis of Stocks & Commodities, |, no. 2 (anuary & February1983).© 1983 Technical Analysis, Inc. Used with permission.
 208 CYCLE ANALYSIS
 
The sine wave changeg phase at the rate of 9 degrees per day, completing one full cycleevery 40 days.
A fast method for observing the possible results is to use weekly rather than daily data.This will be a close approximation for low-frequency waves but will be less representativefor the high frequencies. Averaging the data points can yield results very similar to the dailyanalysis.
MAXIMUM ENTROPY
Maximum Entropy Spectral Analysis (MESA) is a technique that filters noise (entropy)from a time series and exposes the useful cycles;’! it provides a very practical alternative toFourier analysis that makes it possible to find cycles using a very small amount of data. Theuse of Fourier transforms requires at least 256 data points and a minimum of 16 consistentcycles of 16 bars. That would eliminate the possibility of uncovering cycles for the short-term trader.
John Ehlers describes the existence of short-term cycles as a natural phenomenon.” Itis part of the process that causes rivers to meander back and forth as water seeks to flow ina straight line, or a drunkard who walks through an alley bumping against the walls butmoving steadily forward. From these patterns, useful cycles can be found about 20% of thetime.
Using the Phase Angle
In an ideal situation, in which the market cycle can be shown as a pure sine wave, thephase angle constantly increases throughout the cycle, beginning at 0 and ending at 360°.The phase angle then drops to 0 when the new cycle begins and increases again at a con-stant rate until it ends at 360°. This repeated pattern forms a sawtooth chart, as shown inFigure 8-13. Although the cycle goes from peak to value, the phase angle moves constantlyin one direction.
In the practical analysis of short-term cycles, Ehlers compresses tick data into bars ofequal numbers of ticks, then examines the phase for uniformity. Once found, the uniformphase, which appears as a sawtooth chart, will become erratic as the short-term cycle
begins to break down, marking the end ofa current market event.x
Ehlers’s Lateral Shift in Thinking
At first glance, the use of only a small amount of data needed by MESA seems to contradictthe basic rules of statistics, which demand that results be based on as much data as possi-ble to be reliable. But Ehlers, who has been the dominant influence in cycles since about1990, is too knowledgeable to have made a mistake so simple. His book MESA and Trad-ing Market Cycles focuses on the use of short-term cycles based on short sample timeperiods. Instead, he has used this very attribute to apply cycles inside out.
Ehlers’s objective is to find very short-term cycles. By definition, these cycles must bethe result of human behavior, rather than based on market economics, because funda-mentals are not usually relevant to periods of only a few days, and they are not likely tohave a regular pattern when they make a rare appearance. If very short-term cycles exist,
‘‘ anthony Warren, “An Introduction to Maximum Entropy Method (MEM),"” Technical Analysis of Stocks & Com-modities (February 1984). See the bibliography for other articles on this topic.
* John F. Ehlers, “How to Use Maximum Entropy,” Technical Analysis of Stocks & Commodities (November1987).
"8 John F