, such as crude oil,may have a different pattern.Both low and high price levels vary with inflation and structuralchange. Again, low prices do not present a difficult problem. If youwere trading a long-term moving average for copper, and prices dippedbelow 50 cents per pound, there would be limited opportunity for profits by going short. Yet a short position at 45 cents would have nearly the
228
Making a Trading Strategy Robust
Box 11-1. CALCULATIONS FORANTICIPATING SIGNALSNotation usedprice
"today's" price
price[1]
the previous price
price[n]
the price n-days ago
next_price
"tomorrow's" price, or the next period price
min_move
the minimum rise or fall from the previous indicator value needed to give a signal
uy_signal
the price that would generate a new buy signal
sell_signal
the price that would generate a new sell signal
Moving Average
.
@moving_average(price,n) = @sum(price,n)/nwhere n is the number of periods.The next price needed to generate a new buy or sell signal, where themoving average value rises or falls by the min_move:buy_signal = pricefn] + n*min_movesell_signal = price[n] - n*min_move
Improving the Performance of Existing Systems
229
Box 11-1. (Continued)For a spreadsheet (in typical row 75), and a 10-day moving average,this becomesColumn A:Column B:Column C:Column D:Column E:Column F:
DatePrice@ Sum(B75. .B66) Sum of past 10 days+C75/1010-day moving average@ Sum(B75. .B67) Sum of past 9 days (MA less 1)+D75 + 1Buy signal is minimum upmove formoving averageColumn G: +D75 — 1Sell signal is minimum downmove formoving averageColumn H: +F75*10 - E75Lowest price to give a buy signalColumn I: +F75*10 - G75Highest price to give a sell signalExponential Smoothing@exp_ma(price,sc) = ema = ema[1] + sc x (price - ema[1])where sc = the smoothing constant expressed as a percentageema = the value of the trendlineThe next price needed to generate a new buy or sell signal is:
@buy_signal = ema.+ min_move/sc@sell_signal = ema - min_move/sc
Momentum (Price Difference)@momentum(price,n) = price - price[n]The next price needed to generate a new buy or sell signal is:@buy_signal = price - price[n] + price[n - 1] + min_ move@sell_signal = price - price[n] + price[n - 1] - min_move
230
Making a Trading Strategy Robust
same risk as a short entered at 60 cents. As prices reach absolute lows,the profit potential for short positions decreases faster than the risk.High prices are different. The tail of the price distribution is very longon the upside, which means that prices can move up to surprisinglyhigh levels. Even adjusted for inflation and other economic factors, it isdifficult to tell where a new long position has greater risk than reward.To make it more complex, some programs perform better when pricesand volatility are high.A scatter diagram, as shown in Figure 11-2, can be used to find anentry price for a crude oil trend-following system. It plots the entryprice level against the resulting profit/loss. The trades have been separated so that Figure 11-2(a) has only the long positions and (b), only theshorts. Oil is an interesting example because OPEC tried to hold the official selling price at a fixed level, about $20/bbl during this period. Othermarkets have their own patterns, equally as interesting.Trend Longs. Crude oil gives a clear example of the risks associatedwith entering at a relatively high price. Long positions (see Figure ll-2(a))generate many small profits and losses, and a few larger profits, belowentry levels of $25/bbl. Most losses are clustered together and are less than$4/bbl, while profits net as much as $12/bbl. Frequent small losses and afew large profits comprise a profile typical of a trend-following system. Atentry prices above $25 /bbl, there are only losses, and those losses have apattern of getting larger as the entry price increases.The total picture seems very understandable. There is less opportunity and more volatility when long positions are entered at very high levels. Of course, without a diagram such as this, it would be difficult toknow what was "high." Because we know that OPEC targeted an official selling price of about $20/bbl. during this test period, other patternscan be seen. For example, profits dropped as the entry price neared $20.Larger profits were made when oil prices dropped well below the OGSP(Official Government Selling Price). Unfortunately, this analysis benefits from hindsight. If OPEC's target price had dropped to $18/bbl, wecould have expected a decline in profits for long positions entered nearthat level. We could have reasonably expected the same performancepattern, centered around a new level. Had we chosen a longer test period, including oil prices that were stable at $30 /bbl, the pattern wouldnot have been nearly as clear because it would have included more thanone target area.Trend Shorts. We would expect to have more opportunities for profitby setting new short positions at high prices. Figure ll-2(b) shows that one
231
Improving the Performance of Existing Systems
(a)
10
15
2025Entry Price ($/bbl)(b)
30
35
Figure 11-2. WTI (NTMEX) trend system entry price levelversus profit/loss, (a) Long positions, (b) Short positions.Plotting the entry price against the resulting profits or lossesgives you an opportunity to identify, in advance, the tradesthat should not be taken. For a trend-following system appliedto WTI during the period when OPEC's target price was about$20/bbl, we see in (a) that long positions entered above $ 2 5 /bbl consistently lost. With OPEC's ability to increase supplywith relatively short lead time, any immediate imbalance insupply and demand could be corrected quickly. Trend profitshad no time to develop. The short positions in (b) showed losses when entered under $15/bbl and higher risk over $25.
232
Making a Trading Strategy Robust
trade produced a profit just under $14,000 on a 1,000-bbl contract, and fourother short positions, entered above $25, posted larger than average losses. As expected, shorts entered below $15/bbl, a relatively low level, alsoproduced losses. The pattern shows that volatility, for both profits andlosses, increases as the price increases.Price Level, Profits, and Risk. Unadjusted price levels, plottedagainst profitability, paint an understandable picture. Neither inflationnor price evolution can alter the fact that entering new shorts at low levelshas little opportunity and unattractive risk. Buying at high prices is neveras clear, but experience indicates that the risk of a large loss is muchgreater than the opportunity for any profit. Market factors should promptperiodic reevaluation of those levels, but only a simple analysis is neededto see the obvious benefits.
Filtering VolatilityThe volatility at the time of entry is a more dependable indication ofexpected profits and losses. Even more important, high volatility meanshigh risk. A trade that has a good chance of being a loss, and includeshigh risk, is an excellent candidate for elimination. Figure ll-3(a) showsplots of the same WTI trades seen in Figure 11-2, this time using entryvolatility against profits and losses. Volatility was calculated as the10-day average of the absolute price changes (in $/bbl).Filtering Volatile Long Entries. Figure ll-3(a) shows a similar, butslightly regrouped, pattern as the one in Figure ll-2(a), where entry pricewas used. A steady pattern of losses appears when long positions areentered during high volatility. The chart shows that these cases of highvolatility also occurred at high price levels. Longs set during periods oflow volatility were profitable, and some do not correspond to the lowestprice levels, which showed some losses.Filtering Volatile Short Entries. Short positions are different whenplotted against volatility rather than price entry. Many of the trades arepushed to the far left where they are entered at about the same volatilitylevel, and the remaining five trades were set when volatility was from 2.5to 6 times greater. The trades entered on high volatility were predictablylarger losses.
Improving the Performance of Existing Systems
(a)
(b)
Figure 1 1 - 3 . WTI (NYMEX) trend system entry volatilityversus profit/loss, (a) Long positions, (b) Short positions.When entry volatility Is plotted against profits and losses, thepattern Is clearer. For both longs (a) and shorts (b) losses continue to get bigger, moving down and to the right on the chartsas the volatility Increases. The large profit from entering ashort at $27/bbl In (b) Is seen to have occurred during a relatively normal period of volatility. Very low volatility is a reasonto filter any trade.
233
234
Making a Trading Strategy Robust
Using FiltersThe charts for filtering trend-following trades using entry price andvolatility show the simplest choices and the clearest results. Althoughthis example only used crude oil, the same patterns will appear for othercommercial and industrial products, where there is a real high and lowlevel. Currencies are different and more complex. There are no absolutelevels for exchange rates. The temporary normal levels are set by eachcountry based on their relationship with trade partners. When the currency is at an acceptable level/or equilibrium, volatility is low. Whenprices move away from equilibrium, by becoming either stronger orweaker, they become more volatile. You might consider a currency priceas "high" when it is away from normal, and "low" when it is at the normal level. For currencies, volatility is the only measurement that counts.ExpectationsFiltering trades is a clear way to improve performance, where there area few concepts are fundamentally sound. Using volatility does not necessarily improve profits, but it should always reduce the risk more thanthe profits, giving a much better performance profile.Programming Rules for FiltersThis method of filtering was chosen because the volatility calculationcan be made at the time of the entry decision. If the volatility is too high(or too low) then the trade is not taken. The following steps are necessary to find the best filters for a trend-following system:1. Select a trend-following method, such as an exponential movingaverage.2. Produce a table of all trades, summarizing the net profit and lossfrom long and short positions separately.3. Calculate the volatility at the time of entry. Use the sum of theabsolute price changes over, for example, 5 days (as in the crude oilexample).4. Move the position (long or short), entry volatility, and profit/loss toa spreadsheet. Move entry price if you intend to do a price-levelanalysis.5. Plot all the long positions on a scatter diagram with volatility versusnet profit/loss. Plot the short positions in the same way.
Improving the Performance of Existing Systems
235
6. Visually identify the levels of highest risk and consistent losses. Youmay want to eliminate all trades with entry volatility either too highor too low.7. Add the volatility filter(s) to the trend system by testing volatility atthe same time that a trend entry occurs.
Reversing theOptimization ConceptIn Chapter 10, broad-based testing (called "optimization") is used toevaluate the merits of a trading strategy, or to see if a change of rulesimproves overall results. We anticipated large regions of profits, allowing us the latitude of selecting from many parameter combinations, anyone of which would trade successfully. Now consider the worst results.It is common to see erratic patterns of profits and losses in the fast trading zone. If these losses are not caused by transaction costs, they indicate a very good place to enter a new trade in the direction opposite tothe long-term trend position.For example, a long-term trend produces two trades per year, while acomparable 5-day model generates one new trade each week. Both fastand slow models have a buy signal at the same time. We expect that overthe longer interval the trade will be profitable, while the short-term signal has a high likelihood of being a loss. This tells us that, in the shortterm, prices should be lower than the immediate entry point; otherwise,the short-term trade would tend to be profitable. It is not a good time toenter the long-term trade, nor is the timing of a longer trade particularlyimportant (as seen in the section, "Anticipation," earlier in this chapter).Trading RulesSoon after the long- and short-term signals occur, the short term is closedout with a loss. If our timing is right, the faster model now goes short.Because this position is also expected to be bad, we set part of our long position. If the fast system produces a loss, our timing would have been good.A sensible plan for systematizing entry points that follows from thisreasoning is:1. Select a long-term profitable trading strategy for determining marketdirection.2. Select the short-term strategy with low reliability and losses notincluding transaction costs.
236
Making a Trading Strategy Robust
3. Enter V3 of the trade when the long-term model gives a (buy) signal.4. Then enter % of the trade when the short-term model closes out a(long) position.5. Finally enter V3 of the trade when the short-term model enters anopposite (short) position.The market will give signals when it is volatile, appearing to showimmediate profits. Most often, these fast-moving markets have veryhigh slippage, and reverse sharply once the initial momentum lapses.Placing an order for V3 or Vt of the full position gives you an opportunity to decide objectively whether this method improves the performanceof the basic approach. The last 2/3 of the liquidity is set while prices aremoving contrary to your objectives; therefore, slippage should be low.
Overnight RiskMoving through Time ZonesOpening price gaps can cause windfall profits or losses, and increaseoverall risk. They represent uncontrollable risk. For many financialmarket and foreign exchange traders who watch the U.S., European, orFar East markets only during their business hours, that risk can be sizable. For the growing number of traders who have facilities to follow amarket as it moves through time zones, it is possible to reduce a largepart of the risk.Expanding liquidity in world markets allows nearly continuous, 24hour trading. Agreements between major exchanges make executiontransparent with regard to order placing and margining. You can buy inChicago during the morning and sell in Singapore 12 hours later by calling the same local trading desk. Or, you can use Globex or any of a number of other electronic exchanges with growing liquidity and great convenience.To understand the importance of opening gaps, Table 11-4 comparesthe size of the average opening gap with the daily close-to-close pricemove for a broad selection of futures markets. Figure 11-4 gives the percentage of the opening gap relative to the net daily move.Favoring Primary MarketsThe results show that primary markets have smaller opening gaps andless risk. U.S. bonds, trading on the Chicago Board of Trade representthe primary market for bonds during its normal business hours.
237
Improving the Performance of Existing Systems
Table 11-4. Overnight RiskTotal PointsExchange
Open
Close
Days
Day
%
Financials
CBTU.S. BondsMM U.S. T-BillsLIFFE EuroyenLIFFE German BundLIFFE JGB
126.711.171.839.9114.60
515.8720.398.6720.2622.57
1280369100142122
0.100.030.020.070.12
24.654.821.148.964.7
Currencies
IMM D-Mark (in %)IMM British Pound
2.180.89
3.801.07
1056167
0.210.01
57.483.2
Metals
CMXGoldCMX Silver
2292586
3104380
2421056
0.952.45
73.959.0
Other
NYMEX Crude OilCBT SoybeansCME Pork Bellies
10.971141416.7
20.262295916.8
1425971056
0.081.910.39
54.149.745.5
20
30
40
50
60
70
Representedby OpeningGap Markets withFigure 11-4. Opening gaps Percentas a percentageof thedally move.
active 24-hour trading and those whose primary markets are closed show muchlarger opening gaps than exchange-traded markets that are open at the same timeas their primary cash market. These large opening gaps translate into uncontrollable risk.
238
Making a Trading Strategy Robust
Similarly, the Euroyen traded on the London International FinancialFutures and Options Exchange (LIFFE) is active during its primarymarket. These showed the lowest impact of opening gaps, 24.6 and 21.1percent, respectively.The worst performer, the British pound trading on the IMM, had 84percent of its move overnight. We can conclude that during the timebetween the London opening and the IMM opening about 5 hours later,most of the financial news affecting the sterling was already in the market. Prices had moved to their proper level and the IMM was faced with"catching up." The Japanese Government Bond (JGB) traded in Londonis similar. Most of the news relevant to the JGB occurs while the LIFFEis closed, therefore 64.7 percent of the daily move is missed due to theopening gap.The average level of overnight risk might be as high as 50 percent. Wecan account for the large gaps in gpld by recognizing that it is an international store of value; therefore, it is traded around the world.Soybeans and pork bellies are fairly domestic markets, yet show highovernight risk. From this, we should expect that these gaps will addslippage to both entries and exits.
Leverage, Costs, andTrend SpeedLeverage and transaction costs.exert an overwhelming influence on atrend system, and they define a basic difference between stock andfutures trading. Futures markets require a margin deposit of only 5 percent to trade most markets; it can be much lower for currency spreadsand as high as 10 percent for a stock index. Using a slower trend fortrading causes positions to be held longer and results in larger equityswings. Faster trends are often used because the risk per trade isreduced although the sequence of profits or losses that form the totalequity variation may not change.The best reason for using a faster trend-following approach is that itoffers more distinct opportunities for entering and exiting the market. Ifyou had the choice of two systems, a 25-day moving average and a 50day moving average, each returning the same profit/risk ratio withtransaction costs considered, the faster 25-day program would be thetempting choice. More trades allow the following:• Profit objectives to be set closer and reached more often• Smaller individual losses
239
Improving the Performance of Existing Systems
• The application of trend timing to other objectives, such as hedging• The variation of position size by tradeIn general, more trades mean a better sample, hence a more realisticresult. These advantages must be offset against the fact that longer trendsare often successful because they parallel government policy and fundamental influences. A 200-day trend in U.S. Treasury bonds might haveheld a long position for three years, netting exceptionally large profitsand offsetting losses in real estate or other weaker parts of a portfolio.Transaction costs are negligible in the financial and futures markets.A contract with a $100,000 face value can be traded (round-turn) by anactive investor for as little as $10, or 1/10,000 of its value, while a 1 percent charge would not be surprising for an individual stock trader. At 1percent, one stock trade every two weeks takes no less than 26 percentfrom your trading profits each year. Gross trading profits must exceed40 percent per year just to be better than a passive stock portfolio.Because of high commission costs and the slippage associated withfrequent trading, many stocks show gross profits (without transactioncosts) for tests of fast moving average systems. This profit windowexists because small traders cannot benefit from a program where theprofit from each trade is less than V2 percent. Institutions cannot tradeenough volume, nor would they want to appear that active, in order totake advantage of a small window. Therefore the opportunities remain,waiting for a change in the market or the players.Figure 11-5 shows how faster trading, which must have smaller profits, is greatly affected by transaction costs, while long-term positions are
PiONithout Cost*
ooa.
Fast
Trend Speed
Slow
Figure 11-5. Effects of transaction costs on performance. Faster, trading must overcome large transaction costs to be profitable.
240
Making a Trading Strategy Robust
relatively unaffected. Highly leverage trading, such as futures andforex, exaggerates this pattern further. A cost of .0002 for each entry andexit for the Deutsche mark is only .025 of 1 percent based on full value;however, 5 percent margin makes that .5 (Vfc percent), 20 times larger. Asmall trader can expect to pay more than twice that rate.It may be difficult to see the advantages of slower trading over faster.The ability to leverage an investment allows smaller profits to be largepercentages. Testing without the correct transaction costs, includingcommission, slippage, and unables, will often make the results appearto favor the faster trends, while the slower ones always hold the advantage. Large profit objectives of 200 basis points will absorb many problems that will hurt fast traders looking for 20 basis points in theDeutsche mark. Results will be more realistic, price shocks will have asmaller effect, and fundamentals will enhance the positions. Being realistic about leverage, profits, costs, and risk translates into staying powerand success.
Appendix
Notation andTerminologyLotus and Quattro spreadsheet notation, Telerate's TeleTrac, arWOmega's Easy Language are used throughoutjfKe book. They replace the~-—^normal mathematical symbols and should be familiar to most Readers.Some of the examples use a general notation, similar to alToTthem, butnot exactly the same. This is shown in the following list. When a specific spreadsheet or computer language is not indicated, the examplesuse this form.
Mathematical Operators+—*/A
AdditionSubtractionMultiplicationDivisionPower
Relational Operators<<=>>==<>
Less thanLess than or equal toGreater thanGreater than or equal toEqual toNot equal to
241
242
Appendix
Logical Operators(TRUE/FALSE)NOTANDOR
Negates the TRUE or FALSE meaning of the following variableBoth variables must be TRUEOnly one of the variables must be TRUE
Referencing Past Values ofData and VariablesClose or Close[0]Close[1]Close[n]
Current value of today's closePrevious value of the closeValue of the close n periods ago
IP StatementIF condition, then TRUE expressionExample:IF close > close[1 ] then BUY at close
If today's close is greater than theprevious close, then BUY at the close.(If this statement is not true, go to thenext statement)
FunctionsSimple trading rules, indicators, mathematical and logical operationsare done automatically by most spreadsheets and computer testing programs. Those functions will be shown using an "@" in front of the function name. The ones used most often in this book are:Mathematical F u n c t i o n s@ abs_val(x) The absolute (positive) value of x@ power(x, p) Raises X to the power p@ sq rt(x) Square root of X
243
Notation and Terminology
Statistical Functions@average(list)@count(list)@highest(iist)@lowest(list)@median(list)@std_dev(list)@sum(list)
Average of listNumber of items in listThe highest value in listThe lowest value in listThe median (middle) value in listThe standard deviation of listThe sum of values in list
Technical Indicatorsand Studies@momentum(series,n)@average(series,n)
The n-day difference in the value of seriesThe average of the most recent n-days
@ exp_ma(series,p)
Exponential smoothing of series bypercentage pPreset weighted average of series over nvaluesRaw stochastic value of series over n valuesSmoothed raw stochastic (same as %D) of@fastK over n valuesSmoothed ©slowK stochastic over n valuesRelative Strength Index of series over nvalues
of series
@weighted_average(series,n)@fastK(series,n)@slowK(series,n)@slowD(series,n)@RSI(series,n)
Other TerminologyThe word "fundamentals" will be used differently when referring tostock market or commodity market situations. Dividends and P / Eratios make up part of equity fundamentals, while supply, demand, andgovernment policy are the fundamentals of forex and commoditymarkets.
IndexAdaptive moving average:calculation of, 138,140-141codes:Easy Language, 151-153TeleTrac, 150efficiency ratio and, 140-141examples of:Castrol, 139Deutsche mark, 139,142-143programming, 147testing, 146Agricultural markets, 16Annualized compounding, 43Anticipation:calculations for, 228-229executions, 225false, 225large orders, 225price calculation, 226quote equipment, 227significance of, 223trend speed and, 223-225Arbitrage:computer technology and, 4,38trade-offs, 32ARIMA (Autoregressive IntegratedMoving Average) models, 10Artificial intelligence:application of (see Expert systems)defined, 12fuzzy logic, 171-173neural networks, 164-171pattern recognition, 12,160types of, generally, 12,157Artificial neural network (ANN) (seeNeural networks)Asset allocation:efficient frontier curve, 51fast-netting method, 60-61return/risk ratio, 53
At the market orders, 22Bank of England, 27Bank trading, impact of, 4BASIC, 186Best Choice Index, testing process, 181,204,207-208Best Choice test, 47Bolton-Tremblay Index, 9Bond market, during recession, 19Bond portfolios, currency vs., 46Breakout system, 22Brokerage fees, 22Buy and sell signals:alternate rules, 145-146trading rules, 143C, 186Capitalization, trading safety, 49-50Cash markets, testing, 193-194Castrol, adaptive moving average example, 139Chicago Board of Trade, 236Chi-square test, 221-223Closing prices, 20-22Commodity arbitrageurs, 32Commodity price, determination of,6Commodity Trading Advisors, performance measurement, 55-56Common sense, risk reduction strategiesand, 61-65Competition:arbitration and, 32impact of, 4Compounded annualized rate of returnformula, 199Compounded rate of return, 42-43
34B
246Computer learning:artificial intelligence, 157-160expert systems, 160-164neural networks, 164-171price application, 156-157teaching process:erector set illustration, 158-159significance of, 156-157Computer software, strategy-testing,10Computer technology, impact of, 3-4CompuTrac, 186Confidence level, 5-6Consumer Price Index (CPI), 5,115Contour map, 100-102, 204-205,210Corporate earnings, 5Correlations:forecasting, 63risk reduction and, 57-60time periods and, 62-63Countertrend systems:expectations and, 31stop-losses and, 103trade-offs, 32CQG, anticipated price calculation, 227Crude oil:trend-following test, 14-15trend longs example, 230Currency:bond portfolios vs., 46floating, 12
Daily compounding, 43Data:accuracy of, 192amount of, 37-38,189-191,214artificial series, 119-120gap-adjusted series, 195-196integrity of, 215-216risk assessment, 119selection of, 192-193testing, 193-194Deleveraging, 104-105Deltas, 220Derivatives:leverage and, 46risk reduction strategy, 55-56structural changes and, 16Detrended equity, 43
IndexDeutsche mark:adaptive moving average example,138-139,142-143closing prices, 21price shocks and, 115-117stop-loss tests, 100-102trading activity, 13Discretionary trading, 38Dividends, 5Dow, 15Easy Language, adaptive moving averageprogramming, 147,151-153Econometric analysis, 37Economic evolution:effect of, 12-13,17maturing markets:new markets compared to, 13,15price trends and, 12-13Ef ratio, 11Efficiency ratio:adaptive moving average and, 140defined, 134-135mapping, 136Efficient frontier curve, 51Elliott waves, 10Entry points, systematizing plan,235-236Equity markets, 5Equity patterns, types of, 42Errors of omission, 214European Currency Unit (ECU), 16European Monetary System (EMS), 3,12,27-28,115,193Execution:anticipation and, 225price strategies, 25problems, types of, 22-23stop-losses and, 93-94Expectations, significance of, 40Expert systems:computer technology and, 38conflict resolution, 163-164defined, 12forward chaining, 161-163knowledge base, 163terminology, 160-161validation,