(50}(0), cbelow[50](0), crev(50)(0), treross[50}(0),tradj{50)(0), treont(S0](0), ncontl50}(0)}, nitems(S01(0);{Initialize increments)if currentbar <= 1 then beginn= nbars + 1;n2 = @intportion(n/2);middle = n2 + 15min = -n2*gapincrsfor ix = 1 to n beginmaxminCix] = min;min = min + gapincr;
end;end;! (Process gap!4 if open <> closef1] then begini gap = (open - close(1])/gapincr;
if gap > 0 then beginngap = @intportion(gap) + middle + 1;if ngap > n then ngap = n;end;1f gap <0 then beginngap = middle - 1 + @intportion(gap);(gap is negative!if ngap < 1 then ngap = 1;end;nitems(ngap] ~ nitemstngap} + 1;(Relative position of today’s close)if (gap > 0 and close > open) ar (gap < 0 and close < open) thenccont{ngap} = ccont{ngap} + 1;if (gap > 0 and close > close{1] and close < open) or(gap < 0 and close < close[i] and close > open) thencbelow{ngap] = cbelow(ngap] + 1;if (gap > 0 and close < close{1}) or (gap < 0 and close > close[i}) thencrev(ngap] = crev(ngap] + 1;(Pattern of entire trading range!if (gap > 0 and low < closeti}) or (gap < 0 and high > close{1]) thentecross(ngap] = treross{ngap] + 13if (gap > 0 and low > close{1] and, low < open) or(gap < 0 and high < close{1] and high > open) thentradj{ngap] = tradj{ngap] + 1;if (gap > 0 and low >= open) or (gap < 0 and high <= open) thentreont(ngap] = trcont{ngap] + 1;
 
