24 through 260 over the 10-year period (from2.5 per year to 1 every 2 weeks). The table shows that the simple moving average was muchbetter and the N-day breakout much worse. Total results were better, showing that the fasttrends were big losers. This is particularly true of the smoothing methods.
A Different View of Results
The average results give a reasonable picture of performance, but it is clear that each typeof system has a different distribution of trades. For example, doubling the swing percent-
—_—_—_—_—_—_—_—_TABLE 5-4 Average Returns
 
 
 
 
MA EXP LRS SWG P&F NDAY AvgED 210 140 19 160 105, 27 169Us 108. 72 17 24 6 123 48DOM 133 95 441 16 al 106 cySP 57 44 66 -24 -27 49 4OEX -35 -23 29 -12 -I7 7 -21ch 135 112 47 -18 30 152. 66sy 16 -l4 108. 39 47 78 45Avg 73 48 48 20 22 7 StThe merge ofall tests gives a better picture of the robustness of the systems and the trendiness of the markets. Each value is «!10-year risk-TABLE 5-5 Average Returns for Tests with 24-260 TradesMA EXP. LRS SWG - PRE NDAY AvgED ~ 276 196 127 220 - 175 309 217us 153 i 26 13, L 27 28 59DM 192 139 285 -1 < 123 57 132sP “4 31 60 -18 48 80 47Ox aH 2 tH 18 ! 46 8cL 196 165 153 13 16 215 421sy _ 47 22 14 53 93 69 27Avg 116 86 76 43 St 59 Tn.
ooBy limiting the test periods to a more popular range, we see that the simple moving average is eBy nrg range, simple moving average is best, although the markets perform relatively
 
 
COMPARISON OF MAJORTREND SYSTEMS 107
age does not reduce trades as quickly as doubling the days in the N-day breakout. Thiscauses the average results of the two systems to be biased differently toward faster orslower trends. This is corrected by comparing the systems when they have the same num-ber of trades.
Aligning Test Results GraphicallyFigure 5-6 shows the Eurodollar results when we attempt to align each of the six systemsby their test periods. The patterns are similar, but somewhat out of phase. This is especiallytrue for the breakout systems. By displaying performance of all systems by total trades,shown in Figure 5-7, we see a steady decline from left to right. As the number of tradesincreases, profits disappear. ; ,
We can conclude that trending systems, in general, are a robust trading vehicle forEurodollars, but only if we apply a longer time horizon. The patterns clearly show thatincreasing trades result in overall losses. This should be a very comforting conclusion forsystems traders.
Programming the Six Systems
Omega Easy Language Code
A general systems approach to programiming TradeStation's Easy Language bas beentaken in this example. The strategies are written as User Functions rather than systems.This adds flexibility and allows us to use the same programs at another time. A User Func-tion is a small program or subprogram that can be referenced (called) from other pro-grams. This shared program saves you from repeating the rules and calculations for each
new program. .
FIGURE 5-6 Eurodollar results by test period. The rising pattern of profits from left to rightis not clear because of the difficulty in aligning the test period, in days, with the swing size, inpercent.
Eurodollar: risk-adjusted retumsAll systems by test period
 
88
8T
;
8T
x8T
38T
 
Risk-adjusted retums (% drawdown)
 
   
 
 
A80
4 8 16 32 50 75 100 150 200Faster ... PERIOD ... Slower
—e-MA  —@- EXP LAS I SWG O PAF V— NDAY 
108 TREND SYSTEMS
|
 
FIGURE 5-7 Eurodollarresults by total trades. Plotting all systems by total trades (thebottom scale) shows a clear drop in performance as trading becomes more frequent.
 
Eurodollar: risk-adjusted returns
 
 
 
 
 
All systems by total trades -
€ 600
3 7
2 500
ie
& 400 | o
2 % °
§ 3000,
3 6 _ Vv
B 201" Yo oe
g ve on ®
3 100 o® 5 0 9
x e nH
a v
Zz ojo-™ oe
“00 ; on is .0 100 200 300 400 500 600
Fewer ... TRADES ... More
™ MA @ EXP Vv LRS o swe © Par v NDAY
 
