11-01 8 58.90 58.60 57.40 58.60 58.52 38.30 57.9511-03 9 59.10 59.40 59.20 58.20 58.86 58.75 58.5311-04 10 61.00 59.30 59.50 59.45 58.67 59.10 58.9811-05 i} 62.10 61.90 61.77 61.35 60.15 60.15 60.3011-08 (2 62.00 63.20 63.73 63.15, 62.75 62.37 61.5311-09 13 62.50 61.90 62.70 63.50 63.38 63.20 62.9411-10 14 63.50 63.00 62.60 63.00 63.68 63.71 63.64-tl 15 61.30 64.50 64.16 63.70 63.84 64.34 64.381-12 16 61.70 60.10 61.23 62.05 62.25 62.69 63.361-15 17 62.00 62.10 60.36 61.10 61.66 61.87 62.301-16 18 62.20 62.30 62.37 61.10 61.36 6171 61.86(1-17 19 61.70 62.40 62.47 62.55 61.57 61.64 61.8511-18 20 61.50 61.20 61.67 — 61.95 62.17 61.47 61511-09 21 62.40 61.30 61.10 61.35 61.61 61.85 61.3111-22 22 61.40 63.30 62.57 62.05 61.99 62.07 62.2011-23 23 59.90 60.40 6L67 61.75 61.57 6161 61.7311-24 24 59.80 58.40 58.73 59.85 60.29 60.37 60.5811-26 25 59.10 59.70 58.76 58.85 59.22 59.59 59.7111-29 26 59.50 58.40 58.85 58.30 58.06 58.55 58.8711-30 27 59.10 59.90 59.17 59.10 58.56 58.20 58.48
 
THE MOVING AVERAGE
The simplest and most well-known of all smoothing techniques is called the moving aver-age (MA). Using this method, the number of elements to be averaged remains the same,but the time interval advances. Using a generalized time series as an example, Po, Pi,P2,...,P,are a sequence of prices. A moving average measured over 7 of these prices, ordata points, at time t would be _
PrasesPtP) te tPy- &cas
In other words, the most recent moving average calculation is the average (arithmeticmean) of the prior m data points. For example, using three points (# = 3) to generate amoving average:MA, = (P, + P2 + P3)/3MAg = (P2 + Py + P3)/3
MA, = (P;-2 + P,-1+ P,)/366 TREND CALCULATIONS
 
a
TABLE 4-2 Analysis of Predictive Error for CopperPredictive Error for an n-Day Linear Regression
 
 
Sequence PriceDate @ P, E(2), (3), E(4), E(5). E(6), E(7),10-21 I 60.3010-22 2 59.3010-25 3 58.7010-26 4 57.8010-27 5 59.8010-28 6 58.2010-29 7 58.4011-01 8 58.90 -.30 1.50 -30 -.38 -.60 -9511-03 9 59.10 30 10 -.390 -24 -35 -5711-04 10 61.00 -1.70 —1,50 155 2.33 -1.90 2.0211-05 I 62.10 -.20 —33 =75 -1.95 =1.95 -18011-08 12 62.00 1.20 1.73 LIS 75 37 -4711-09 13 > 62.50 -60 20 1.00 88 70 411-10 14 "63.50 -50 -.90 -.50 18 2i 4T1-EE 15 61.30 3.20 2.86 2.40 2.54 3.04 3.08H1-12 16 61.70 -1.60 ~47 35 35 99 1.66H-1S 17 62.00 . 10 —1.64 90 -34 13 3011-16 18 62.20 10 7 -1.10 84 -Ad -34W-I7 19 61.70 70 77 85 -.13 -.06 ASW-18 20 61.50 —30 7 45 67 -.03 OlI-19 . 2i 62.40 -1.10 -1.30 —1.05 -79 —65 -1.0911-22 22 61.40 1.90 LIZ 65 59 67 8011-23 23 59.90 50 1.77 1.85 1.67 V7 1.8311-24 24 ~ 59.80 —1.40 1.07 05 49 57 7811-26 25 59.10 60 -34 25 12 49 611-29 26 ~59.50 -1.10 —70 -1.20 1.44 —95 6311-30 27 59.10 80 07 00 -.54 -.90 -.62© (Standard deviation) 1.209 1.217 1.069 L.ISE 1.149 1.220M (Mean) 030 —.037 012 -.027 037 065V (Variance) 1.389 1.406 1.086 1.260 1.255 L415
 
If P, represented a price at a specific time, the moving average would smooth the pricemovement. When more prices are used, the new price will be a smaller part of the averageand have less effect on the final value. Five successive prices form a five-day moving aver-age. When the next sequential price is added and the oldest is dropped off, the prior aver-age is changed by % of the difference between the old and the new values. If
MAs = (P, + P2 + P3 + Py + Ps)/5
_andMAg = (P2 + P3 + Py + Ps +Po/5then c = P; + P; + P, + Ps can be substituted for the common part of the moving average,solved for c, and substituted to getMAg = MAs + (P,— Py _,)/5This also gives a faster way to calculate a moving average. It can be seen that the moreterms in the moving average, the less effect the addition of a new term is likely to have:
MA,=MA,_1+ (P:—Py-n)/nTHE MOVING AVERAGE 67
 
The selection of the proper number of terms is based on both the technical considerationof the predictive quality of the choice (measured by the error) and the need to determineprice trends over specific time periods for commercial use. The more days or data pointsused in the moving average, the more smoothing will occur; variation lasting only a shortwhile will have less effect. There is also a danger of losing cyclic or seasonal price patternsby selecting the wrong value of n. For example, a repeating cycle of four data points 5, 8,3, 6, 9, 4, 7,..., which advances by the value 1 each complete cycle, will appear as astraight line if a moving average of 4 days is used. If there is a possibility of a cyclic or sea-sonal pattern within the data, care should be taken to select a moving average that is outof phase with the possible pattern (that is, not equal to the cycle period).
The length of the moving average must also relate to its use. A jeweler may purchasesilver each week to produce bracelets. Frequent purchases of small amounts keep the com-pany’s cash outlay small. The purchaser can wait as long as possible while prices continueto trend downward during any one week but will buy immediately when prices turnupward. A 6-month trend cannot help his problem, because it gives a long-term answer toa short-term issue; however, a 5-day moving average may give the trend direction withinthe jeweler’s time frame.
User-Friendly Software
Fortunately, we have reached a time when it is not necessary to perform these calculationsthe long way. Spreadsheet programs and specialized testing software provide simple toolsfor performing trend calculations as well as many other more complex functions discussedin this book. The notation for many of the different spreadsheets and software is very sim-ilar and self-explanatory:
 
 
Function Spreadsheet Omega
sum @sum{ list, period) @summation(value, period)Moving average ~ @avg(list, period) @average(value, period)Standard deviation @std(tist, period) @stddev(value, period)
 
What Do You Average?
The closing or daily settlement is the most common price applied to a moving average. Itis generally ‘accepted as the true price of the day and is used by many analysts for calcula-tion of trends. But other alternatives exist. The average of the high and low prices of theday will smooth the results by preventing the maximum difference-from occurring whenthe close is also the high or low. Similarly, the closing price may be added to the high andlow, and an average of the three used as the basis for the moving average.
Another valid component of a moving average can be other averages. For example, ifP, through P,, are prices, and MA, is a 3-day moving average, then
MA, = (P, + P2 + P3)/3= (P, + P3 + Py/3MA, = (P; +P, +P;)/3and.MAS = (MA, + MAy + MA)/3MAJ is a double-smoothed moving average, which gives added weight to the center points.
More on double smoothing can be found later in this chapter. Smoothing the highs andlows independently is another technique that creates a representation of the daily trading8 ‘TREND CALCULATIONS
 
range, or volatility. This has been used to identify normal and extreme moves, and will alsobe discussed in Chapter 5 (“Trend Systems”).
Types of Moving Averages
Besides varying the length of the moving average and the elements that are to be averaged,there are a great number of variations on the moving average.
An accumulative average may be used for a long-term trend. It does not satisfy ourstrict definition of a moving average, because it adds data but does not discard any; there-fore, it is cumulative. It is traditionally started at the beginning of a futures contract andcontinued until the contract expires. It may be applied to stocks after each dividend notice.Due to the accumulation of prices and the constant increase in the length of the average,the effect of the additional price at day t on the moving average will be (P, - AVG)/t, whereANG is the average ofall prices from the beginning through ¢. The impact of 1 day becomesvery small toward the end of a 1-year contract, which has approximately 250 trading days.A reset accumulative average is a modification of the standard accumulative average andattempts to correct for the loss of sensitivity as the number of trading days becomes large.This alternative allows you to reset or restart the moving average whenever a new trendbegins, a significant event occurs, or at some specified time interval.
Truncated moving averages are the most common, and they are often called simplemoving averages. The most basic has already been discussed in detail. An ‘alternate methodof calculating a daily moving average calculation is to keep the total of the past 7 days. Eachnew day then only: requires the addition of the new value and subtraction of the oldestone. The new total is saved for the next day and is also divided by n to get the new movingaverage value. An interesting twist to this technique is the average-modified method, inwhich the price of the new day is added and the last moving average value is subtracted.Returning to the example of a 5-day moving average, day 6 was
MAg = MA, + (Ps — P)/5This becomes.MAg = MA, + (Ps ~ MAs)/5
The average-modified version is convenient, because only the prior moving averagevalue and the new price are necessary for each calculation. The substitution of the movingaverage value tends to smooth the results even more than a simple moving average. Its useprevents the difference (P¢ — P,) from becoming too extreme; it effectively cuts the possi-ble range in half and dampens the end-off impact.
The weighted moving average opens many possibilities. It allows the significance ofindividual or groups of data to be changed. It may restore proper value to parts of a datasample, or it may incorrectly bias the data. A weighted moving average is expressed in itsgeneral form as
DS wRW= wiPrt WePrart 1 + WaProne feWy t+Wyto tw,
aThis gives the weighted moving average at time ¢ as the average of the previous 7 prices, eachwith its own weighting factor w,. The most popular form of this technique is called front-loaded, because it gives more weight to the most recent data and reduces the significance ofthe older elements. Therefore, for the front-loaded weighted moving average (see Figure 4-1)
W,2W2 2+ > Wp,THE MOVING AVERAGE 69
 
The weighting factors w, may also be determined by regression analysis, but then they maynot necessarily be front-loaded. A common modification to front loading is called stepweighting in which each successive w, differs from the previous weighting factor w,_, bya
fixed incrementC= W,-Wj,-4The simplest case takes integer values for an n-day step-weighted moving average:
wWy=nw2z=n-1W,=1
This gives the weighting factors the values of 5, 4, 3, 2, and 1 for a 5-day average. A com-puter program for calculating a linearly weighted moving average is
 
FIGURE 4-| A comparison of moving averages.
—— Daily prices3-Day ma.~*~ 5-Day ma.010 -Day ma.5-Day modified0 0 0 ooAccumulated
 
63.00
 
 
PRICE (cents)
 
Dee eo een eeSESF€FEsssas
Wt
WHS1/4Ws18Ws
1/10VthVWs/t2VTSWW16VV™ N1911/2270 TREND CALCULATIONS
 
for 1=1 to N begin- 141; 'sum + M*price;
 
123456 LWMA = sum/ ( N* (N+1) /2)
In line 6, the divisor (N*(N+1))/2 is the arithmetic formula for the sum of 1+ 2 +--+ +N.Another approach would be a percentage relationship between w; elements,
W;-.= AX UW;where a = .90; then, ws =5, ws = 4.5, ws = 4.05, w, = 3.645, and w, = 3.2805.
Prices may also be weighted in groups. If every two consecutive data elements have thesame weighting factor,
_ WP, + WPy_y + W2Pr—2 + WP — 3 + 1 + WP rna 2X (Wy t+ wrt + + Wap)or, grouped with 7 even,w(P, + Pr 1) + W2(Pr-2 + Pra) $1 + Wap (Prens2 tPr-ne)2X (Wy + W240 + War)
 
W,=
Any number of consecutive data elements can be grouped for a step-weighted moving aver-age. Because there can be any number of combinations, there is no simple, automaticmethod for calculating anything other than a linearly weighted average, which is the func-tion @WAverage(price, length) in Omega’s Easy Language. If the purpose of weighting isto duplicate a pattern that is intrinsic to price movement, then the following sections ongeometric averages and exponential smoothing may provide better tools.
. These moving averages can also bé plotted in different ways, each way having a majorimpact on their interpretation. The conventional plot places the moving average value MA,on the same vertical line as the last entry P; of the moving average. When prices have beentrending higher over the period of calculation, this will cause the value MA, to lag behind(or below) the actual prices, when prices are declining, the moving average will be abovethe prices (see Figure 4-2).
The plotted moving average can either /ead or lag the last price recorded. If it is to leadby 3 days, the value MA, is plotted on the vertical line ¢ + 3; if it is to lag by 2 days, it is plot-ted at t- 2. In the case of leading moving averages, the analysis attempts to compensate forthe time delay by judging price direction using a forecast based on current rate of changeand direction. A penetration of the forecasted line by the price may be used to signal achange of direction. The lag technique may also serve the more sophisticated purpose ofbbasing the moving average. A 10-day moving average, when lagged by 5 days, will be plot-ted in the middle of the actual price data. This technique will be covered later.
Comparison of Moving Average Methods
The comparison seen in Table 4-3 confirms that simple moving averages taken over shorterperiods identify shorter trends. The 3-day moving average trendline had 9 separate trends,while the 10-day had only 5. The 5-day average modified method was very similar to the 10-day simple moving average due to removing the average price each day. The cumulativeaverage showed the fewest trends even though it began its accumulation process only 10days prior; as time increases, this trend will become less responsive. For this short sampleinterval, the 10-day linearly weighted average was identical to the average modifiedmethod and very similar to the 10-day simple average; however, because it weights therecent data 10 times greater than the oldest, this similarity will not continue. A closer lookwill! show that the trend values are very different.THE MOVING AVERAGE 7nS
ENFIGURE 4-2 Plotting lag and lead for a | 0-day step-weighted moving average with weightingfactors of 10,9,8,....
 
— Daily pricesStep- weighted m.a.eeeee Lag plot of ma.0.0000 Lead plot of m.a,
63.00
 
62.00
 
 
61.0032&wg=€60.0059.00 ,58.00SQPLSASH- NHOTBONAAHARL LOEFEGESSSSESEEEESHESSSES Essa- DATETriangular Weighting
While the simple moving average or linear regression treats each price equally, exponentialsmoothing and linear step weighting puts greater weight on the most recent data. There isan entire area of study in which the period of the dominant cycle is the basis for determin-ing the best trend period. Triangular filtering’ is a related concept that attempts to uncoverthe trend by reducing the noise on both the front and rear of the trend window, where it isexpected to have the greatest interference. Therefore, if a 20-day weighted average is used,the 10th day will have the greatest weight, while days 1 and 20 will have the smallest.
To implement triangular weighting, begin with the standard formula for a weightedaverage,
S whi
2 -
1
  
JJ. Payne, “A better way to smooth data,” Technical Analysis of Stocks & Commodities (October 1989).TABLE 4-3 Comparison of Moving Averages Methods*
 
 
-s, ; 5-Day 10-D
__‘Simple Moving Averages _ Average Cum nearly
Price 3-Day 5-Day 10-Day Modified Average — Weighted930316 64.59930317 64.23930318 65.26930319 65.24930322 65.07930323 65.14930324 64.98930325 64.76930326 = 65.1930329 65.46930330 65.94930331 66.10930401 66.87930402 66.56930405 66.71930406 66.19930407 66.14930408 66.64930412 67.33930413 68.18930414 67.48930415 67.19930416 66.46930419 67.20930420 67.62930421 67.66930422 «67.89930423 69.19930426 69.68930427 69:31930428 69.11930429 69.27930430 68.97930503 69.11930504 69.50930505 69.70930506 69.94930507 69.1930510 67.64930511 67.75930512 67.47930513 67.50930514 68.18930517 67.35930518 66.74930519 67.00
930520 67.46930521 67.36930524 67.37930525 67.78 f 42" . sf930526 67.96 67.70 67.59 67.47 67.65 67.22 67.50 |
No. Trends it} 9 5 5 3 5
 
 
*The gray areas of the table show downtrends,THE MOVING AVERAGE B
 
where 7 is the size, or width, of the window. The weighting factors w, will increase linearlyfrom 1 to the middle of the window, at 7/2, then decrease to the end at n. This has a slightlydifferent form when the period is odd or even,
w; =i, for i = 1 to @intportion((nt2)/2)n-it+l, for i = @intportion((n+2)/2) + 1 ton (even values of 7)n-i, for i = @intportion((n+2)/2) + 1 tan (odd values of 7)
where, for odd values of 7, the weight factor has the value i when ranges from 1 to n/2(rounded up using the function for the integer portion) and the value of n — 7 from 7/2 ton. Instead of a triangular filter, which is very precise about the middle value having thegreatest importance, we may choose a Gaussian filter, which weights the data in a formsimilar to a bell curve. Here, the weighting factors are more complex,
i \2w,= 10° and =3(1 -4)
Pivot-Point Weighting
Too often we limit ourselves by our training. When a weighted moving average is used, itis normal to assume that all the weighting factors should be positive; however, that is nota requirement. The pivot-point moving average uses linear weights (e.g., 5, 4, .. ..) thatbegin with a positive value and continue to decline even when they become negative.” Thismethod treats the oldest data in a manner opposite to their direction. In the following for-mula, a pivot point, where the weighting is zero, is reached about % of the way through thedata interval. For a pivot-point moving average of 11 values, the 8th data point is weightedwith 0:
PPMA,(11) = (7P, + 6P, + 5P, + 4P, + 3P, + 2P, + LP, + OP, — LP, — 2P, - 3P,)/22°
This technique is intended to limit the lag by front loading the prices and reducing the divi-sor of the weighting formula by the sum of the negative weighting factors. The general for-mula for an 7-day pivot-point moving average is?
 
- 32 n .PP: ‘n) = ——— 3i-~n —-1)P,MAC) = 2, 6 PrTo implement this in a computer program, the following steps would be used:1 sum = 0;2 for I to N begin3 M=N-1T 41;4 sum = sum + P[M]*(3*I - N - 1);5 end;6 PPMA = sum*(2/ (N* (N+1)))
where lines 2 through 5 calculate the sum of the prices times the weighting factor, and line6 divides that sum by the sum of the weighting factors (after multiplying the top and bot-tom of the fraction by the value 2).
The negative weighting factors reverse the impact of the price move for the oldest datapoints rather than just give them less importance. For a short interval this can cause thetrendline to be out-of-phase with prices. The application of this method should be limitedto longer-term cyclic markets, where the reflection point, at which the weighting factorbecomes zero, aligns with the cyclic turn or can be fixed at the point of the last trendchange.
? Patrick E. Lafferty, “End-Point Moving Average,” Technical Analysis of Stocks & Commodities (October 1995).3 Don Kraska, “Letters To S&C,” Technical Analysis of Stocks & Commodities (February 1996, p. 12).14 TREND CALCULATIONS
 