(Continue next day}if(gap(1} > 0 and open > close[l]) or(gapl1] <0 and open < closef1]) then -ncont{ngap] = ncont(ngap) + 1;endelsenitems({middle] = nitems{middle} + 1;if lastcalcdate ~ date then beginfor ix =n downto 1 beginprint (file("C:\windows\gapout™), maxmin({ix):4:3, nitemsCixj:5:0,econtlix]:5:0, cbelowLix} GO, crevlix}:4:0, trcross(ix]:5:0,- tradjLix}:4:0, trcontlixJ:4:0, ncontlix}:5:0);end;
 
 
 
end; 
 
 
 
 
400 PATTERN RECOGNITION
THREE STUDIES IN MARKET MOVEMENT—WEEKDAY, WEEKEND, ANDREVERSAL PATTERNS
The next three sections are concerned with longer periods of time. The first, weekday pat-terns, looks only at the closing prices during a 5-day week from Monday through Friday tofind recurring close-only patterns. A week is often considered to have integrity as a single unitof time, and participants are accused of acting in the same way each week. This study attemptsto isolate predictive patterns; for example, if Monday through Thursday were all higher, whatis the possibility of Friday being higher? If the weekly trend can be clearly identified, should acorrection on Friday be expected due to evening-up (closing out positions before the week-end)? Because patterns represent human behavior, the results could prove interesting.
Weekend patterns are considered independently in the second study. The openingdirection on Monday could restore the trend of the prior week, if those traders who liqui-date on Friday intend to reset their positions. The weekend is also an extended period forunexpected news or a buildup of public interest. The study will attempt to relate the direc-tion of the Monday opening price to some pattern or trend of the preceding week.
Reversal patterns are not based on a day of the week but have often been discussed asa leading indicator. They may also be used as a filtering or timing device.
Weekday Patterns
During their constant exposure to the market, professional traders often observe patternsin weekly price movement, their acceptance of these patterns is as old as the market itself.In Reminiscences of a Stock Operator, the ficticnal character Larry Livingston (assumed tobe Jesse Livermore) begins his career recording prices on a chalkboard above the floor ofthe New York Stock Exchange, eventually becoming aware of patterns within these prices.The most accepted occurrence of a pattern is the Tuesday reversal, which is taken as com-‘monplace by close observers of the market. When questioned why a strong soybean mar-ket on the first of the week is followed by a weak day, a member of the Board of Tradewould shrug his shoulders and quote: “Up on Monday, down on Tuesday.” If this is true,there is a trading opportunity.
If a commonly accepted idea is not enough to be convincing, consider the additionalrationalization about human behavior: The weekend allows a buildup of sentiment, whichshould result in greater activity on Monday. Coupled with adding back positions that wereliquidated prior to the weekend, this may cause a disproportionate move on Monday, espe-cially early in the session. This pattern may be further exaggerated when a clear trendexists. With this overbought or oversold condition, it is likely that Tuesday would show anadjustment. So much for hypothesizing.
‘The first aspect of the test was to define the weekday pattern. This was done in terms ofthe Friday-to-Monday move (close-to-close). Monday always received the value X, regardlessof whether its direction from Friday was up or down. For each day that closed in the samedirection as the Friday-to-Monday move, another X is used; when the close reversed direc-tion, an O is recorded. Therefore, XOXXO means that Tuesday and Friday, represented by O,closed'in the opposite direction from the prior Friday-to-Monday move, while Wednesdayand Thursday were in the same direction. This could have meant either of the situations:
 
————$ $$
 
(0) (2)Monday x Up DownTuesday O _ Down UpWednesday xX ~ Up DownThursday x Up DownFriday O Down Up
 
THREE STUDIES IN .,ARKET MOVEMENT—WEEKDAY, WEEKEND, AND REVERSAL PATTERNS 401
 
It might be that there is a distinction between the weeks that begin with an upwardmove on Monday rather than a lower price, but both cases were combined. This assumesthat the pattern, rather than the direction, is most important. It would also be reasonableto have assumed that the upward bias of the stock and interest rate markets during the past10 years would justify a separation of patterns according to their initial direction.
 
Daily Sequences
Figure 15-6 shows the aggregate results of the weekday patterns for a sampling of 23futures markets tested during the period 1976 through 1985, appearing in the previousedition of this book. The numbers next to the corresponding patterns indicate the per-centage of occurrences of each new day's pattern. For example, if the Monday-Tuesday pat-tern was XX, indicating that prices moved the same direction, then there was a 58% chancethat an O followed, indicating a reversal.
Returning to the original premise for studying weekday patterns, we can use the broadset of market to see if any dominant behavior exists. We see that there was a 58% chance ofa reversal on Tuesday (XO) and a 53% chance of that reversal continuing into Wednesday(XOO). Ifa reversal did not occur on Tuesday, there was a 58% chance that it would occuron Wednesday (XOO). For a large number of tests, 58% shows a definite pattern that con-firms the original view. There are very few significant values that appear on Thursday, butthree patterns of interest appear on Friday—XOXXX, XOOXX, and XXOOX—showing57%, 64%, and 60%, respectively. These three patterns are important because they all showmidweek reversal and a continuation of the trend by the end of the week.
‘The weekday patterns for the same six markets studied in the previous section (“Open-ing Gaps”) were also tested for the period January 1986 through February 1996 and appear
 
FIGURE 15-6 23 futures markets, 1976-1985.
 
Monday Tuesday Wednesday Thursday Friday
 
p> | XOXXX_57,
 
 
 
 
 
XOXX _50XOXXO 43XOX 47XOXOX 50xOxO sob
 
bere SI froreos0]
| XOOXxx 64
XOOX 50 =XOOXO 36x0O 53 ————XOOOX 50
XO00 50———_- L+1x09000 50_ [| XXxxx 49XXXX_53>| XXxxO 51>[xxxox 47
L+[xxxoo 53XXOXX 54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
XXXO 47
 
 
 
 
 
xX 42
 
 
 
 
XXOX 54XXOXO 46
- XXO__ 58 —XXOOX 60
XXOO 46
 
 
 
 
 
 
 
 
 
 
 
 
 
Xx000 40
 
 
 
  
402 PATTERN RECOGNITION
in Figure 15-7a-f To understand the accuracy of these tests, each one includes approxi-mately 480 complete weeks of information used to compile the patterns; therefore, eachof the two combinations appearing on Tuesday have 240 entries, each pattern on Wednes-day represents 120 weeks, Thursday 60, and Friday 30, assuming an equal distribution ofpatterns. All of these markets are actively traded.
Looking first at the Deutschemarks (Figure 15-7a), we see the same pattern as in the10 years prior. There is a 55% chance of a Tuesday reversal (XO) and a 58% chance of aWednesday reversal (XXO). If a reversal does not occur by Wednesday, there is a 57%chance of a reversal on Thursday (XXXO), but only a 28% chance that a reversal will occuron Friday (XXXXO), if it hasn't yet happened. The reverse situation shows that, if pricesmoved in the same direction Monday through Thursday, then there was a 72% chance theywould move in that direction on Friday.
‘The same pattern seen in Deutschemarks is also apparent in the S&P (Figure 15-76),where the chance of a reversal is 56%, 54%, 62%, and 38%. The most dominant Friday pat-tern is a trend continuation following a similar day on Thursday (XXXXX and XXOXX).Treasury bonds (Figure 15-7c) show a slightly greater consistency for reversal—57%, 59%,55%, and 53%. For bonds, the chance of continuing in the same direction for the entireweek is small. Gold (Figure 15-7e) also reflects similar reversal Patterns—59%, 55%, 58%,and 38%. In view of the steady downtrend in gold prices during this 10-year period, thispattern appears to show a consistent method in the behavior of the traders. Soybeans (Fig-
 
FIGURE 15-7 Weekday study results. (a) Deutschemarks. (b) S&P 500. (c) Treasury bonds.(d) Heating oil. (e) Gold. (f) Soybeans.
Monday Tuesday Wednesday Thursday Friday- [Kom 49
oR} BO]
Lf XOXXO 51
p> XOX 58XOXOX 49Lf xoxo 51 —XOXO 51
[| ROOXx 48XOOX_§7>| XOOXO 52
L+|xoo 44 W —=XOOOX 51
L[x000 we}x0000 49]
= XXXXK 72
poo 28]oat XXXOX 44>| XXXOO 56
T XXOXO 48
rf XXOOX 42Lf XxOO_51= al Xx000 58
 
 
 
 
 
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
(a) Deutschemarks
 
THREE STUDIES IN MARKET MOVEMENT—WEEKDAY, WEEKEND, AND REVERSAL PATTERNS 403
 
FIGURE 15-7 (Continued)
Monday Tuesday Wednesday Thursday Friday
fronts
>] XOXXO 48
 
 
 
 
 
XOX 51
i
>| xoxox 56XOXO _54 =L-{xox0o 44
XOOXX 48XOOXO 52X00Ox 50X0000 50x 62
XXXXO 38GA Lxxa0 26}
 
 
 
 
 
 
 
 
x:x34
rN
8
x
g
 
100
{
|i
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
oe XXXOX 52WOE p becca]XXXOO 48———XXKOXX 60>| xxox 43—— >] XXOXO 40XXO__54—_—— XXOOX 52!>| XxOO_57XXO00 48(0) S&P. 500
 
ure 15-7f), a market clearly out of the financial circle, show their reversal tendency as 56%,58%, 59%, and 58%. This variation on Friday does not change the uniform market reversalpattern seen early in the week. -
Heating oil patterns (Figure 15-7d) are noticeably different from the other five mar-kets. There seems to be no dominant pattern on Tuesdays and Wednesdays and only minorseparation on Thursday. The three best patterns on Thursday, XOXO, XXXO, and XXOO,all show that Thursday moves in the direction opposite to Monday. The three best patternson Friday, XOOXO, XXXOO, and XXOXO, also show that Fridays reverse from the opening
—Monday direction. After seeing the consistency of the other markets, these patterns indi-
cate avery different participation. We might speculate that midweek release of oil stocks bythe API, combined with weekend news about OPEC, have a tendency to create differentreactions from traders,
Trading Weekday Patterns
The persistence of the weekday reversal over the past 20 years appears to be based on thenature of market participation. The patterns span nearly all markets with very similarresults, To trade these weekday patterns, positions must be entered on the close of theprior day. Therefore, if soybeans move higher on Monday and Tuesday, we set a short on"Tuesday’s close with a 58% chance of a profit on Wednesday. If that does not occur, we canhold that short with a 59% chance of recovering at least some of that loss on Thursday. IfWednesday proved profitable, neither Thursday nor Friday have interesting patterns andwe would close out the trade. 
 
erie Hn
PATTERN RECOGNITION
404
 
FIGURE 15-7 (Continued)7Monday Tuesday Wednesday Thursday FridayXXX 54
*:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
XOXX 49XOXXO 46XOX 49XOXOX 43,t+} xOxO 51XOXOO 57XOOXX 51+| XOOX 55Lf XOOXO 49°xOO 51XOOOX 53)XOOO 45XOCOO 47,[>] XXXXX 47| Xxxx 45, ——Lf XXXXO 53XXXOX 49,>} XXXO_ 55.r| XXOXX 46>| XxOx_ 40 —>| XXOXO 54XXO 59 —_XXOOX 47>| XxOO 60Lf XXOOO 53,
(@) Treasury bonds
 