The following User Functions perform the unique calculations for each of the sixstrategies, and return the value
signal = 0, no position= 1, buy or hold long position
 
-1, sell or hold short position
Note that the final statement of the User Function sets the User Function name equal to thevalue of the signal. Bach program also references a variable type, which indicates that themarket being processed is, or is not, an interest rate.
type = 0, default, 3-month interest rate (e.g., Eurodollars, Matif Pibor, Short sterling)
 
, long-term interest rate (e.g,, U.S. T-bonds, T-notes, U.K. Gilt, German bund)
SystemAsystem has buy and sell orders, equity calculations, and other statistics. Parameter valuescan be set from the appropriate menu. Our systems will reference a User Function to find ~the signal for each strategy. Because each of the systems would be identical, except for theone fine that calls the user function, only one system is shown.
   
IndicatorAn indicator is a program that displays the value of key points or calculations on a chart.An indicator can position the high and low points of a swing (Kswing) or show a separategraph on a split page (KLRS).{KMA : Moving Average User Function -
Copyright 1994-1998, P J Kaufman. All rights reserved.)
COMPARISON OF MAJOR TREND SYSTEMS 109——eeoeseS
(period = length of moving average trendfilter = whole % trend change to give signal
lag = 0 to enter on close, n to enter n-days later
)
input: period(numericsimple), filter(numeric), lag(numericsimple);vars: ma(0), change(0), signal(O);
signal = signal[1];
{moving average for testing anticipation}
ma = @Average(close, period);
change = (ma - maC1))*100/closeL1};
(long signal}
if lag >= 0 and change{lag]>filter then signal=1;{short signal}
if lag >= 0 and change{lagi<-filter then signal=KMA = signal;
 
(KEXP exponential User FunctionCopyright 1994-1998, P J Kaufman. All rights reserved.}
{period = length of exponential trendfilter = whole percent trend change to give signaljag = 0 to enter on close, n to enter n-days later
tinput: period(numericsimple), filter(numeric), lag(numericsimple);
vars: exp(0), change(0), signal(0);
signal = signal{1];(Exponential smoothing for testing anticipation)Exp = @SmoothedAverage(close, period);
change = (Exp - Expf1})*100/close(1];,
(long signal)
if lag >= 0 and change(iag]>filter then-signal=1;{short signal]
if lag >= 0 and changeLlag]<-filter then signal=KEXP = signal;
(KLRS : Linear Regression Slope User FunctionCopyright 1994-1998, P J Kaufman. All rights reserved.Method of least squares to calculate slopel
Inputs: period(numericsimple);
vars:  sumx(O), sumx2(0), sumy(O), sumxy(0), m0), k(O), top(O), bot(O),slope(0), yint(0);
 
{Time = x, the independent variable, e.g., 1, 2, 3,...Close = y, the dependent variable}
{standard sum of integer series}sumx = period*(period+l) / 2;sumx2 = period*(period+l)*(2*period+1) / 6;sumy = @summation(close,period);sumxy = 03n = period;for k = 0 to period-1 beginsumxy = sumxy + n¥closetk];n=n-1;end;top = period*sumxy - sumx*sumy;bot = period*sumx2 - sumx*sumx; .if bot<>0 then slope = top / bot;{yint = (sumy ~ slope*sumx) / period;)KLRS = slope; 
110 TREND SYSTEMSIKLRSignal : Linear Regression Slope signal User FunctionCopyright 1994-1998, P J Kaufman. All rights reserved.)
{period = length of exponential trend
filter = whole % trend change to give signal
}
input: period(numericsimple), filter(numeric), lag(numeric);vars:  slope(0), signat(0);
 
(Call linear regression slope User Function}slope = KLRS(close, period);
signal = signal(ll;
{long signai : slope is up by more than filter}if lag >= 0 and slopeLlag]>filter then signal = 1;(short signal : slope is down by more than filter}if lag >= 0 and slope{lag]<-filter then signal =KLRSignal = signal;
 
 
({KNDB : N-Day Breakout User FunctionCopyright 1994-1998, P J Kaufman. All rights reserved.)
{INPUT for N-day Breakout System signal rules:BUY when high is above N-day high and close > prior closeSELL when low is below N-day low and close < prior close)
input: period(numeric);vars: nhigh(0), nlow(O), signal(0);
nhigh.= highest(high{1],period - 1);
nlow = lowest(lowl1],period - 1);
(Buy and sell signals)
signal = ‘signal(1];
if high > nhigh and close > close{1] then signal = 1if low < nlow and close < closef1] then signal =KNOB = signal;
  
