00 70 T = 2,N-3c= C1) + DET+2)T = O(1+1)P= (1-1) + D(1+3)$C2 = SC2 + C*CSCO = SCD + CAT 7SCP = SCP + C*P$02 = $02 + T*T
70
6004
C----
100
6009
19)6010
APPENDIX 4 : 665
 
SOP = SDP + T#PALPHAZ = (SDP*SC2-SCP)/(SO2*SC2-ALPHAL = (SCP-ALPHAZ*SCD)/SC2T = SQRTCALPHAL*ALPHAL+8*(1+ALPHA2/2) )W1 = ACOS((ALPHAL+T)/4)W2 = ACOS(CALPHAL-T)/4)
WRITE(6, 60043SC2,SCD,SCP,SD2,SDP,ALPHAL, ALPHAZ,W1,W2FORMAT(/* Intermediate values:'//
  
co)
+ + SUMS C2 =", FB.1,", C*D =",F8.1,", C#P #1, F8.1+ : 02 =", F8.1,°, OP =',FB.I//" Alphal = ',F8.3+ ‘ Alpha2 =", F8.3,' Omegai =',F5.2,', Omega2 =',F5,2)
Sums for normal equations. . .to be used for matrix solutioncewi = 0CWISH1 = 0CWLCW2 = 0cWISW2 = 0YCwl = 0s2wl = 0SWICH2 =SW1SW2 =YSWl = 0c2w2.~ 0CW2SW2 =ycw2 = 0S2Ww2 = 0YSW2 = 0
00 100 I = 1,NOl = DCI)SW1 = SINCWI*I)CWl = COS(W1*I)SWZ = SINCW2*1)Cw2 = COS(W2*1)C2W1 = C2W1 + CW1*SWiCWLSW1 = CWISW1 + CWI*SWICW1CW2 = CWICW2 + CW1*CW2CWLSH2 = CW1SW2 + CW1*SW2 -yCW = YCWi + DI*CWLS2Wi = S2W1 + SW1*SW1SWICW2 = SWISW2 + SW1*CW2SWISW2 = SW1SW2 + SW1*SW2YSW1 = YSW + DIC2W2 = C2W2 + CW2*CW2CW2SW2 = CW2SW2 + CW2*SW2YCW2 = YCW2 + DI*CW2S2W2 = S2W2 + SW2*SW2YSW2 = YSW2 + DI*SW2
- Duplicate calculations for matrix
DUPL = CW1SW1
oup2 = CHICW2OUP3 = SW1CW2OUP4 = CWISW2OUPS = SWISW2ouP6 = CW2sH2
WRITE(5, 6009)
FORMAT(/' Coefficient matrix: '/}
00 110 i = 1,NDiM~WRITECS ,6010)(ACE,J) ,J=2,4),8¢1)FORMAT(5F8.3)APPENDIX 4
 
666
C---- Solve using matrix Gaussian EliminationCALL MTX(A,B,NOIM)
C++-- Solution vector
WRITE(6, 6011) (B( 1), 1=1,NOIM)FORMAT(/' Solution vector: '/4F8.3)Values of fitted curve using detrended datado 90 1 = 1,N90 R(T) = AL*COSCWI*I) + BI*SINCWI*I) + AZ*COS(H2*I) ++ B2*SIN(W2*T)WRITE(6, 6006)6006 FORMAT(/* Trigonometric regression results using detrended data’,+ rP)00 105 1 = 1,N,4105 WRITE(6,6001)1,(R(J),J=I, 143)
C--+- Add trend back to resultDo 115 T= 1,N115. R(T) = R(1) + ALIN + BLIN*E
WRITE(6, 6007) .6007 FORMAT(/’ Final results with trend added back'/)DO 120 1 = 1,N,4120 WRITE(6,6001)1,(R(J),0=1,1+3)
CALL EXIT
ENO
SUBROUTINE MTX(A,C,N)
Matrix solution to simultaneous linear equationsCopyright 1986 PJ Kaufman
DIMENSION AC4,4), C(4), AL(4,4), C1(4)
Process row by row (Gaussian Elimination)do 100 I = 1,NOly = ACI)
DO 40 J =1,N40 ACL,O) = ACL) /01V -Cory = C(E)/OIV
 
 
 
C---- Zero cut column I for each rowDo 60 J = 1,NIF(J.£0.1)GOTO 60FACTOR = ACJ, 1)0 50 K = 1,N
50 AGI,K) = ACI,KD - ACT, K)*FACTOR- C(d) = C(3) + CCE)*FACTOR60 CONTINUE100 CONTINUERETURN _END - -2-Frequency Trigonametric RegressicnTime Prices1 22.12 22.46 22.17 22.00
5 23.18 24.55 25.57 30.599 28.23. 33.77 38.99 40.0513 46.22 $1.48. 45.76 40.1617 36.51 29.30 30.36 © 36.42ar 39.75 30.07 29.08 32.13
 
 
APPENDIX 4 66725 38.94 42.95 43.38 46.2329 47.70 46.98 35.78 = 27.3533 25.40 29.45 27.15 28.4837 32.74 33.53 30.01 29.2541 36.82 45.07 55.13 65.5145 66.56 70.06 27.30 35.6249 32.06 31.46 35.75 36.4653 38.22 43.24 45.46 38.9657 37.08 38.72 34.01 33.0061 36.07 40.23 41.63 44.9565 51.12 63.71 59.56 63.38
Linear regression results: A =
Detrended data-7.04
1
5
91372.252g333741454953576165
1
1ol
“6
2
9
-10
7.0333
5
06-86.08
5.25
3.3)
?
1.06
2,3
36
47
1
+040265392 —830412
4786
28.-10.
6.96
93
2.21
85
4.40
+70
7.11
07
8.52-5.514.96
 
8879os
-5.67
7517.
+231g
Intermediate values:
SUMS C2 = 17396.7,6126.9,
Alphal = .151, Alpha2 = .898, Omegal
02 =
Coefficient matrix:
34.206 790 ~ 461 426.790 33.794 - 454 2479
-.461 “454 33.742 >.7812426 1479 =.781 34.258
Solution vector:
3.635 -.317 ~.930 762
Trigonometric regression results using detrended deta1 4.29 -84 69 -1.20
5 3.72 2.38 4.57 -2.18
9 -1,06 -.43 3.23 2.12
13000 4.21 3.45 1.39 1.82
17 -2.17 1,93 -3.36 9 -4,29
210 -1.80 0 -2.78 671.72
2500 2.23 4.76 Bd
29 1.05 1.95 -1.09 | -4.45
33° -+2.90 3.25 2.67 «70
37 (1200 3.490 BAL 2.97
4h 3.97 127 689 -2.04
45 3.68 2.57 -4.56 “1.50
 
07866169628139“11.09-9.3014.75“14.25-6.771.87-10.64-4.0912.77
52219
 
+7.96
+144
9500
19A?86-0903
338610=32-8992046.32
28.889, B = .267
C*O = 8753.0, C*P = 10475.1O*P = 5499.2
47, Omega2 = 2.52
124.829-7.036-33.50028.219sere
 
 
: 668 APPENDIX 4 APPENDIX 5! soe 38 oe a“3 53 4.54 9 2.79 1.38 1.203 $7 -2.70 “2.91 -3.91 -3.91 . .: a1 168248 Lad 189 Fourier Transformationik 65 2.86 4.60 2.08 3.19{ a Final results with trend added backi 1 33.44 30.26 30.38 28.752 3 6 : 3 a i 3 : be ae 3 The original computer program that solves the Fourier transformation as described by Jack13 36.58 36.08 34.29 34.98 Hutson and Anthony Warren (Technical Analysis of Stocks & Commodities) is based on theV7 31.26 31.77 30.61 29.85 Cooley-Tukey Fast Fourier Transform Algorithm (1965), developed at the IBM Thomas J.j 21 32.71 31.99 38.70 37.02 Watson Research Center. A full explanation of this program and its interpretation can be25 37.80 40.60 38.42 39.61 found in the two articles that appeared in the January 1983 edition of Technical Analysisk 29 37-89 38-36 3608 of Stocks & Commodities, then reprinted in the September 1986 issue.4 3 3 3 aeisa ane a2 The following program appeared in the September 1986 issue of Technical Analysis of: 41 43.76 40.38 40.97 38.60 Stocks & Commodities. It was written by John Ehlers and appended to the article “A Com-{ 45 37.26 38.61 36.89 40.22 parison of the Fourier and Maximum Entropy Methods.”49 40.93 42.63 45.96 44.9853 47.89 46.11 44.96 45.06 FAST FOURIER TRANSFORM PROGRAM. 61 43.50 43.01 47.16 47.68 10 REM “FAST FOURIER TRANSFORM"65 49.12 51.13 48.87 $0.25 20 REM FOR APPLE J{ WITH 2 DISKS USING
i 30 REM DATA IN CSI OR COMPU-TRAC FORMAT40 REM BY JOHN F, EHLERS45 REM COPYRIGHT (CY 1986 BY TECHNICAL ANALYSES, INC.~ 50 HOME60 DIM DFS«20)70 HTAB S: INVERSE : PRINT ** FAST FOURIER TRANSFORM *"NORMAL- 71 HTAB 19: PRINT "BY"72 HTAB 14: PRINT “JOHN EHLERS"73 HTAB 16: PRINT "BOX 1801774 HTAB 12: PRINT "GOLETA, CA 93116": PRINT80 LET O$ = CHRS(4)90 PRINT D$ + “OPEN MASTER,L40,02"- 100 FOR I = 1 TO 20
| : 57 41.42 42.87 40.75 41.01ii||i
110 PRINT OS + "READ MASTER,R"31
120 INPUT DFS(I)
130 IF LEFTS (DF$(I},5) = "99999" GOTO 150140 NEXT I
150 PRINT O$ + “CLOSE”160 FOR J = 1 TO I-1170 PRINT "<"; CHRS (J +64); ">"; MIDS (OFS(J),4,16)~ 180 NEXT J
190 PRINT "<V> VIEW NEW DATA DISK"
200 PRINT "<X> EXIT TO MENU": PRINT -
210 PRINT " SELECT <>": CHRS(8); CHRS(B); -
: 220 POKE - 16368,0: GET X$: PRINT X$; ">"; CHRS(B); CHRS(8);. . 230 IF XS = "Vy" THEN. HOME : VTAB 10:
PRINT "INSERT NEW OATA DISK IN ORIVE 27PRINT: PRINT "PRESS";: INVERSE: PRINT "RETURN" |:NORMAL: PRINT "TO CONTINUE": VTAB 22POKE - 16368,0: GET S$: GOTO 30
240 fF X$ = 7K" THEN HOME
- - 250 LET SF = ASC (XS) - 64
260 IF SF > 1 ANO SF <~ J - 1 THEN 290
270 HTAB 13: PRINT "*: CHRS(8);: GOTO 220
280 IF K < 120 OR K > LR THERPRINT "OOPS ~ RUN AGAIN": END
  
 
670
230300
310326330340350360
370380390
400410420430440450460
470
480490500
510520530540550560570
580
590600610620
630640650660670680690700
719720730740
APPENDIX 5
HOME : VTAS 10: INVERSE: PRINT MIDS (DFS(SF),4,16):
NORMAL: PRINT: PRINT
PRINT: PRINT DS + "OPEN" + MIDS (OFS(SF),4,16) + *,L40":
PRINT DS + "READ" + MIDS (DFS(SF),4,16) +", RO":
INPUT XS: LET LR = VAL (X$)
PRINT DS + "CLOSE"
IF UR < 32 THEN 370
IF LR < 1024 THEN 410
PRINT "CONTAINS"; LR; " RECORDS"
PRINT "A MAXIMUM 1024 RECORDS ARE ALLOWED": PRINT
PRINT "PRESS";: INVERSE: PRINT “RETURN";: NORMAL:
PRINT " TO CONTINUE": VTAB 22
PRINT "CONTAINS ONLY"; LR; “RECORDS”
PRINT "AT LEAST 32 RECORDS ARE REQUIRED": PRINT
PRINT “PRESS";: INVERSE: PRINT “RETURN";: NORMAL:
PRINT "TO CONTINUE": VTAB 22
POKE - 16368,0: GET S$: HOME: CLEAR: GOTO 20
PRINT "CONTAINS "; UR; " RECOROS": PRINT
PRINT “ENTER ONLY 32, 64, 128, OR 256"
PRINT "FOR ANALYSIS. THIS NUMBER MUST BE*
PRINT "LESS THAN THE FILE LENGTH.": PRINT
INPUT "RECORDS FOR ANALYSIS? *; N
IF (N= 32 OR N= 64 OR N = 128 OR N = 256 OR N ~ 512)ANON < LR THEN 480
PRINT: PRINT "OOPS -- RUN PROGRAM AGAIN": END
DIM DAS(1024), F(1024), AC257,8)PRINT: PRINT DS + “OPEN* + MIDS (DFS(SF),4,16) + *,L40"FOR [= 1 TO NsPRINT DS + "READ * + MIOS (DFS(SF),4,16) + "JR";(LR = Nf): INPUT DAS(ID:NEXT 1PRINT DS + *CLOSE*REM *** DATA CONVERTER ***IF MIO$ (DA$(1),23,5) <> "99999" THEN 550LET DAS(1) = DAS(2)FoR f= 1 TONLET FCI) = VAL (MIDS (DAS(I),23,5)) .IF MED$ (DAS(I),23,5) = "99999" THENLET F(T) = F(L - 1DNEXT 1
 
 
 
 
REM *** SPECTRUM ANALYSIS ***LET PI = 3.1415926LET PO = INT (N / 4): LET SO= 8FOR 1 = 1 70 RO + i: -FOR J = 1 TO 8: LET ACT,J) = O: NEXT J:NEXT 1FOR I = 1 TO RO -For J = 1 TO SO STEP 2LT K=4* (1-1) + .5* (+) -LET ACE,J) = FCK)LET ACI,d #1) = 0NEXT JNEXT ELET M= LOG (NM) / LOG (2): LET NZ =N/ 2:LET ND = NN - Ee ler J =1FoR 1 = 170 NI -IF 1 > J THEN 850LET RR = INT (CO - 2 @)LeT S = 2*9-B8*R
APPENDIX 5
67t
 
750 LET RL = INT ((L = 1) f 4)760 LET SL=2*1-8* RL770 LeT RD = R141
780 LETR = R41
790 LET T = ACR,S)
800 LET ACR,S) = ACR1,S1)810 LET A(RI,S1) = T
820 LET T = ACR,S - 1)
830 LET ACR,S - 1) = ACRI,ST - 1)840 LET A(RI,S1 - 1) =T
850 LET K = N2
860 IF K > J THEN 910
870 leTy =a -K
880 LET K = Ks 2
890 GOTO 860
900 NEXT I
910 LeT J =a +K
920 NEXT L
930 LET LO = 1940 FOR L = 1 TOM
950 LET Ll = LO
960 leT LO = 2 * LO
970 leT Vv =2
980 LET W = 0
990 cer Z = PL Ui
1000 LET WL = COS (2)
1010 LET W2 = SIN (Z)
1020 FOR d= 170 LL
1030 FOR 1 = J TON STEP LO
1040 leT K = 1+ U1
1050 LET R1-= INT (CK = 1) / 4)
1060 lef S1=2*K-8* RI
1070 LET RI = RL +1
1080 LET Al = ACRL,SI - 1)
1090 LET 81 ~ ACR1,S1)
1100 leT T = Al * Vv - BI *W
1110 LET U = AL * W+ BL * V
1120 LET R = INT (CI = 10/4)
1130 ueTS -2*+1-87R
1140 LETR = R41
1150 LET ACRI,S1 - 1) = ACR,S - 1) - T
1160 LET ACR1,S1) = ACR,S) ~ 0
1170 LET ACR,S - 1)  ACR,S = 1) + T
1180 LET _ACR,S) = ACR,S) + U
1190 NEXT I -
1200 LET U= Ve WL WW?
2210 LET W= Vv * W2 + W* WL
1220 - LET V=U
1230 NEXT J ~
1240, NEXT L
1250 LET Z = ~ 166 ~
1260 FORT = 1TO RO/ 2 -
1270 FoR J = 1 TO SO STEP 2
1280 If [= 1 ANO J ~ 1 THEN 1310
1290 LET A(T,J) = SOR (A(T,J) * ACTS) # ACE, + 1) +ACJ +1)
1300 IF A(T,J) > 2 THEN LET 2 = ACEO)
1310 NeXT J -
1320 NEXT T
1330 HOME: PRINT "SPECTRUM FOR" + MIDS (OFS(SF),4,16) 
 
672 APPENDIX 51340 PRINT -
1350 PRINT “PERIOD RELATIVE AMPLITUDE"
1360 PRINT "(DAYS) (08)": PRINT
1370 LET K = 01380 FORT = 1 TO RO/ 2
1400 FoR J = 1 TO SO STEP 21410 IF = 1 AND J = 1 THEN 14601420 LET L = INT (N/K + 225)1430 If L +1 > P THEN 14601440 LeT P=1450 PRINT TAB( 2): L; TAB( 16);INT (1000 * LOG (A(I,d) / 2) / LOG (103) / 1001460 LeTK = K+ 11470 NEXT 31480 NEXT I
PROGRAM LENGTH: 152 LINES/3304 BYTES
 
APPENDIX 6Heenan ee ee eee
Construction of a Pentagon
CONSTRUCTION OF A PENTAGON FROM ONE FIXED DIAGONAL
Establish the diagonal D by connecting the top and bottom of a major price move by astraight line. This diagonal will be toward the left and top of the pentagon to be con-structed (see Figure AG-1).
1. Measure the length of the diagonal D. This diagonal connects two points of thepentagon.
2. With the point of a compass at one end of the diagonal and the tip on the other,draw a long arc to the right; placing the point on the other end of the diagonal,draw another arc to the right. These arcs should not cross to avoid confusion.
3. The length of a side of a regular pentagon is calculated from the diagonal by theformula
S=.618xD
Using a ruler, set the compass to the length of a side and place the point at one endof the diagonal. Draw an arc on both sides, crossing the arc on the right; do thesame for the other end of the diagonal. The two new arcs will cross on the left. Thethree new crossings are the missing points of the pentagon.
 
  
674 . APPENDIX 6
4, The center of the pentagon ean be found by bisecting any two sides. The point atwhich the two bisecting lines cross is the center. Use this point to circumscribe a cir-cle around the pentagon.
CONSTRUCTION OF A PENTAGON FROM ONE SIDE
Establish the side § by connecting the top and bottom of a major price move with a straightline. As in the previous example, this side will be toward the top and left of the pentagon,which will extend down and to the right (see Figure A6-2).
1. Calculate the length of the diagonal D by applying the formula D = S/.618. This willrequire a ruler to determine the length of S.
2. Using a ruler again, set your compass to the length of the diagonal calculated in the
first step. Draw wide arcs of radius D from the endpoints of S crossing to the lower
right of S. The place of crossing will be the third point of the pentagon P,, opposite
side S.
Set the compass back to length 5 and place the point at Ps. Cross the inner arcs
drawn in step 2 with a small arc drawn on either side of P. The place of crossing will
be the two remaining points of the pentagon.
4. The perpendicular bisectors of any two sides will cross at-the center of the penta-gon and allow you to circumscribe a'circle around the pentagon.
y
EEFIGURE A6-2_ Construction of a pentagon from one side.
f
 
APPENDIX 6 - 675
 
The perpendicular bisector of any side is constructed by setting the compass to anylength greater than half of the line being bisected, then placing the point at one end ofthe line. Draw an arc on both sides of the line in the area above the center of the line. Dothe same by placing the point of the compass at the other end and crossing the arcsalready drawn. A line through the two crosses will be the perpendicular bisector of theoriginal line.a
Bibliography
‘Aan, Peter W. “How RSI Behaves.” Futures (January 1985).
‘Abraham, Bovas, and Johannes Ledolter. Statistical Methods for Forecasting. New York,NY: John Wiley & Sons, 1983.
Achelis, Steven B, Technical Analysis from A to Z. Chicago, IL: Probus, 1995.
‘Ainsworth, Ralph M. Profitable Grain Trading. Greensville, SC: Traders Press, 1980 (origi-nally 1933).
‘Altman, Roger. “Tactical Trading Revisited.” Technical Analysis of Stocks & Commodities,(September 1993).
Andrews, WS. Magic Squares and Cubes. New York, NY: Dover, 1960.
Angas, L.L.B. Investment For Appreciation. New York, NY: Somerset, 1936.
‘Angell, George. “Thinking Contrarily” (an interview with R. Earl Hadady). CommoditiesMagazine (November 1976)
Angell, George. Winning in the Commodities Markets. New York, NY: Doubleday, 1979.
Anon, Louis J. “Catch Short-Term Profits with ARIMA.” Commodities Magazine (December1981).
Appel, Gerald. Winning Market Systems: 83 Ways to Beat the Market. Great Neck, NY: Sig-nalert, 1974. ~
, and Martin E. Zweig. New Directions in Technical Analysis. Great Neck, NY: Sig-nalert, 1976.
Arms, Richard W, Jr. “Equivokime—A New Method of Charting.” Commodities Magazine(April 1973) _
Aenold, Curtis M. The Personal Computer Can Make You Rich in Stocks and Commodities.‘West Palm Beach, FL: Weiss Research, 1980 (published in hardcover 1984). ~
“Tracking ‘Big Money’ May Tip Off Trend Changes.” Futures (February 1985).
_ “Your Computer Can Take You Beyond Charting.” Futures (May 1984).
Aronson, David R. “An Introduction to Computer-Based Pattern Recognition." Financialand In