In many cases, if you are trading the reversal pattern and it does not occur on the firstday, it is best to hold that position at least one more day. This study may be taken furtherby looking at whether the open of the next day is a better point to enter a reversal tradethan the previous close. Therefore, if Monday and Tuesday were both lower, a long enteredon the open Wednesday may prove more profitable and less risky.
Programming the Weekday Study
‘The following program will produce results forthe weekday study in the Printer Log win-“dow of TradeStation. There are a number of different methods that could be used to findthese patterns; this approach is shown because it is transparent without using an excessive
amount of programming code. ~
ISYSTEM: Weekday Study](Copyright 1985-1998. PJ Kaufman. AI] rights reserved.){Update weekday study in “Trading Systems and Methods")vars: dow(0), dir(0), 1x(0),4y(0), errorco), Mon(O), day2(O), day3(0), day4(00,dayS(0),div(0), pCO);arcays:Tuesf2}(0), Wed£4}(0), Thurstel(O), Fri{16](0), patternl5](0),n2l2O), n3C4}(O), n4fBICO), mS[16}(0);{create full pattern for week before entered values in case incomplete}“dow = @dayofweek( date) ;if currentbar = 1 then beginTues{t] = 10; Tues€2] = 11;
 
THREE STUDIES IN MARKET MOVEMENT—WEEKDAY, WEEKEND, AND REVERSAL PATTERNS 405
 
FIGURE 15-7 (Continued)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Monday Tuesday Wednesday Thursday FridayKOK aa | XOXXX 58
[xox 20} TT Leet XOXXO 42
L+[xoxo _ 56]
xO 52eae} Boe
~| XOOXO 62
+} XxOOO 50--—} O0OX 54
XO000 46
“ oon ae] [| XXXXX 49[eee es
xx 78 > XXXOO 65
| XXOXO 62
+} XxOOO 55
(2) Heating oi
 
Wed(1] ~ 101; Wed{2] ~ 100; Wedf3) ~ 111; Wedt4) = 110;Thurs(1} = 1011; Thurs(2] = 1010; Thurs{3] = i001; Thurst4] = 1000;Thurs[5] = 1111; Thurs{6] = 1110; Thurst7J = 1101; Thurs(8) = 1100;Frs1] = 10111; Fritz] = 10110; Fric3) = 10101; FriCa] ~ 10100;Fei(5] = 10011; Frif6] = 10010; Fri(7] = $0001; Frits] = 10000;Fri[9] = 11111; FriC1O] = 11110; Frifi2] = 11101; Fri{12] = 11100;FriC13) = 11011; Fri(i4] = 11010; Frit} = 11001; Frif163 = 13000;end;(Monday!$f dow = 1 then beginfor ix = 1 to § beginpattern{ix] ~ 0;end;if close > close{1) then pattern{1] ~ 1 else pattern{1} =end; -
 
(Tuesday)
if dow ~ 2 then beginif close > close{1] then pattern{2] = 1 else pattern{2) =
 
   
end;(Wednesday)if dow = 3 then begin. if close > closef1] then pattern[3] = i else pattern(3) ={Thursday}
if dow = 4 then begin 
406 PATTERN RECOGNITION
THREE STUDIES IN Ps RKET MOVEMENT—WEEKDAY, WEEKEND, AND REVERSAL PATTERNS 407
 
 
FIGURE 15-7 (Continued)
 