{KSWG : User Function to determine swing direction and new swing highs or lowsCopyright 1994-1998, P J Kaufman. All rights reserved.){INPUT for KSWGswing in whole percentdirection & breakout: *
+1 up, +2 up breakout
0 none
-1 dn, -2 dnbreakouttype : 0= normal, 1= 3 month rate, 2= bondsignal rules:
buy when upswing is above prior upswing
sell when downswing is below prior downswinginput: swing(numeric), type(numericsimple);vars: minswing(0), last(O) , curhigh(0) , curlow(O), swhigh(O), swlow(0),swingdir(0), signal(0);
 
 
minswing = swing*close/100; -
if type=1 then minswing = swing*(100 - close) / 100
if type=2 then minswing = swing*(8./close) -
{SWINGS: Initialize most recent high and low
if (currentbar = 1)then begin gcurhigh = close; (cuPrent high}curlow = close; {current Tow}end; -
~iSearch for a new hight
if last<>1 then begin
 
COMPARISON OF MAJOR TREND SYSTEMS iw
if high > curhigh then curhigh = high; {new current high)if low < curhigh - minswing then beginlast = 1; (last high fixed)swhigh curnigh; {new verified high)curlow = low; (initialize new lows}end;end{Search for a new low!else beginif last <> -1 then beginif low < curlow then curlow = low;if high > curlow + minswing then beginjast = -1;Ww = curlow;curnion = high; (initialize current highend;end;end;(Buy and sell signals}signal = signal(l];swingdir = 05 ;if last = 1 then beginswingdir = -1;if curlow < swlow then signal = -15end; .if last = -1 then beginswingdir = 13jf curhigh > swhigh then signal = 1;end;KSWG = signal;
: i ‘igure User Function ©eee yiigne 1994-1998, PJ Kaufman. All rights reserved.)(INPUT for KMA_PF_System, swing in whole percentdirection & breakout:+1 up, +2 up breakout0 none-1 dn, -2 dnbreakouttype : O= normal, l= 3 month rate, 2= bondsignal rules: ;buy when upswing is above prior upswingsell when downswing is below priordownswing)
input: box(numeric), revboxes (numeric);vars: minswing(0), last(0}, curhigh(),swingdir(0), Signal(O;
curlow(0), swhightd), swiow(O),
 
(For percentage calculations:minswing = swing*close/100; - .if type=1 then minswing = swing*(100-close) / 100;jf types2 then minswing = swing*(8./close))minswing = box*revboxes;{SWINGS: Initialize most recent high and Tow){f currentbar = 1 then begin |
curhigh = close; {current high)
curlow = close; {current low)
end; ~(Search for a new high}
if last© 1 then begin aif high > curhightboxsize then curhigh = high;
 
(new current high} 
112.
 
TREND SYSTEMSif low < curhigh - minswing then beginlast = 1; {last high fixed}swhigh = curhigh; {new verified high}curlow = Tow; {initialize new lows}end;end(Search for a new low!else begin
if last <> -1 then beginif low < curlow-boxsize then curlow=low;if high > curlow+minswing then beginlast = -1;swlow = curlow;curhigh = high; (initialize current highiend;end;end;(Buy and selT signals)signal = signal(1};swingdir = 0;if last = 1 then beginswingdir = -1;if curlow <.swlow then signal = -1;end;if last = -1 then beginswingdir = 1;if curhigh >, swhigh then signal =end;KPF = signal;
SYSTEM
 
The following system can be used for any of the six methods by changing the braces (com-ment notation)
{System Signals.Copyright 1994-1998, P J Kaufman. All rights reserved.)
(type = 0, default, ‘1, 3-month rate2, long-term ratesperiod = length of calculationswing = swing filter in whole percent (i.e., 1.5 = I'/ percent)filter = whole % trend change to give signal'input: type(0), period(0), swing(0), box(0), revboxes(0), filter(O), 1ag(0);vars:  signal(0); .{Call User Function}signal = KMACperiod,filter,lag);{signal = KLRSignal (period) ;}(signal = KNDB(period);} -{signal = KSWG(type);}(signal = KPF(box, revboxes);}if signal ~ I then buy at close;if signal = -1 then sell at close;
INDICATOR .
The KMA Swing Indicator plots the high and low swing points above and below the corre-sponding prices. Select the scale-by-price feature.
 
‘COMPARISON OF MAJOR TREND SYSTEMS
(KMA SWING: Finds most recent swinghighs and lows.Copyright 1994-1998, P J Kaufman. All rights reserved.
Inputs for KMA SWING:swing = price swing in %type = 0, normal; 1, 3-month rate; 2, bond rateindex = 0, treat as price;1, create index series} :input: swing(1.5), type(O), index(1);vars: peswing(0), last(0), curhigh(0), curtow(0),Swhigh(O), sWiow(0), highbar(0), lowbar(O),chighbar(0), clowbar(0), lowp(0), highp(O),aclose(0), ahigh(0), alow(0), xclose(0),xhigh(O), xlow(), factor(1);
peswing = swing/100.;aclose = close;ahigh ~ high;alow = low;factor = 1;if type <> 0 then factor = -1; '{Adjust prices ff interest rates}if type = 1 then begin* aclose = 100. - close;ahigh = 100. - low;alow = 100. - high;end;if type = 2 then begin;aclose = 800./close;ahigh = 800./close;alow = 800./close;end;(Initialize most recent high and low}if currentbar = 1 then beginif index = 0 then beginxclose = aclose;xhigh = ahigh;xlow = alow;endelse beginxclose = 100.;__xhigh = ahigh*100 / aclose;xlow = alow*l00 / aclose;
end;curhigh = xclose; — {current high}curlow = xclose; ~ {current low}endelse begin
if index = 0 then beginxclose = aclose;xhigh = ahigh;xlow = alow;end
else begin
xclose = xclose{1] + (aclose - aclose(1])*100 / aclose(1]5xhigh = xclose{1] + (ahigh - aclose{i])*100 / acloseC1];xlow = xclose[1] + (alow - aclose[1])*100 / aclose(1];
end;
113 
“ha TREND SYSTEMS
 
end; :(Search for a new high - favor reversals}if last<>1 then begin(Reverse from high if minimum % swing}if xlow < curhigh - curhigh*pcswing then beginlast = 1; (Vast high fixed)swhigh = curhigh; (new verified high}highbar = chighbar;curlow = xlow;lowp = Tow;clowbar = currentbar;ploti{currentbar - highbar](high{currentbar - highbar}+ factor*highp*peswing/4,"swinghigh") ;endelse beginif xhigh > curhigh then begincurhigh = xhigh; (mew current high)chighbar = currentbar;end;end;end;(Search for a riew low - favor reversal}if last <> -1 then begin(Reversal from low if minimum % swing}if xhigh > curlow + curlow*pcswing then beginlast = -1;swlow = curlow;Jowbar = clowbar;curhigh = xhigh;highp = high;chighbar = currentbar; :plot2@{currentbar - lowbar](low{currentbar - lowbar]-factor*lowp*peswing/4, swing] ow");endelse beginif xlow < curlow then begincurtow = xlow;clowbar = currentbar;
{initialize new lows}
{initialize current high)
end;end;end;Spreadsheet CodeIn the following QUATTRO code, the “$” GENERAL DESCRIPTIONprecedes a row or column that is fixed A6 Date (YYMMDD)(e., it does not get copied down). 86 High price ~
C6 Low priceMoving average, exponential, and N-day 06 Closing price
breakout share the same page, asdothe — C3_Test period, swing %, or box sizeswing breakout and point-and-figure system. (5 Point-and-figure number of reversalboxes
The price data is not repeated to save space. All data starts in row 7
MOVING AVERAGE -3 period (e.g., 5 day)€3 filter (e.g.,.10 for O&X data)
 
 
‘COMPARISON OF MAJORTREND SYSTEMS us
 
Repeated process (copy down)
Ell MA @Avg(07..011)
Fll Dir @IF(E11 - E10>$£$3,1,@IF(E11 - E10<-$E$3,-1,F10))
G11 Entry @IF(Fll=_1#AND#F10<>-1, *Se11*,@IF (F11=1#AND#F10<>1, "Buy", *"))
EXPONENTIAL SMOOTHING
3 period (e.g., 5 day)
£3 filter (e.g.,.10 for O£X data)63 smoothing constant 1 / (C3+1)Initialize
&6 EXP +06
Repeated process (copy down)
€7 EXP. +E6+$G$3"(D7 - £6)
7 Dir  @IF(E7 - E6>$ES3,1,@IF(E7G7 Entry @IF(F7=-1#AND#F6<>-1,"SeT1"
N-DAY BREAKOUTRepeated process (copy down). There are no constants and no initialization
E6<-$E$3,-1,F6))@LF ( F7=1AND#F6<>-1,"Buy,""))
 
“ELL — Nhigh @Max(B6..810)
-Gll Dir
Fill = Nlow = @Min(C6..C10)@IF(B11>E11#AND#O11>010, 1 ,@IF(C11<FLI#AND#D11<010,-1,G10))HIL Entry @IF(G11=-1#ANO#G10¢>-1,"Se11" ,@IF(G11=1#AND#G10<>1, "Buy", ""))
SWING BREAKOUT
3 Minimum swing percentage£6 CurH +86
F6 CurL +C6
GE H/L  @1F(D6>(E6+F6)/2,-1,1)
£7 CurH @IF($G6=-1#AND#87>E6,B7 ,@IF($G6=1,B87,£6))
F7 Curl @IF($G6=1#AND#C7<F6,C7 ,@IF($G6=-1,C7,F6))
G7 H/L @IF($G6=-1, @IF(C7<E7 - $C$3*07,1, $66) ,@1F(B7>F7+$C$3*D7,-1,$G6))
H7 SwH  @LF($G7=14AND#G6=-1,E7 ,H6)
17 Swh  @LF($G7=-1#AND#G6=1 , F7,16)
J7 Entry @IFC$G7=-1#AND#B7>H7#AND#D7 >D6 , “Buy”,@IF($G7=1#ANDIC 7 <4 7#ANDH07<06 ,"Se11",*"))
NOTE: The point-and-figure spreadsheet code varies slightly from the TradeStation code.It is a more accurate representation of the exact point-and-figure charting method (favor-ing reversals when possible).
POINT AND FIGURE
C3 Point and figure box sizecs Number of reversal boxes£6 CurH @INT(B6/$C$3)
F6 Curl @INT((C6+$C$3)/$C$3)
G6 Dir @IF(DE>(EG+F6)/2,1,-1)
E7 CurH @IF($G6=1,@1F (@INT(b7/$C$3)>E6 ,@INT(B7/$C$3) ,E6) ,@INT(B7/$C$3))
F7 Curl @1F($G6=-1,@IF (@INT((C7+$C$3)/$C$3)<F6 ,@INT( (C7+$C$3)/$C$3)),F6 ,@INI( (C7+$C$3)/$C$3) )
G7 Dir @LF(G6=-1#AND#@INT(B7/$C$3)>F7+D$3-1) ,1,@IF(G6=1FAND#@INT((C7+$C$3)/$C$3)<E7 ~ ($D$3-1),-1,66))
H7 Lasth @IF(G7=-1#AND#G6=1,E7 ,H6)
I7 Lastl @IF(G7=1#AND#G6=-1,F7, 16)
U7 Entry @LF(G7=-1#ANDH@INT((C7 - $C$3)/$C$3)<I7,"SeTI",@IF(G7=1#AND#@INT(B7/$C$3)>H7, "Buy", ""))
LINEAR REGRESSION SLOPE3 périod (e.g.,5) _E3 filter (e.g.,0)Initialize .
  
 
  
U6 ‘TREND SYSTEMS.
 
£6 Timex 1 :G6 X*2 E6*E6 (copy down) :J6 xy €6*06 (copy down)
Normal processing (copy down all cells)
E? Timex +£6+1
F10 Sumx  @Sum( £6. .£10)
Glo x2 +£10*E10
H10 Sumx*2 @Sum(G6. .G10)
110 SumY  @Sum(06. .010)
J10 xy +EL0*D10
K10 SumxY @Sum(J6. .J10)
L10 Slope ($C$3*K10 - F10*I10) / ($C$3*H10 - F10*Fi0)
M10 Dir @IF(L1O>$ES3#AND#L9<SES3,1,@1F(L10<-SES3#AND#L9> - $ES3, - 1,M10))
N10 Entry @IF(MLO=-1#AND#M9<>-1,"Se11" ,@IF(M10=1#AND#M9<>1, "Buy", *"))
To verify that the correct code was entered into the spreadsheet, Figure 5-8 shows a sam-ple of the opening lines of the spreadsheet using sample data. The columns E, F, G, and Hhave been repeated for each of the moving aveiage, exponential smoothing, and N-daybreakout systems. In Figure 5-9, this approach has been taken for the swing breakout andpoint-and-figure systems using the same data.
TECHNIQUES USINGTWOTRENDLINES .
This section is restricted to applications of trendlines; however, do not assume that trend-lines constitute the only timing methods. Any secondary system that analyzes a shortertime period than the primary system can be considered as a timing device. Typically, a3-day moving average could act as a timing technique for a 10-day average; however, thedelays of 1, 2, 3, or more days, discussed earlier, are also for timing. A 5-day delay wouldnot be a sensible choice to be used with a 3-day moving average, because the two periodswould be incompatible. Plotting of lag and lead moving average values is another possibletiming method. In this section, the use of more than one moving average will be examined(any type of trend approach would apply) to create a system.
In using two averages, the slower one, requiring a longer calculation period, willdetermine the long-term trend. The faster average will be used for timing. The long-termmoving average generates a signal compatible with the long-term trend, regardless ofrecent patterns. A trader would be more comfortable knowing that there is a recent short-term surge of prices in the direction of the new position at the moment of entry. To imple-
ment this idea, select two moving averages, one noticeably faster than the other, and applyeither of the two following rules:
1, Buy when the faster moving average crosses the slower moving average going up.
> dcit when the faster moving average crosses the slower moving average going down,
2. Buy when the current price crosses above both moving averages, and close out longPositions when prices cross below either moving average. Sell when the currentPrice crosses below both moving averages, and close out short positions whenPrices cross above either moving average (Figure 5-10). :
The first set of rules results in constant trading, going from Jong to short and backagain as the long-term trend is violated by the faster trend. The second set of rules allowsfor a neutral position when the current position is closed out and the long-term trend isnot penetrated. One problem with this second approach is that the faster moving averagemay cause whipsaws by being too close to the current price. This can be solved in the samewway as the single moving average by placing a band around oné or both of the trendlines.
There are other variations of these rules that can be listed, but they are not materially dif-ferent from these two.
FIGURE 5-8 Sample spreadsheet results for the moving average, exponential, and N-day breakout systems,
 
N-day Breakout
Exponential
Moving Avg
Data
 
 
 
 
 
  
 
 
   
 
 
= =a 3a ——2 EESSESBSSSKASASRARKSRSSERBS SSSSSRSSESSRERS= BSSISAAAARRTSRRRRSSTSs > POO OSSSS Saaan & Ss2 SSSRSRSSSSSASSSSSSS Ss“ a 3 2g | SSSRSRRSRSRRTAssaseaggusssSSS SUK MAS EHS RASE RR esseO|SRSSSSRESSSSSSSSSERR RRS SSS24 3 z Baa trod te .SRR Ra RRB ec hagsgagegasejaa = iwi Ow = 2= ZRSSRRSAAARASASASSSSSS=wsts ogeeg|SQSS8 82a Qareesge gl een gssasSSRI FHS Ase Ee S SsS|eeeeaSengSeaseeeeehseseseeaE Se RT RROanFRSHSR TIS SRS SS RTS TAS SEASUES RASS eESE S = =S)SERRSESSSRESS ESR SERRE SSSESRags asB/SERSR RIARETARIGERASRSSISSPisa wow ~¥ 0 SESERESS 8esssesTISRSSRSSESSSRSRSSSSSSSS SSSOSA SERSSSEES