profitability of your system. Although stop-lossreduces the risk of a single large loss, it can generate a series of small losses, whichin total can exceed the single loss. According to a study by William Chan publishedin the Journal of the Market Technicians Association (see Bibliography), after
Trading System Design
167
back-testing fixed % and trailing % stop-loss conditions on both trend-followingand mean-reversion trading strategies the author concluded that “The results fromour tests indicate a significant negative correlation between the value added byapplying these stop-loss rules and the profitability of the trading strategies tested.In other words, there was a tendency for these stop-loss mechanisms to underminethe performance of the profitable trading strategies tested and improve that of theunprofitable ones in the test”(my italics). Based on my experience in developingtrading systems, I have also noticed that stop-loss conditions improve systems withpoor exit conditions but tend almost always to degrade the profitability of a systemwith good and timely exit conditions. This is because an unrealized loss caused byan excessive price spike might be recouped by continuing with the trade insteadof being converted into a realized loss on liquidation.• The frustration involved in being stopped out of a position, only to have the marketturn around, will prevent the trader from re-entering a good trade.In conclusion I would have to agree that even though stops do not necessarily improvethe final profitability of the results of a trading system they certainly contribute toa trader’s peace of mind and prevent catastrophic losses in the case of unforeseenevents. In a sense, stop-losses can be compared to premiums on an insurance policyand should be considered as an unavoidable cost of doing business.
10.5
PROFIT TARGETS
The use of profit targets is not uncommon, but in general they run contra to thepopular principle “cut your losses short and let your profits run”.Profit targets effectively exit a trade once a predefined amount of profit has beenachieved. Below are some variants of profit exits:• Percentage based. This is the simplest method. The profit taking target is measuredas a percentage of the initial price when entering the trade.• Double objectives. This is similar to the first method with the difference that twoprofit targets are used, spaced further apart as profits get larger. Half of the initialposition is liquidated upon reaching each target. This method has the advantageof increasing the chance of reaching at least one of the objectives while removinghalf the risk.• Price level based. The target is usually set at a price level of technical significance,i.e. a support or resistance. In the case of technical systems based on patternrecognition the profit target is applied according to the specific formation. In thecase of flag, pennant and rectangle formations I have derived statistically a formulato calculate the appropriate price target in my articles in the April 2005, May2006 and June 2007 issues of Technical Analysis of STOCKS & COMMODITIES
168
Intermarket Trading Strategies
(see Bibliography). You can also find the formula for calculating the price objectiveof rectangle formations in Appendix C.• Indicator based stop. This is triggered by an indicator such as a stochastic reachingan overbought level in range bound markets.
10.6
MONEY MANAGEMENT
Money management concerns the actual size of the trade to be initiated, with consideration of account equity and potential for trade risk. It is extremely important for atrader to scale trading positions relative to available capital.Effective money management is related to the risk of ruin, which can help determinethe amount of capital needed to trade a given system. Effectively, the risk of ruinincreases as the amount per position increases, and decreases as the probability ofwinning increases, or as the payoff ratio increases.As every trade carries a potential for loss, there is a need to determine the maximumamount of capital to expose at each trade, given a finite capital base. There are anumber of approaches in common usage. For example, the traditional Kelly system(see Money Management Strategies for Futures Traders by Balsara) evaluates thefraction of capital to expose, f , as the difference between the probable expectedwin and the amount expected to lose. Other methods include Vince’s optimal f(see Bibliography). Monte-Carlo analysis can also be used to determine the optimalmoney management strategy by optimizing f according to the probability of successor failure.
10.7
NEURAL NETWORKS
Artificial neural networks are well suited in quantifying complex relationships between interrelated markets because they address the nonlinear nature of financialtime series. The concept behind neural networks was originally brought forth almost50 years ago and had its origin in studies of the mechanisms by which the brainlearns. Neural network software is designed to mimic the working of the human brainwhen solving problems; they use information that the network has learned in solvingproblems with known outcomes, to solve similar problems with unknown outcomes.Neural networks consist of highly complex nonlinear models that use variousoptimization techniques to find the model that most closely gives the output corresponding to the input. They select which of the inputs are relevant in predicting theanswer and assign weighting factors to produce the correct forecast. The predictedoutput is based on the training, so it is critical that a relationship is present betweenthe variables.Neural network software are composed of three types of neuron layers: an inputlayer, one or more hidden layers, and an output layer. Transform functions serve
Trading System Design
169
as the connectors or neurons. During training, the transform functions establish theweights of the connections by seeking the optimum connective weightings that willresult in a minimum of error between the network’s prediction and the actual answer.Some modern commercial neural network software now actually have one layer foreach hidden neuron, and the layers are added one by one as needed. They starttraining with an arbitrary set of starting weights and search for a set of weightsthat minimizes the network’s errors. Training neural networks by minimizing theoutput error is conceptually similar to the least-squares technique used in statisticalregression analysis where the formula for a line that best fits a collection of scatteredpoints on a graph is found by minimizing the sum of the squared differences betweenthe predicted and actual values.Neural networks are primarily beneficial when the relationship between inputand output data is not clearly understood, but a large number of sample setsof data are available. What distinguishes neural networks from artificial intelligence or standard programming practices? Neural networks are “trained with data”rather than programmed. This implies that neural networks improve with experience. The more data the network is trained with, the more reliable the answerswill be.Unlike conventional technical trading systems, neural network systems work wellwhen technical and fundamental data are combined. It is sometimes difficult, however,to find appropriate fundamental data, which is often subject to revision and not alwaysreported in a data-compatible format. Neural networks trained with fundamental dataare more often used as longer-term screening strategies.Fortunately you don’t have to be a computer programmer in order to use neuralnetworks as there is a wide selection of commercial neural network software, likeNeuroShell Trader, Trading Solutions, Traders Studio with the Neural Studio & Kernel regression add-in, NeuralWorks Predict, Deep Insight, Tradecision, WealthLabDeveloper, etc. It is tempting to see techniques like neural networks as a panaceafor predicting the market, but it is important to realize that these are simply a stepin the correct direction to model the complex underlying mechanics of the financialmarkets.There is general acceptance that neural networks are superior at modeling andpredicting relationships within the financial market domain, due in part to theirability to model non-linear relationships in the noisy environment which the stockmarket represents. This praise may be premature in some areas such as trading anddoes not mean neural networks are the “Holy Grail”.The following is a list of limitations and criticisms of neural networks:• A major limitation of neural networks that most traders or analysts are not awareof is over-training or over-fitting, which is analogous to curve-fitting in rule-basedtrading systems. As a neural net makes training runs through the data, if it can’tminimize error level by learning real relationships between the input training dataand the variable to be predicted, it will tend to find patterns that exist only by
170
Intermarket Trading Strategies
chance. This will result in an over-fitted model that will fail miserably when usedin actual trading. There are no rigorous training methodologies that can avoid thisproblem entirely. Also, where there are multiple inputs, neural networks tend tofind inputs which are important for making the prediction and weight unimportantones near 0. This uses some of the power of the network and will also producecurve-fitted results because it produces a model which works well on the trainingdata but performs poorly on out-of-sample test data.• Another major problem encountered when working with neural networks is interpretability or their virtually non-existent explanatory capability. You can create asuccessful neural network without understanding how it works: the output wouldin all probability be completely valueless as a scientific resource. Generally, mostresearchers do not attempt to extract rules from their networks; rather they rely onstatistical testing performed on out-of-sample results.• There are obvious mismatches between the goals of neural networks and realtraders. While neural networks are attempting to minimize forecast errors in training, traders typically focus on maximizing profit and minimizing drawdown.• Neural network systems tend to overtrade. For example, a neural network systembased on rules similar to a conventional system could produce three to ten timesthe number of trades.• An issue which can be confusing to new users of neural software is that it is veryunlikely that you will get exactly the same results each time you train a network.This is counterintuitive and often leads to misconceptions among many traderswho used conventional systems in the past. A conventional system, for example amoving average crossover system, uses a unique and specific relationship (betweenthe two moving averages); all you have to worry about is getting accurate, precisedata and then the system produces the appropriate unique signals. This is not thecase, however, with neural systems because they start training with an arbitrary setof starting weights and therefore produce a different solution each time. This is aproblem which cannot be overlooked, as it is often required to retrain the networkup to 10 times in order for the solution to converge, meaning that all trainingoutputs would have to be within a given tolerance limit of the correct answer. Theresulting trained network would have deciphered the input conditions correctlyand could then take new input data and presumably give good predictions everytime. To deal with this issue, system developers started using the method of Kernelregression (see Chapter 3) as an alternative to neural networks as it always givesthe same answers. Automation of the convergence process is also an alternativesolution to the tedious training process.• A neural network model can fall apart when confronted with market conditionsthat were not present during the training and optimization process. They thereforeneed to be retrained occasionally to take into account the new market dynamics.• I have also heard criticisms citing the following conundrum: How can a techniquewhich mirrors human intelligence be able to predict changes in the stock marketwhen humans are remarkably poor at beating the market?
Trading System Design
171
Despite these clear limitations, neural networks are still considered the tool of choicefor investigating non-linear relationships amongst noisy and complex data sets. Ofcourse neural networks are just tools in understanding one piece of the puzzle of thefinancial markets and their interrelationships and other pieces of the puzzle are stillmissing.
10.8
FUZZY LOGIC
Indicators are rarely definitively bullish or bearish, nor can they be considered to haveprecise values, such as true or false. More accurately, a technical indicator provides, asthe name suggests, an indication of a situation, and not a black-or-white conclusion.Artificial intelligence developers decided to deal with this ambiguity by introducingthe concept of fuzzy logic. Fuzzy logic uses propositional logic that is modified toallow the use of any value in the range of 0 to 1, rather than only the crisp values of0 or 1.The result is a value falling within the range of 0 to 1 considered partly true tothe magnitude of that particular value. For example, can a stock’s daily price changeof 3 % be considered high while 2.9 % is not? A decision based on a crisp rule isdifficult to develop, but by using fuzzy logic a rating or an indexed value from 0 to1 can be applied. The resulting fuzzy logic should then be able to accommodate thevague linguistic terms closer to human judgment and intuition.The following are a few of the advantages in incorporating fuzzy logic in yourtrading systems and indicators:• Simplicity of programming. Fuzzy rules do not have to be as precise as traditionalbinary specifications. This will reduce the time spent in designing a trading system.• Familiarity. Fuzzy systems can be used for developing systems that can be described with linguistic rules in which the experience of a trader can be incorporated in a natural way. Thus the behavior of the system would be more familiar fortraders.• Speed. Less time will be required to optimize the system.• Pattern recognition. Experienced traders can recognize a formation or pattern on achart but ask them to describe it precisely and you will get a different descriptionfrom each. This makes pattern recognition an ambiguous task, more appropriatefor fuzzy logic. By incorporating fuzzy indicators into your screening systems,you can scan for your favorite patterns or formations in multiple securities in afraction of the time that you could do it manually.• Fundamental criteria (for example William O’Niel’s popular CANSLIM method)are relatively vague and the results depend on how one interprets them. In thesecases, fuzzy logic could be used to transform ambiguous qualifiers, such as growth,leadership, supply and demand, etc., with crisp mathematical models for machineprocessing.
172
Intermarket Trading Strategies
• Errors. Fuzzy logic is far more intuitive and closer to human judgment than binarylogic and therefore more tolerant to bad data, outliers and other input data errors.Fuzzy logic fits well to the perception of the traders. However, a trader sometimesadapts his strategies depending on market conditions, circumstances and other external stimuli. To add the necessary flexibility to your fuzzy system, a genetic algorithmcan be used to optimize the internal fuzzy logic engine parameters to allow for a widerrange of variations in order to take into account the ever-changing market conditions.Despite the obvious advantages of using fuzzy logic, traders have been slow to embrace this new technology, and its use in the development of trading systems has beenlimited mainly to Wall Street professional consultants and academics. In fact, I don’tknow of any independent trader who uses fuzzy logic systems in trading. This maybe because their implementation is not as straightforward as binary logic, or becauseof the high cost of purchasing artificial intelligence software or the complexity inusing them. I have presented in this chapter three different artificial intelligence tools(neural networks, fuzzy logic and genetic algorithms) as well as traditional binaryrule-based systems, but the focus each time has been only on a single method. Thisdoesn’t mean, however, that a combination of two or more different methods in asingle strategy is not possible or without merit.While an artificial intelligence system can be profitable, its use may be sub-optimal,in the sense that results may be constrained by the limitations of the technology. Forexample, while neural networks have the positive attributes of adaptation and learning,they have the negative attribute of a “black box” syndrome. By the same token, fuzzylogic has the advantage of approximate reasoning but the disadvantage that it lacksan effective learning capability. Merging these technologies provides an opportunityto capitalize on their strengths and compensate for their shortcomings. However, todesign an effective hybrid system, the strengths and weaknesses of all componenttechnologies must first be understood.Commercial software vendors, eager to cash in on the new technologies, havealready developed software that are capable of constructing a trading system whichincorporates traditional as well as all the above artificial intelligence tools. The onlyobstacle in using them is the cost of the software and the time and skill required tolearn to use the new software.
10.9
CONCLUSION
In approximately 500 BC, Confucius said, “Study the past if you want to divine thefuture.” As far as I am concerned, this makes Confucius the first market technician.You should have learned by now, especially after reading the section on back-testingand the pitfalls of optimization, that there is no guarantee that a system, no matterhow many hours you spent in back-testing it, is going to be profitable in the future.
Trading System Design
173
For example, a change in market conditions or a price shock caused by an unexpected geopolitical event can devastate any system. In the world of trading thereare no formulae that produce black and white results, and all rules must be based onpartial knowledge. The paradox is that the market is a place where no transactioncan be completed unless the opinions of the participants are diametrically opposed.You must therefore accept the fact that you are often going to be the participant whois wrong. You should accept losses with no remorse, no tears, no what-ifs, and nopointing fingers at others.In order to survive, seek out strategies based on probabilities and focus on limitingyour losses, money management and the mathematical principle of compounding.The information on trading systems presented in this chapter is by no meansexhaustive. I have included a number of books in the Bibliography, for the benefit ofreaders interested to learn more about the development of trading systems. I highlyrecommend Perry Kaufman’s Smarter Trading, Chuck Lebeau and David Lucas’Technical Trader’s Guide to Computer Analysis of the Futures Markets, and MurrayRuggiero’s Cybernetic Trading Strategies which also includes chapters on intermarkettrading systems.
DisclaimerMy editor has asked me to include the following disclaimer. Please read it carefullybefore proceeding with the trading systems in the next chaptersHypothetical performance results have many inherent limitations, some of whichare described below. No representation is being made that any account will or islikely to achieve profits or losses similar to those shown. In fact, there are frequentlysharp differences between hypothetical performance results and the actual resultssubsequently achieved by any particular trading program.Any performance results listed in the next chapters represent simulated computerresults over past historical data, and not the results of an actual account. All opinionsexpressed anywhere in this book are only opinions of the author. The informationcontained here was gathered from sources deemed reliable; however, no claim is madeas to its accuracy or content. Different testing platforms can produce slightly differentresults. My systems are only recommended for well capitalized and experiencedtraders.
11A Comparison of FourteenTechnical Systems forTrading Gold
The market always does what it should do, but not always when.–Joseph D. GoodmanI presented in Chapter 9 many different intermarket indicators that can be useful indeveloping trading systems. But which one has the best predictive capacity and whichintermarket securities should one use for trading gold? Only testing can reveal thewinner.
11.1
TEST SPECIFICATIONS
All single divergence indicators were tested using the Philadelphia Gold & SilverMining Index (XAU) and the dollar index (DXY) separately in order to evaluatethe best performing indicator and intermarket security at the same time. Double andmultiple divergence indicators used the XAU–dollar index and XAU–silver–dollarindex combinations respectively.I used the gold ETF (GLD) instead of gold futures as not all investors or tradershave a futures account. Unfortunately, the gold ETF started trading in the NYSE inNovember 2004. For this reason, for the time period that the GLD was not in existence(from January 1992 to November 2004) I used gold spot prices (after dividing themby 10) to create a “tradeable proxy”. I then used MetaStock’s downloader to join theproxy and actual GLD prices into one long continuous file of gold prices stretchingfrom 1992 to 2007. Similarly, I joined the World Silver Index prices (after multiplying
176
Intermarket Trading Strategies
them by 10) with the SLV. Daily pricing data were obtained from Telechart afterexporting them to MetaStock.The test results were compared with the buy and hold method (Table 11.1). Alltests started with an initial equity of $100 000. In order to compare the systems withthe buy and hold method, profits or losses were compounded to the initial equity.Tests were carried out using MetaStock Professional 8.0 and test statistics arepresented in Tables 11.1, 11.2 and 11.3. All orders were executed at next day’sopening price at the market, and the commission charged was $10. Gold bullionTable 11.1 Test results of some single intermarket systems from 1 December 1995 to21 August 2007. All tests were profitable and outperformed the buy and hold method by awide margin. The LRS system used the linear regression slope divergence method. Themomentum oscillator was used to determine optimum divergence levels.System
Buy & hold
Intermarket securityTotal net profitProfit/loss %Annual % gain/lossTotal no. of tradesWinning tradesLosing tradesPercent profitableAvg. winning tradeAvg. losing tradeAvg. win/avg. lossProfitability coef.Profit factorMax drawdownRisk/rewardTime in market
$67 50968 %5.8 %110100 %$67 5090
−$35 19452.1 %100.0 %
Regression
Regression
LRS
LRS
DXY
XAU
DXY
XAU
$265 474265 %23 %27161159 %$14 306−$70712.022.622.94−$31 10811.7 %30.2 %
$621 084621 %53 %3125681 %$20 410−$29416.946.8028.91−$12 8962.1 %38.0 %
$282 257282 %24 %2119290 %$10 135−$27213.736.9335.39−$9 2823.3 %20.7 %
$244 097244 %21 %1613381 %$11 795−$17176.876.8529.76−$11 0674.5 %24.0 %
3040
4050
2008525256050
200705155050
System ParametersDivergence daysMA goldMA intermarketROC – daysIMO – daysIMO – buyIMO – shortIMO – sellIMO – coverTime exit – bars
400
10200607158050
400
12200608158050
A Comparison of Fourteen Technical Systems for Trading Gold
177
Table 11.2 Test results of some single intermarket systems from 1 December 1995 to21 August 2007. All tests were profitable and outperformed the buy and hold method (inTable 11.1) by a wide margin. The XAU or the dollar index were used to calculateintermarket indicators. All systems used the momentum oscillator to determine optimumdivergence levels.System
BB
Disparity
Disparity
Z-score
Z-score
Intermarket security
XAU
XAU
DXY
DXY
XAU
Total net profitProfit/loss %Annual % gain/lossTotal no. of tradesWinning tradesLosing tradesPercent profitableAvg. winning tradeAvg. losing tradeAvg. win/avg. lossProfitability coef.Profit factorMax drawdownRisk/rewardTime in market
$179 543180 %15 %1613381 %$8553−$56621.514.146.55−$10 6655.9 %18.9 %
$290 447290 %25 %2618869 %$11 080−$17006.525.5914.66−$35 42412.2 %26.7 %
$323 637324 %28 %3123874 %$12 437−$68521.823.875.22−$26 8448.3 %24.1 %
$409 960410 %35 %2417771 %$20 113−$68072.954.557.18−$30 6507.5 %38.4 %
$307 540308 %26 %2416867 %$16 948−$62862.703.965.39−$26 8638.7 %28.9 %
500
100
200905505050
2008010504050
System ParametersDivergence daysMA goldMA intermarketIMO – daysIMO – buyIMO – shortIMO – sellIMO – coverTime exit – bars
100100100200705305050
1515152008025306050
20152008025306050
investors do not get any dividends or interest, so for a more realistic comparison withthe buy and hold method, interest was credited at an average rate of 4 % when out ofthe market.If you wish to replicate the tests, please keep in mind that for them to beginproducing any signals the indicators used in each should be calculated first, and thisrequires a number of bars to be loaded. For example, the test using the regressiondivergence and the 200-day momentum oscillator will need 617 extra data bars to beloaded (11 for the ROC + 400 for the regression + 3 for the divergence EMA + 200
178
Intermarket Trading Strategies
Table 11.3 Test results of the relative strength, LRS and multiple regression intermarketsystems from 1 December 1995 to 21 August 2007. All tests were profitable andoutperformed the buy and hold method by a wide margin. The XAU, the dollar index andsilver were used to calculate intermarket divergence. The multiple divergence systemoutperformed all systems producing an astonishing profit of more than $1.2 million on a$100 000 initial equity.System
RS(Diverg)
RS
LRSdouble
LRSdouble
Regresionmultiple
Intermarket security
XAU
DXY
XAU DXY
SLV DXY
XAU - SLV- DXY
Total net profitProfit/loss %Annual % gain/lossTotal no. of tradesWinning tradesLosing tradesPercent profitableAvg. winning tradeAvg. losing tradeAvg. win/avg. lossProfitability coef.Profit factorMax drawdownRisk/rewardTime in market
$267 542
$141 363
$370 418
$476 181
$1 263 992
268 %23 %1714382 %$14 487−$84101.724.568.04−$21 4838.0 %21.4 %
141 %12 %97278 %$13 282−$68991.934.366.74−$13 4539.5 %20.6 %
370 %32 %33201361 %$17 460−$57023.063.604.71−$48 83513.2 %40.8 %
476 %41 %2315865 %$30 290−$67804.474.698.38−$35 4237.6 %42.4 %
1264 %108 %3832684 %$36 601−$80644.546.6224.21−$70 0585.5 %42.5 %
System ParametersRegression daysMA goldMA intermarket SEC1MA intermarket SEC2ROC – daysIMO – daysIMO – buyIMO – shortIMO – sellIMO – coverTime exit – bars
200
3002085352040
150
2500202030
202030
3007015107050
20075575550
11300707146050
for the momentum oscillator + 3 for the momentum EMA) before the test can startproducing trading signals.This presents a problem when comparing the test results with the buy and holdmethod, because most trading simulation software use the stock price of the first dateof the data loaded in the chart to calculate the buy and hold profit/loss. This willnot make much of a difference where most normal indicators are concerned but will
A Comparison of Fourteen Technical Systems for Trading Gold
179
make a big difference when using intermarket indicators. To deal with this issue, Ihad to calculate the buy and hold profit manually using the date that the test couldstart producing trading signals. Thus the actual test period was from 11 December1995 to 21 August 2007 but extra days were loaded to address the indicator lag issue.Normally, when these type of systems are developed, two data sets should be used:one for optimization and the other for testing the optimized parameters on the newdata. Since these tests were only carried out for comparison purposes, in order tosimplify the process, optimization was carried out across the complete data set.Another software issue that I encountered halfway through the test was that, forsome reason, MetaStock did not execute certain trades. Instead it issued a rathercryptic “Cancelled – Open Cost” message, even though the account equity was morethan enough to buy the shares. After contacting Equis technical support I found thiswas caused because I chose to execute orders with a one day delay. The programcalculated the number of shares for the trade on the signal day and not the actual tradeday. If the stock was up the next day, the number of shares calculated the previousday times the inflated price put it over the amount of equity available. To overcomethis problem I had to increase the initial equity to $111 111 and specify the defaulttrade size to 90 % of the initial equity to (111 111 × 90 % = 100 000). This left amplemargin for price increases on the next day. I hope Equis will modify the code on laterversions to calculate the amount of shares on the actual trade and not the signal day.
11.2
TEST DESIGN
There are two types of trading system: trend-following and countertrend. These twostrategies form the foundation on which all trading systems are built, and the marketsprovide the medium.Basically, the goal with the countertrend system is to buy at the bottom and sell atthe top, which is most often determined using oscillators. For example, a signal canbe generated when the stochastic or other momentum oscillator begins to fade andfalls below a certain level. Trend-following systems, on the other hand, rely on thehypothesis that the current trend is likely to continue in the future. Therefore theydo not need to forecast the trend; instead they use trend-following indicators such asmoving averages to determine only the direction of the trend. The main disadvantageof trend-following systems is that they do not work during sideways markets orchoppy markets, i.e. 70 % of the time. On the other hand, the main disadvantage ofcountertrend systems is Newton’s first law of inertia: A body in motion tends to stayin motion until it encounters an opposing force. Once a trend has been established, ithas to overcome inertia forces, i.e. investors who missed the boat and are trying to getin late by buying the dips. This can cause contrarian indicators, like the CommodityChannel Index (CCI), the stochastics and other oscillators, to fail miserably.The basic premise of the systems presented in this chapter, except for the relativestrength (RS in Table 11.2) is divergence between gold and related intermarketsecurities and should be therefore classified in the countertrend category.