FIGURE I5-7 (Continued)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Monday Tuesday Wednesday Thursday _ FridayXOXXX 54= pbx] XOXXO 46xox _63}-4 —>SSLL.Txox00 43| xO 59
or XOOXX 36pees
x00__47: =_-7 [x00
L+[x000 4 -XO000 61eI faeXXXXX 38=< pte 2H esosx| ee XXXOX 85XXXOO 45XX 4SIO XXOXX 45|
XxXOXO 55
XxXO_ 5500x 53
 
 
{
F
|a
 
(000 57|(e) Gold
 
if close > close{1] then pattern(4] = 1 else pattern{4] = -1;end; -{Friday} Xif dow = 5 then beginYf close > close(1] then pattern{S] = 1 else pattern{S] - -1;error = 0;(process pattern for entire week, convert to pattern beginning with 1}for ix ~ 2 to S beginif pattern{ix] = 0 then error = 1;if error = 0 then beginif patternLix] * pattern(1] > 0 then pattern{ix] = 1 elsepatternlix] = 05
 
- end;
ends .pattern{l] = 1; _if error = 0 then begin aT
{create a value for each day}Mon = Mon + 15day2 = 10 + pattern(2];day3 = 100 + pattern(2}*10 + pattern(31;,days = 1000 + pattern(2]*100 * pattern{[3]*10 + pattern[4};dayS = 10000 + pattern(2)*1000 + pattern{3}*100 + pattern{4]+l0 +pattern[53; -{match each pattern and add to number of cases)if day2 = Tues(1] then n2{i] = n2{1] + 1 else n2(2) = n2(2] + 1;for ix = 1 to 4 begin
 
é2$o
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Monday Tuesday Wednesday Thursday Friday| XOXXX 59: 7 Lox ss} sooXOX 51Ly po] XOXOX 52,ze| XOxt 48XOOXX 44XOOX 55== pS SL ooxe ssLa XOOO 45 [7 LACORS4!>| xOOCO 46)100OO t—>| XXXXX 42nen!XXXXO 58Gk [2xxx0 58]f—~| XXxOXx 60.“ UL} xXxxO 59>| XxxOO 40,XKOK 5S p>] XXOXX 45: Leos]x 58Ixxoo a7] t XXOOX 52XXOOO 48}
(f) Soybeans -
 