GEOMETRIC MOVING AVERAGES
The geometric mean is a growth function that is very applicable to long-term price move-ment, introduced in Chapter 2 (“Basic Concepts”). It is especially useful calculating thecomponents of an index. The geometric mean can also be applied to the most recent npoints at time f to get a geometric average similar to a moving average
” (in)Gee Bex Peer Ko XK Prone 1M = (1 Peis)ts]
The daily calculation is more complicated but, as shown in Chapter 2, could be rewrittenas
In P+ In Py-1 +77 +10 Pye netn
Lye=3(2 InP,-1)nin
This is similar in form to the summation of.a standard moving average based on the arith-metic mean and can be written for either spreadsheet or program code as
In G,=
GA = @average(@log(price) ,n) *
Note that some software will use “log” although the calculation is actually the natural log,
In. Other programs will allow the choice of @log(value) or @1n( value). A weighted geo-
metric moving average would-have the form
win P,+ w2 InP, y+wy + w+
+, In Pr-nerWw,
   
InG,=
> wn Pres
i=
The geometric moving average itself would give greater weight to smaller values withoutthe need for a discrete weighting function. In applying the technique to actual commodityPrices, this distinction may not be obvious. For widely ranging values such as 1,000 and 10,the simple average is 505 and the geometric average is 100, but for the three sequentialcocoa prices, 56.20, 58.30, and 57.15, the arithmetic mean is 57.2166 and the geometric is57.1871. A similar test of 5, 10, or 20 days of commodity prices will show a negligible dif-ference between the results of the two averages. If the geometric moving average is to behelpful, it would be best applied to long-term historic data with wide variance, using yearlyor quarterly average prices.
DROP-OFF EFFECT
Two types of trending methods can be distinguished by the drop-off effect, a common wayof expressing the abrupt change in value when a fixed-period calculation drops off a sig-nificant value. A simple moving average, linear regression, and weighted averages all use afixed period, or window, for determining the trend. When an unusually volatile piece ofdata becomes old and drops off, there can be a sudden jump in the trend value, called thedrop-off_effect. For an 7-period moving average, this value is the difference between thefirst and the last items, divided by the number of periods,
drop-off effect = (P,— P;-,)/nEXPONENTIAL SMOOTHING 15
 
A weighted average, in which the oldest values have less importance, reduces thiseffect