-day CI is plotted in the top window, the 28-day vertical horizontalfilter below and the 14-day ADX in the second from bottom window. CI detected both uptrends (in gray) with virtually no lag.
On 5 April, the CI crossed over 20, decisively followed eight days later by the VHFcrossing over 0.35 (the indicator’s default value for a trend) on 16 April.The ADX, on the other hand, missed the trend altogether. It was actually down atthe beginning of the trend and started rising on 17 April, but by the time it crossedover 25 (indicating a trend) the trend was over.But why the disparity between the indicators? The answer is in the calculationmethod. The VHF is calculated using the formula:VHF =
Highest(C, 28) − Lowest(C, 28)ABS(Ci − Ci−1 )
(9.17)
142
Intermarket Trading Strategies
Table 9.7 Calculation of the VHF. Column B is the S&P 500 closing price, Column Cshows the highest close of the last 28 days, Column D shows the lowest close of the last28 days, Column E is their difference, Column F is the absolute value of the differencebetween consecutive daily closes, Column G is their sum for the last 28 days and Column His the VHF.A
B
C
D
E
F
G
H
Date
Close
Highest
Lowest
H-L
|(C-C[1])|

VHF
2/27/072/28/073/1/073/2/073/5/073/6/073/7/073/8/073/9/073/12/073/13/073/14/073/15/073/16/073/19/073/20/073/21/073/22/073/23/073/26/073/27/073/28/073/29/073/30/074/2/074/3/074/4/074/5/07
1399.041406.821403.171387.171374.121395.411391.971401.891402.851406.61377.951387.171392.281386.951402.061410.941435.041434.541436.111437.51428.611417.231422.531420.861424.551437.771439.371443.76
1459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681459.681457.631456.381451.191449.371443.76
1399.041399.041399.041387.171374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.121374.12
60.6460.6460.6472.5185.5685.5685.5685.5685.5685.5685.5685.5685.5685.5685.5685.5685.5685.5685.5685.5685.5685.5685.5683.5182.2677.0775.2569.64
50.37.83.616.013.121.33.49.91.03.828.69.25.15.315.18.924.10.51.61.48.911.45.31.73.713.21.64.4
190.96194.49194.01202.46210.47219.62206.83215.03214.43209.98229.21230.73233.39237.32251.42258.28280.67270.92267.8259.55256.15266.02270.05267.58269.22281.19277.6280.17
0.3180.3120.3130.3580.4070.3900.4140.3980.3990.4070.3730.3710.3670.3610.3400.3310.3050.3160.3190.3300.3340.3220.3170.3120.3060.2740.2710.249
ColumnCDEFGH
Formula= MAX(B9:B36)= MIN(B9:B36)= C36-D36= ABS(B36-B35)= SUM(F9:F36)= E36/G36
Intermarket Indicators
143
Table 9.8 Example of calculating CI in Excel. The second, third and fourth columns are theS&P 500 high, low and closing prices respectively. Column E is the highest high of the last28 days, Column F is the lowest low of the last 28 days, and Column G is the price percentchange during the last 28 days. In column H is the percent daily price difference and in thelast column is the CI.A
B
C
D
E
F
G
H
I
Date
High
Low
Close
HH
LL
ROC
(HH-LL) /LL
CI
3/19/073/20/073/21/073/22/073/23/073/26/073/27/073/28/073/29/073/30/074/2/074/3/074/4/074/5/07
1403.21411.531437.771437.661438.891437.651437.491428.351426.241429.221425.491440.571440.161444.88
1386.951400.71409.751429.881433.211423.281425.541414.071413.271408.91416.371424.271435.081436.67
1402.061410.941435.041434.541436.111437.51428.611417.231422.531420.861424.551437.771439.371443.76
1461.571461.571461.571461.571461.571461.571461.571461.571461.571461.571461.571456.951456.951449.25
1363.981363.981363.981363.981363.981363.981363.981363.981363.981363.981363.981363.981363.981363.98
−3.31−2.58−0.210.08−0.48−1.22−1.94−2.63−2.55−2.52−2.19−0.92−0.693.20
0.070.070.070.070.070.070.070.070.070.070.070.070.070.06
−46.23−36.06−2.941.14−6.68−17.10−27.06−36.79−35.57−35.26−30.55−13.57−10.1251.13
ColumnEFGHI
Formula= MAX(B22:B49)= MIN(C22:C49)= (D49-D22)/D22* 100= (E49-F49)/(F49+0.01)= G49/H49
where Highest(C,28) is the highest close in the last 28 days; Lowest(C,28) is thelowest close in the last 28 days; and the denominator is the sum of the absolute valueof the difference between consecutive daily closes for the last 28 days.To help solve the mystery I calculated the 28 day readings, up to 5 April, for theVHF and CI indicators in the Excel sheets in Tables 9.7 and 9.8 respectively. Let’stake a closer look what happened on 3 April (the first day of the breakout).On that day the S&P was up 1 %, and as a result the denominator of formula (9.17)increased while the numerator decreased because the new 28-day high was lowerthan the previous one. As a result the VHF was down on the actual breakout and thestart of the trend! On the other hand the CI shot up from −13 to 51 during the nexttwo days, confirming decisively the start of a possible trend.
Part II
10Trading System Design
Life can only be understood backwards but it must be lived forwards.–Søren KierkegaardThere are basically two ways to trade using technical analysis: discretionarily andsystematically. Discretionary traders use technical indicators and their experience tomake their trading decisions. System traders, on the other hand, rely on the tradingsignals automatically produced by computerized trading systems.The disadvantages of discretionary trading are human emotions: fear and greed.When you are in a trade that seems to move against you, fear of loss and hope ofrecovery make it hard to cut your losses. Optimism keeps you in a losing trade, hopingthat the price will eventually turn in your favor. On the other hand, when you are in atrade that starts to move to the upside, greed takes over and you take profits too early,missing the biggest part of the move.Trading systems remove much of the emotion surrounding trading decisions, andcan also save a lot of time.But do they work?Many people believe in the Efficient Market Hypothesis. The Efficient MarketHypothesis states that, at any given time, security prices fully reflect all availableinformation. The implications of the Efficient Market Hypothesis are truly profound.But if markets are efficient and current prices fully reflect all information, then buyingand selling securities in an attempt to outperform the market will effectively be a gameof chance rather than skill.This belief persists although it is rudimentary, false and intellectually dishonest.Researchers have uncovered stock market anomalies that seem to contradict theEfficient Market Hypothesis. One major criticism stems from the fact that marketparticipants take into consideration other factors than just the price when they buy orsell an asset.
148
Intermarket Trading Strategies
One such factor, not taken into account at all by the Efficient Market Hypothesis, isthe concept of risk. Since different kinds of market players compute risk in differentways, it is perfectly possible that one participant views a certain stock price as a goodbuying opportunity, while another views the same price as a good selling opportunity.Another factor is different liquidity needs among traders. Some traders are gladlywilling to pay a higher price just to make sure the trade is executed immediatelywhile others may want to sell an asset in order to buy something else. Yet none ofthe traders above can be said to act irrationally. They simply have different needs forcomputing the value of different actions and states.Another flaw in the Efficient Market Hypothesis is that prices tend to be slow toreflect all fundamental information. Without instantaneous adjustment, speculationbased on the price trend may be profitable until all information is fully discountedand reflected in the price. Thus, the time lag can be exploited by technical systems inshort-term speculation.The search for anomalies is effectively the search for systems or patterns that canbe used to outperform passive and/or buy and hold strategies.Developing an effective trading system is by no means an easy task. It requiresa solid understanding of the plethora of available parameters, the ability to makerealistic assumptions and the time and dedication to develop the system. However,if developed and deployed properly, a trading system can yield many advantages. Itcan increase efficiency, free up time and, most importantly, increase your profits.I have seen a lot of different approaches to designing trading systems and strategies.The most popular are trend and countertrend systems but other less common systemsuse breakout from consolidation, channel breakout or volatility concepts. Indicatorsand techniques that work for one trader do not necessarily work for others.
10.1
BACK-TESTING
Back-testing is a key component of effective trading-system development. It isaccomplished by reconstructing, with historical data, trades that would have occurred in the past using rules defined by a given strategy. The results can be analyzedstatistically and used to gauge the effectiveness of the strategy. Using this data, traderscan optimize and improve their strategies, find any technical or theoretical flaws, andgain confidence in their strategy before applying it in real trading. The underlyingtheory is that any strategy that worked well in the past is likely to work well in thefuture and, conversely, any strategy that performed poorly in the past is likely toperform poorly in the future. Some of the advantages of back-testing a trading systemare as follows:• History repeats itself. Back-testing will reveal repeating patterns, disclosed byany number of indicators, oscillators or chart formations. Otherwise we would beshooting in the dark at every market turn.
Trading System Design
149
• Traders have the confidence to rely on the systems.• It provides an estimate of the probability and magnitude of the potential tradeprofits because the performance statistics can be reproduced by back-testing.Since back-tests are always done with the benefit of hindsight, there are all kinds ofways to cheat on reported performance.There are many factors traders pay attention to when they are back-testing tradingstrategies. Here is a list of the five most important things to remember.
Sample SizeFor a strategy to have value it must be adaptable to many market types. To avoid unrealistic back-testing results that cannot be reproduced in actual trading it is essential thatan adequate sample size must be measured both in number of trades and diversity ofmarket trends. For example, if a strategy was only back-tested during the 2003–2007bull market, it may not fare well in a bear market. It is often a good idea to back-testover a long time frame that encompasses several different types of market conditions.
OptimizationTrading system optimization is a controversial subject among analysts and traders.But what is optimization? When designing a technical trading system, the analystmust use an indicator or formula to produce trading signals.All indicators, however, contain one or more variable parameters. A parametercan be set to one of several possible numeric values, which can greatly alter thebehavior and performance of the indicator. The dilemma is what value to assign toeach parameter. That is where optimization occurs. Optimization is the process ofchoosing the best parameter values for the indicator.This is accomplished by having the software “try” a large number of differentcombinations of parameters or combination of indicators, until a set is found thatgives the best result. The result could be net profits, percentage of profitable trades,minimum drawdown and so forth. An example of a trading system parameter is thelength of a moving average used. It is very important to identify the ranges into whichthe values for parameters and criteria fall.A thorough development of a trading system must involve the testing of thousandsof parameter combinations to identify those that persist in producing profits, eventhough they are not necessarily the optimum. Thus, it is often better to pick up thoseparameters in the best ten percent of the parameters instead of the best based on stableneighbouring parameters.Today’s software for trading systems can take you down a dangerous path. A bigprofit, however, on an optimized test does not necessarily mean you have a good
150
Intermarket Trading Strategies
system. The danger with optimization is that what worked well in the past willalmost certainly not perform as well in the future. Optimized variables can reflectirregularities in the data far more than any underlying logic of the market or thetrading strategy.Usually, such curve-fitting fails as soon as the parameters hit the real world with itsrandom shocks, because the more control you take of the data by specifying indicatorsand their optimal parameters, the less substance is left in the data to provide predictivecapacity. Statisticians call this a loss of degrees of freedom; traders call it curve-fitting.Some analysts claim that if the data sample is large enough, then the curve-fittingcaptures most of the price dynamics and the future buy and sell signals will be justas good as the curve-fitted ones. These claims are generally accepted as being truebecause there is a lack of knowledge, but the truth is that they are based on nothingmore than hope.So how can we design trading models and avoid the illusion of optimization?The usual way to validate an optimized trading system is to test the system ondata it has never been tested on before — that is, test the system on some data setaside and not used when developing the model. This holdout data set is referred toas out-of-sample data. If the system performance holds up well on the out-of-sampledata, we can be confident the system will perform as well in the future as it has in thepast.A more rigorous method of back-testing is that of walk forward testing. Theconcept is similar to out-of-sample testing but instead of optimizing on seven yearsof data and using the last three years for testing, a system is optimized on five yearsand then tested the next year. Once this test is completed, the whole time windowis moved forward one year to include the year just tested and the system is thenre-optimized. It is then tested again the next year. This process is repeated again andagain, “walking forward” through the data series until all the data is exhausted. Atthe end, all tabulated one-year out-of-sample results are merged to create one largeout-of-sample results segment and the system performance is evaluated based on thecombined out-of-sample results.The main advantage of using this method is that since market dynamics changeslowly over time the optimum values based on the most recent five-year segment willbe accurate in forecasting one year into the future before the model falls apart.The time periods used in this example for optimization and walk forward testingare not set in stone. The selection of the optimization period depends on the availabledata and the time required to model the market dynamics. The walk forward periodcan be between 12–20 % of the optimization period.Although computationally intensive, this is an excellent way to study and testa trading system. Even though optimization is occurring, in a sense all the tradesare tested on what is essentially out-of-sample test data. In addition, the resultswill closely simulate the process that occurs during real trading, in which tradersfrequently re-optimize their systems to bring them up to date with fundamental ortechnical changes in the traded market or its intermarket relationships. Even though
Trading System Design
151
nothing can guarantee future results, this approach appears to be as close as wecan practically come to estimating trading relationships during constantly changingmarket conditions.Unfortunately, totally automated walk forward testing is not available in mostpopular off-the-shelf trading software and implementing it manually can be timeconsuming. There is, however, a Tradestation add-in that can be purchased separately. Walk forward testing is also available in Deepinsight Professional andTradersStudio.A major drawback of out-of-sample testing is that to exhaustively determine theoptimal indicator sets as well as their respective periods would require an inordinatelylarge amount of data. If one uses this approach consistently, every piece of data mustbe thrown away after a single use in the testing phase. In addition to the cost ofsubscribing to data providers, some futures have only recently begun trading. If theamount of data you possess is limited, you may want to consider the followingadditional methods of reliability testing.Cluster spotting and profit mapping: When optimizing a system, traders often savethe parameter set which produces the highest level of profit. Once the system withthe highest level of profit is identified, you should inspect the results of surroundingparameter values nearby to be sure it is not merely the result of a freak coincidencein the data. Optimal results which are surrounded by similar levels of profit are muchmore desirable. A better approach is to export the test results produced from eachsimulation to an Excel spreadsheet and plot a three-dimensional graph, with oneparameter scaled along the X-axis, the second parameter scaled along the Y-axis andthe profit as height along the Z-axis. Casually inspecting this graph, one can find theregion where variations in both parameters have the smallest impact on profitability.Parameter sets in this range may be assumed to be more reliable than parameter setswhich produce spikes of profits. This is because low parameter sensitivity in the pastimplies continued low sensitivity in the future, even though the parameter valuesproducing maximum profits are outside this parameter range.The process described above can be applied to a wide variety of trading systemsas most of them are either already described by two parameters or can be altered tofit a two-parameter model by optimizing each rule or indicator separately.Monte Carlo simulation: This technique is mainly used to obtain a more realisticfigure for the drawdown statistic than the figure obtained by simulation testing andis performed by rearranging the trades randomly (hence the name).To rearrange the trades, the Monte Carlo simulation uses a random number generator to select a random number between zero and one. This random number is thenused to select a trade from the specified listing. The Monte Carlo simulation canreveal whether the account would have experienced a deeper drawdown and what theactual expected drawdown could be in real trading. If the Monte Carlo drawdown
152
Intermarket Trading Strategies
is significantly different to that obtained from the simulation model this can alsoindicate that the system has been overoptimized.A limitation of this method is that the random number generator assumes thattrade returns are independent of each other. It is therefore a good idea to check forautocorrelation of returns before running a Monte Carlo simulation.Low number of inputs: By increasing the number of inputs to extremely high levels,you could design a system that fits almost perfectly around a price series. This system,however, will almost certainly fail when confronted with real time data that it has notseen before. It is therefore a good idea to keep the number of parameters in the modelrelatively low, because the larger the number of variables in the system, the easier itis to create an overoptimized system that will underperform in real time.Diversification with intermarket indicators: Last but not least, the key to robustsystem development is to select non-correlated inputs that have predictive ability.Using a superfluous number of moving averages and oscillators that are derived fromthe same price series won’t create a profitable trading strategy. In fact, it will mostlikely fail to work in real time. Rather than using standard, price derived indicatorsas your only input, try to ascertain what other markets are related to the market beingtraded and use the intermarket relationship as a filter or replacement of a redundantclassic indicator. One interesting advantage of intermarket analysis is that it relies onat least two different data sources or price series. Most single market analysis toolsare derived from the same price data. A price shock or bad data would affect all theindicators or tools based on those data. By using two different data sources, you canhelp to insulate yourself against such an event. The use of intermarket relationshipsin developing trading systems is explained extensively in the following chapters.By using some of the above techniques, I am convinced that anyone can, at thevery least, avoid trading with systems of absolutely no value. Considering the amountof money at stake in these highly leveraged and volatile markets, it’s hard to believeanyone can justify trading a system without first performing some type of validationand reliability testing.Markets: The choice of securities used in back-testing is also important. For example, if a broad market system is tested only on oil stocks, it may fail to do well indifferent sectors. As a general rule, if a strategy is targeted towards a specific sector,limit the stocks to that sector, but in all other cases, maintain a large universe fortesting purposes.Software inputs: Back-testing customization is extremely important. Many backtesting applications have input for commission amounts, round (or fractional) lotsizes, tick sizes, margin requirements, interest rates, slippage assumptions, positionsizing rules, same-bar exit rules, (trailing) stop settings and much more. To get the
Trading System Design
153
most accurate back-testing results, it is important to tune these settings to mimic yourtrading style and the broker that will be used when the system goes live.Paper trading: The market is dynamic and strategies that performed well in the pastfail to do well in the present because of changing market conditions. Be sure to papertrade a system to ensure that the strategy still applies in practice.Data quality: Price data often contain errors, which can cause serious problems,Special care should be exercised when handling missing values as these are usuallyreplaced by zeroes. Sometimes free internet data sources, such as Yahoo Finance, donot adjust stock prices for splits. The resulting gap will not only affect the system’sprofitability but will also bias the system to select the appropriate parameters toposition itself on the right side of the market when the price jump (or split) occurred.While easily spotted manually, data errors tend to corrupt a mechanical system if aprice series is used for testing without careful data preprocessing and error checking.There is an option in Equis’ Downloader to test the data for over 100 different errorconditions. The most useful is testing for a large change in close (Error#1090).
Optimization MethodsExhaustive search technique: The most common optimization method used bymost commercial software (like MetaStock or Tradestation 2000) is the exhaustivesearch technique (also known as the brute force approach). Optimization is performedby testing every possible number of different combinations of parameters until aparameter set is found that produces the best performance of the system over sometradable price series.This method is the preferred technique for solving problems in which all possiblesolutions can be tested within the available time because it is guaranteed to exhaustall the possibilities. The primary drawback to this approach is that it is highly laborintensive and time-consuming, especially when there is a large number of parametersto be tested with wide test ranges.The range and increments of values you specify will also affect the number of teststo be performed. The more values that must be tested, the more tests that must be runand the longer the optimization will take. To reduce the time required for testing, youcan either reduce the number of parameters being tested or decrease the parameterrange or reduce the number of inputs or indicators being optimized at the same time.Monte Carlo method: A second optimization method is the “Monte Carlo” orstochastic tunneling approach. As the name suggests, this method selects different random parameter values and records the best-performing values for each optimization pass. It then narrows the range around the parameters, centering eachparameter range on the previously detected best value. During each pass through the
154
Intermarket Trading Strategies
optimization, it gradually approaches toward the best solution. The Monte Carlomethod will not always find the most profitable solution, but it performs better thanthe brute force approach when the search space is too large and the amount of timeis limited. This approach is offered as an alternative to the brute force method by theWealth-Lab Developer software.Gradient descent method: A third optimization method is the gradient descentmethod, so named because it performs the optimization by trying to find the minimumof the error curve. This is achieved by calculating the direction of the error curve inwhich the trial solutions seem to produce better answers. This approach is faster thanthe other methods when the error curve is a smooth parabola, but there are problemswhen the error curve has local troughs as these may confuse the search and direct thegradient descent search away from the global minima of the error curve. A variationof this method, called the conjugate gradient descent, is used by some neural netsoftware like Alyuda’s Forecaster and NeuroIntelligence.Genetic algorithm: A fourth optimization method is the genetic algorithm, so namedbecause it simulates evolution. In a typical optimization problem there is a set ofvariables (called individuals) which controls the process. The genetic algorithmdevelops a fitness function to select the best individuals (survival of the fittest). Thesethen undergo crossover and mutation to produce new individuals that are expected tobe better solutions to the problem.After the genetic algorithm mates fit individuals and mutates some, the populationundergoes a generation change. The population will then consist of offspring, plus afew of the older individuals which the genetic algorithm allows to survive becausethey are the fittest individuals in the population, and the algorithm wants to keepthem breeding. The newly formed combinations are then decoded and tested, and thegenetic inheritance process continues for several generations until the time allottedfor the search has expired or a satisfactory solution (algorithm) is found. Duringthe mutation process the parameter variables are changed to optimize the model andminimize the error.Genetic algorithms are a powerful tool for finding the best variables or combinationof variables in designing a trading system or selecting and optimizing neural networkparameters. They can also be used to select related markets or weighted compositeindices in designing intermarket trading models.This optimization method is popular with commercial neural net software (likeNeuroShell Trader Professional, Tradecision, etc.) to identify the best inputs andoptimize their parameters in designing a neural network or trading strategy. It is alsoused with some conventional trading software like TradersStudio with the GeneticOptimizer add-in. Unlike the brute force approach, the genetic algorithm will notidentify the global optima that will maximize profitability. On the other hand, it is amuch faster and more efficient technique as a near-optimum solution can be foundin a fraction of the time required by the brute force approach. The genetic algorithm
Trading System Design
155
method is powerful enough to analyze hundreds of parameters within an acceptabletimeframe, and the Genetic Optimizer settings add flexibility to this technique.
10.2
EVALUATING PROFITABILITY
Evaluating a trading system performance is not an easy task. Not only does a traderneed