if day3 = WedLix] then n3Cix} = n3Cix} + 15end:
for ix = 1 to 8 beginif day4 © Thurs(ix} then n4(ixJ = ndlix] + 1;end:
for ix = 1 to 16 beginif dayS = Frilix] then nS{ix] = n5Cix) + 15end;
end;end;if lastcalcdate = date then begin -print ("Monday = 1 100%, cases =", mon:5:0);print ("Tuesday");for ix = 1 to 2 begindiv © @intportion( (4x+1)/2);pe = n2Cix]*100/Mon;print (Tueslix]:5:0, n2fix]:4:0, pc:4:0)5end;print ("Wednesday");for ix = 1 to 4 degindiv = @intportion((4xt1)/2)5pe = n3Cix]*200/n2Cdiv);print (Wed{ix]:5:0, n3{ix]:4:0, pos4i0)5 -end;print (*Thursday");for ix = 1 to 8 begin
 
  uterine
 
:?j3};ii4;i+?
* 408
 
PATTERN RECOGNITION
div = @intportion((ix+11/2);pe = n4lixJ*100/n3tdivI;print (Thurs(ix]:5:0, n4Cix}:4:0, por4:0)5end;
print (Friday?)
for ix = 1 to 16 begingiv = @intportion( (ix+1)/2)5pe = n5ix]*100/neCdiv];print (Frifix]:5:0, n5Cix]:4:0, posd:0)5end;
end;
Weekend Patterns
Of all patterns studied, this test was expected to be the most promising. Two factors leadto the anticipation of strong weekend patterns:
1. Friday liquidation—the aversion of traders to hold a market position over theweekend.
2, Setting of new positions and resetting of old ones on Monday, especially during atrending market.
If the patterns can be identified, the 2-day wéekend delay should result in large pricejumps and good profits for those willing to take the weekend risk, Not knowing what toexpect but anticipating combining the results with the study of weekday patterns, a num-ber of different trend indicators and patterns were tested. These were limited to closingprice relationships.
Trend indicators
Prior Thursday-to-Friday directionFriday-to-Friday directionMost frequent direction last week
Following each of the trends or patterns, the prices on Monday were tabulated todetermine the frequency and consistency of the opening price, closing price, and high orlow prices that were in the same direction as each of the trends or patterns. Table 15-7 liststhe results for the six markets studied for the 10 years from 1986 through February 1996.Based on the three trend patterns, none of the markets show any significant tendency tocarry the trend over the weekend reflected in the open or close of the following Monday.The extreme on Monday, that is, the high or low price, normally provides an opportunityt6 exit at a profit from a trend position taken on Friday's close sometime on Monday.
It seems surprising that the price pattern on Monday no longer reflects the directionof the previous Thursday-to-Friday move, nor the trend of the previous week. In the samestudy performed in the prior 10 years, there was a clear pattern based on Thursday to Fri-day. Considering the fact that there have been dominant trends in the equities markets andinterest rates, the only reasonable conclusion is that markets are more complex, based ongreater participation. It will be necessary to look at longer trends or other patterns to findhigh-probability cases.
Combining Weekend and Weekday Patterns
The direction of Monday’s prices is more interesting when viewed in terms of the previousweekday patterns. Seen side by side, the frequency of each pattern and the way the six sam-ple markets react with respect to the following, Monday closing price give insight into mar-
 
THREE STUDIES IN MARKET MOVEMENT—WEEKDAY, WEEKEND, AND REVERSAL PATTERNS 409
 
 
TABLE 15-7 Weekend Pattern Based on Possible Trends during the Prior Week,January 1986-February 1996
 
 
Continued Direction Monday (%)Market Trend Open Close ExtremeDeutschemark Thurs to Fri 55 51 74Frito Fri 56 55 78Most frequent direction 54 51 99S&P 500 Thurs to Fri 49 49 87Fri to Fri 46 St 88Most frequent direction 47 50 98US. Fbonds Thurs to Fri 46 47 87Frito Fri 46 St 89Most frequent direction 46 49 96Heating oil Thurs to Fri 49 49 77Fri to Fri 49 48 80Most frequent direction 50 49 96Gold Thurs to Fri 53 47 7%Fri to Fri 50 46 76Most frequent direction st 47 97Soybeans Thurs to Fri 53 45 76Frito