Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Stocks & Commodities V.

2:3 (91-93): SIDEBAR: Programming Conventions for BASIC Technical Analysis subroutines:

Programming Conventions for BASIC Technical


Analysis subroutines:
NO Input/Output routine is provided, only a generic BASIC computational subroutine containing the
fundamental technical analysis is provided. This subroutine should, with only minor changes, work on
any computer using the BASIC language.
INPUT data {daily, weekly, monthly, etc.) must be provided by the user (i.e. YOU} in the following
matrix format: X(7,NUM) where
NUM= Number of days in the Matrix
X(0,NUM) = Date Optionally used to store the date
X(1 ,NUM) = Open Mean open trade price for the day
X(2,NUM) = High Highest trade price for the day
X(3,NUM) = Low Lowest trade price for the day
X(4,NUM) = Close Last trade or bid price for the day
X(5,NUM) = Volume Number of shares or contracts traded
X(6,NUM) = Open Interest Total contracts or optioned shares
X(7,NUM) = STUDY Last STUDY results stored here
B = Beginning First day of Matrix (usually = 1)
E = Ending Last day of Matrix (usually = NUM)
OUTPUT are usually in the STUDY column X(7,NUM) at the end of the subroutine. NO printing or
graphics is provided of the subroutine output.
1100 REM "MOMENTUM OSCILLATOR OF TRIPLE
EXPONENTIAL SMOOTHED DATA"
BY JACK K. HUTSON
COPYRIGHT (C) 1983, 1984
TECHNICAL ANALYSIS, INC.
1105 LET T$ = "TRIX":
REM STUDY TITLE
1110 LET P(6) = 1:
LET P(7) = 0:
REM DRAW A REFERENCE BASE LINE AT ZERO
1115 LET Y = 10000:
REM ARBITRARY OUTPUT SCALE FACTOR
1120 LET P$ = "1:0 2:H 3:L 4:C 5:V 6:0I 7:S :" :
GOSUB 1165:
ON NOT (N = 1 OR N = 2 OR N = 3
OR N = 4 OR N = 5 OR N = 6 OR N = 7) GOTO 1120:
REM ADJUST MATRIX COLUMN LENGTH TO TRUNCATE LEADING AND TRAILING
ZEROES
1125 FOR I = B TO E:
ON X(N,I) < > 0 GOTO 1135:
LET B = B + 1:

Article Text Copyright (c) Technical Analysis Inc. 1


Stocks & Commodities V. 2:3 (91-93): SIDEBAR: Programming Conventions for BASIC Technical Analysis subroutines:

NEXT
1135 FOR I = E TO B STEP - 1:
ON X(N,I) < > 0 GOTO 1145:
LET E = E - 1:
NEXT
1145 LET G = N:
LET T = LOG (X(G,B)):
LET U = T:
LET R = T:
LET Z = T:
REM SEED INITIAL ITERATION VARABLE S
1150 LET P$ = "1:ALPHA 2:FILTER 3:CUTOF F FREQ :" :
GOSUB 1165
1151 IF N = 1 THEN
LET P$ = ALPHA SMOOTHING CONS
TANT (0 TO 1) : " :
GOSUB 1165:
LET K = N:
GOTO 1160
1152 IF N = 2 THEN
LET P$ = " FILTER LENGTH IN DAYS : " :
GOSUB 1165:
GOTO 1155
1153 IF N = 3 THEN
LET P$ = CUTOFF FREQUENCY IN CYCLES/YEAR : " :
GOSUB 1165:
LET C = (1 - COS (N * 0.024166)) / 0.25992:
LET K = C * ( SQR (1 + 2 / C)- 1 ) :
GOTO 1160
1154 GOTO 1150:
REM BAD N VALUE
1155 LET K = 2 / (N + 1):
REM K = ALPHA APPROXIMATION ALGORITHM
1160 FOR I = B TO E:
LET R = ( LOG (X(G,I)) - R) *
K + R:
LET T = (R - T) * K + T:
LET U = (T - U) * K + U:
LET X(7,I) = (U - Z) * Y:
LET Z = U:
NEXT :
RETURN
1165 VTAB 2:
HTAB 1:
PRINT P$;:
INPUT " " ;N:
RETURN
PROGRAM LENGTH: 16 LINES / 1035 BYTES

Article Text Copyright (c) Technical Analysis Inc. 2

You might also like