BASIC program to compute "Timer's Trend" Signals
The Contrarian's View
BASIC program to compute "Timer's Trend" Signals
10 REM STOCK MARKET TUG-OF-WAR PROGRAM
20 REM recoded from VMS BASIC to Chipmunk BASIC for the Mac, January 2005
80 REM P% is the number of DJIA points per column (used to be 5)
81 REM (bug) LET P%=35
82 P%=35
90 LET Z$=" "
100 PRINT "Running....."
130 OPEN "GRAPH.TXT" FOR OUTPUT AS #2
145 LET E1=0
147 LET E11=0
150 INPUT "Exponential % (negative for historical data)? ";E1
151 IF E1=0 THEN LET E11=1
152 IF E1=-4 THEN LET E11=1
153 IF E1<0 THEN LET F1$="HISTORICAL.TXT" ELSE LET F1$="MARKET.TXT"
154 OPEN F1$ FOR INPUT AS #1
155 IF E1<0 THEN LET E1=-E1
156 IF E1=0 THEN LET E1=4
157 REM INPUT "Volume %? ";E4
158 LET E4=100
159 REM INPUT "Cutoff ";E3
160 LET E3=0
168 LET D3=20000.
178 LET X3=20000.
179 LET X13=20000.
188 LET E2=0
189 LET E8=0
190 LET E10=0
195 LET R9=0
197 LET D99=0
200 PRINT #2," Stock Market Trading Barometer"
220 LET CAP$="* - DJI ("+STR$(P%)+" POINTS PER COLUMN)"
230 PRINT #2,"# = TRADING INDICATOR"
232 PRINT #2,""
235 PRINT #2,"{, } = 4% exponential change confirmed by 10% expo in same direction."
236 PRINT #2,"[, ] = 4% exponential change unconfirmed by 10% expo."
240 PRINT #2,""
250 PRINT #2," -1 -.5 0 +.5 +1"
270 PRINT #2,"------------------------!---------------------------------------"
273 LET U=0
280 LET X=0
290 LET Y=0
300 LET B=0
305 LET D$=CHR$(124)
310 INPUT #1,L$
320 REM ON ERROR GOTO 9990 (VMS)
325 INPUT #1,L$
326 REM ON ERROR GOTO 0 (VMS)
327 IF EOF(#1)<>0 THEN GOTO 9990
330 IF LEN(L$)<25 THEN GOTO 320
333 IF INSTR(L$,CHR$(9),1)=0 THEN GOTO 340
335 PRINT "***ERROR!*** THERE IS A TAB CHARACTER IN THIS LINE:"
336 PRINT L$
337 GOTO 320
340 IF B=0 THEN LET B=P%*INT(VAL(MID$(L$,15,8))/P%)
350 LET V=0
355 LET D1=0
357 IF LEN(L$)<60 THEN GOTO 400
360 LET D1=VAL(MID$(L$,52,4))
365 LET R2=D1/VAL(MID$(L$,57,4))
370 LET D1=D1-(VAL(MID$(L$,57,4)))
380 LET D1=INT(D1*E4/100)
400 LET G$=LEFT$(L$,13)
410 LET D=VAL(MID$(L$,15,8))
420 LET V1=VAL(MID$(L$,41,4))+VAL(MID$(L$,47,4))
425 IF V1=0 THEN GOTO 480
426 LET R1=1000*VAL(MID$(L$,23,4))+VAL(MID$(L$,28,3))
427 LET R3=1000*VAL(MID$(L$,31,4))+VAL(MID$(L$,36,3))
428 LET R1=R1/R3
430 LET V2=VAL(MID$(L$,23,4))+VAL(MID$(L$,31,4))
440 LET V2=V2+(VAL(MID$(L$,28,3))+VAL(MID$(L$,36,3)))/1000
450 LET V3=VAL(MID$(L$,41,4))*(VAL(MID$(L$,23,4))+VAL(MID$(L$,28,3))/1000)
460 LET V4=VAL(MID$(L$,47,4))*(VAL(MID$(L$,31,4))+VAL(MID$(L$,36,3))/1000)
470 LET V=(V3-V4)/(V1*V2)
475 REM IF V1<40 THEN LET V=V*V1/1600
476 REM IF V2<15 THEN LET V=V*V2/225
480 PRINT LEFT$(L$,13),D,V
490 IF V<0 THEN LET V$="-"+STR$(10*(-V))+" "
491 IF V>=0 THEN LET V$=" "+STR$(10*V)+" "
500 LET V=10+INT(10*V+.5*SGN(V))-.5*(SGN(V)-1)*ABS(SGN(V))
505 IF V<0 THEN LET V=0
510 LET G$=G$+LEFT$(Z$,V+1)+"#"
520 IF LEN(G$)<35 THEN LET G$=G$+LEFT$(Z$,35-LEN(G$))
530 IF MID$(G$,25,1)=" " THEN G$=LEFT$(G$,24)+CHR$(124)+MID$(G$,26,LEN(G$)-25)
540 IF MID$(G$,22,1)=" " THEN LET G$=LEFT$(G$,21)+"."+MID$(G$,23,LEN(G$)-22)
550 IF MID$(G$,28,1)=" " THEN LET G$=LEFT$(G$,27)+"."+MID$(G$,29,LEN(G$)-28)
590 LET Z=15+V
600 LET V=INT(63.5+(D-B)/P%)
610 IF V>=36 THEN GOTO 620
612 IF V"+" THEN LET G$=LEFT$(G$,V-1)+"*"
614 GOTO 618
615 IF MID$(G$,V,1)<>"+" THEN LET G$=LEFT$(G$,V-1)+"*"+MID$(G$,V+1,LEN(G$)-V)
618 LET G$=G$+LEFT$(Z$,36-LEN(G$))
619 GOTO 625
620 IF V>35 THEN LET G$=G$+LEFT$(Z$,V-36)+"*"
625 LET S=1
627 REM ******* Bypass <, > signals, code removed for Mac......
628 REM GOTO 720
720 IF MID$(G$,36,1)=" " THEN G$=LEFT$(G$,35)+CHR$(124)+MID$(G$,37,LEN(G$)-36)
725 IF MID$(G$,36,1)=CHR$(124) THEN GOTO 728
726 IF MID$(G$,15,3)<>" " THEN GOTO 728
727 LET G$=LEFT$(G$,14)+"("+STR$(S)+")"+MID$(G$,18,LEN(G$)-17)
728 IF MID$(G$,36,1)=CHR$(124) THEN GOTO 731
729 IF MID$(G$,15,1)="(" THEN GOTO 731
730 LET G$=LEFT$(G$,32)+"("+STR$(S)+")"+MID$(G$,36,LEN(G$)-35)
731 IF MID$(G$,36,1)=CHR$(124) THEN GOTO 734
732 IF MID$(G$,36,1)<>D$ THEN GOTO 734
733 LET G$=LEFT$(G$,35)+CHR$(124)+MID$(G$,37,LEN(G$)-36)
734 IF MID$(G$,36,1)<>CHR$(124) THEN LET D$=MID$(G$,36,1)
735 IF U=0 THEN GOTO 745
736 LET F=0
737 LET M=(U+W+X+Y+Z-125)/5
738 LET V=47+ABS(INT(M))
739 IF LEN(G$)<53 THEN LET F=1
740 IF LEN(G$)=0 THEN LET G$=LEFT$(G$,V-1)+"+"+MID$(G$,V+1,LEN(G$)-V)
743 IF MID$(G$,V,1)="*" THEN GOTO 745
744 IF M<0 THEN LET G$=LEFT$(G$,V-1)+"-"+MID$(G$,V+1,LEN(G$)-V)
745 IF MID$(G$,47,1)=" " THEN G$=LEFT$(G$,46)+CHR$(124)+MID$(G$,48,LEN(G$)-47)
747 IF MID$(G$,49,1)=" " THEN LET G$=LEFT$(G$,48)+"."+MID$(G$,50,LEN(G$)-49)
748 IF V>52 THEN LET G$=LEFT$(G$,45)+"@"+MID$(G$,47,LEN(G$)-46)
749 LET U=W
750 LET W=X
760 LET X=Y
770 LET Y=Z
771 IF E11>0 THEN GOSUB 1200
772 IF E11<=0 THEN GOTO 778
773 IF D99>=0 THEN GOTO 778
774 IF MID$(G$,25,1)<>"#" THEN GOTO 775 ELSE GOTO 777
775 LET G$=LEFT$(G$,24)+"I"+MID$(G$,26,LEN(G$)-25)
776 GOTO 778
777 LET G$=LEFT$(G$,24)+"&"+MID$(G$,26,LEN(G$)-25)
778 REM go subroutine 1000 = calculate exponential signals
779 IF E1>0 THEN GOSUB 1000
780 IF LEN(G$)>48 THEN LET G$=LEFT$(G$,36)+MID$(L$,15,8)+MID$(G$,45,LEN(G$)-44)
790 IF LEN(G$)<49 THEN LET G$=G$+LEFT$(Z$,59-LEN(G$))+MID$(L$,15,8)
800 IF F>=1 THEN GOTO 804
802 IF LEN(G$)<=78 THEN PRINT #2,G$
804 IF LEN(G$)>78 THEN LET F=2
805 IF LEN(G$)<75 THEN LET G$=G$+LEFT$(Z$,75-LEN(G$))+LEFT$(V$,5)
806 PRINT G$
810 IF F=0 THEN GOTO 320
820 FOR I=48 TO LEN(G$)
830 IF MID$(G$,I,1)=" " THEN G$=LEFT$(G$,I-1)+CHR$(126)+MID$(G$,I+1,LEN(G$)-I)
840 NEXT I
843 IF RIGHT$(G$,2)="~ " THEN LET G$=LEFT$(G$,LEN(G$)-2)+"~~"
845 IF LEN(G$)<=79 THEN GOTO 850
846 IF MID$(G$,76,1)="-" THEN LET G$=LEFT$(G$,75)+" "+MID$(G$,81,LEN(G$)-80)
850 IF RIGHT$(G$,1)="*" THEN GOTO 855
852 IF RIGHT$(G$,1)<>CHR$(126) THEN LET G$=LEFT$(G$,LEN(G$)-4)
855 PRINT #2,G$
860 PRINT "---------------------------------------------------------------"
870 PRINT "DJI overflowed or underflowed, so I'm recomputing the baseline."
875 PRINT "---------------------------------------------------------------"
880 IF F=1 THEN LET B=5*INT(8+VAL(MID$(L$,15,8))/5)
890 IF F=2 THEN LET B=5*INT(-6+VAL(MID$(L$,15,8))/5)
900 GOTO 320
1000 REM exponential signals subroutine
1010 IF D3<>X3 THEN GOTO 1020
1015 IF D1=0 THEN GOTO 1190
1020 LET R9=.9*R9+(.1*LOG10(R1/R2))
1025 LET PSN%=INT(25+50*R9)
1030 IF PSN%<16 THEN LET PSN%=15
1035 IF PSN%>34 THEN LET PSN%=34
1040 REM IF MID$(G$,PSN%,1)="#" THEN GOTO 1050
1045 REM LET G$=LEFT$(G$,PSN%-1)+"@"+MID$(G$,PSN%+1,LEN(G$)-PSN%)
1050 LET D2=D3+D1
1055 LET X2=X3+INT(E1*(D2-X3)/100+0.5)
1060 IF X2>=(X3-E3) THEN GOTO 1070
1065 IF E2>=0 THEN LET G$=LEFT$(G$,34)+"["+MID$(G$,36,LEN(G$)-35)
1070 IF E11<=0 THEN GOTO 1080
1071 IF X2>=(X3-E3) THEN GOTO 1080
1072 IF E2<0 THEN GOTO 1080
1073 IF E10>=0 THEN GOTO 1080
1075 IF E8>=0 THEN LET G$=LEFT$(G$,34)+"{"+MID$(G$,36,LEN(G$)-35)
1080 IF E11<=0 THEN GOTO 1090
1081 IF X2>=(X3-E3) THEN GOTO 1090
1082 IF D9>=0 THEN GOTO 1090
1085 IF E8>=0 THEN LET G$=LEFT$(G$,34)+"{"+MID$(G$,36,LEN(G$)-35)
1090 IF X2>=(X3-E3) THEN GOTO 1100
1091 IF E2>=0 THEN LET E2=-1
1100 IF X2<=(X3+E3) THEN GOTO 1110
1105 IF E2<=0 THEN LET G$=LEFT$(G$,34)+"]"+MID$(G$,36,LEN(G$)-35)
1110 IF E11<=0 THEN GOTO 1120
1111 IF X2<=(X3+E3) THEN GOTO 1120
1112 IF E2>0 THEN GOTO 1120
1113 IF E10<=0 THEN GOTO 1120
1115 IF E8<=0 THEN LET G$=LEFT$(G$,34)+"}"+MID$(G$,36,LEN(G$)-35)
1120 IF E11<=0 THEN GOTO 1150
1121 IF X2<=(X3+E3) THEN GOTO 1150
1122 IF D9<=0 THEN GOTO 1150
1125 IF E8<=0 THEN LET G$=LEFT$(G$,34)+"}"+MID$(G$,36,LEN(G$)-35)
1150 IF X2<=(X3+E3) THEN GOTO 1160
1155 IF E2<=0 THEN LET E2=1
1160 LET X3=X2
1170 LET D3=D2
1180 IF MID$(G$,35,1)="{" THEN LET E8=-1
1185 IF MID$(G$,35,1)="}" THEN LET E8=1
1190 RETURN
1200 REM 10% exponential subroutine
1205 LET D9=0
1210 IF D3<>X13 THEN GOTO 1300
1220 IF D1=0 THEN GOTO 1390
1300 LET D2=D3+D1
1310 LET X2=X13+INT((D2-X13)/10+0.5)
1315 IF X2<(X13-E3) THEN LET D99=-1
1320 IF X2>=(X13-E3) THEN GOTO 1330
1325 IF E10>=0 THEN LET D9=-1
1330 IF X2>=(X13-E3) THEN GOTO 1335
1333 IF E10>=0 THEN LET E10=-1
1335 IF X2>(X13+E3) THEN LET D99=1
1340 IF X2<=(X13+E3) THEN GOTO 1350
1345 IF E10<=0 THEN LET D9=1
1350 IF X2<=(X13+E3) THEN GOTO 1360
1355 IF E10<=0 THEN LET E10=1
1360 LET X13=X2
1390 RETURN
9990 REM RESUME 9991
9990 IF F1$="MARKET.TXT" THEN GOTO 9995
9991 LET F1$="MARKET.TXT"
9992 CLOSE #1
9993 OPEN F1$ FOR INPUT AS #1
9994 GOTO 310
9995 CLOSE #1
9996 CLOSE #2
9999 END