disparityindicator. The last three rows indicate the genetic algorithm optimized contribution of eachintermarket security on the system. The objective used to optimize the network structure wasreturn on trades. The maximum open trade drawdown is the difference between the entryprice and the worst price during any trade multiplied by the point value.Test
Buy & hold
Intermarket security
ROC
ROC (relative)
Disparity
BIX, XOI
BIX
CAC
Account requiredTotal net profitReturn on account %Return on trades %Annual return on trades %Total number of tradesWinning tradesLosing tradesPercent profitableGross profitGross lossAvg. winning tradeAvg. losing tradeAvg. win/avg. lossProfitability coefficientProfit factor
£3750£12 292338 %25.4 %8.1 %110100 %£12 293£0£12 293
£3750£47 2471575 %1574 %500 %102673565.7 %£69 176£21 929£1032£6271.652.793.15
£3750£32 5031083 %1083 %344 %89622769.7 %£47 442£14 939£765−£5531.382.773.18
£3750£32 910924 %1097 %348 %100643664.0 %£49 370£16 460£771−£4571.692.683.00
Max. drawdownMax. open drawdownMax. initial drawdownMax. consecutive lossesRisk/reward
−£11 458−€816−€635093 %
−£6304−£3471£0313 %
−£5428−£4014£0417 %
−£3375−£3271−£561310 %
Start date/testOutput end dateTest period (years)Test duration – barsAvg. trade length – barsTrades/year
01/04/0502/27/083.157977970.3
01/04/0502/27/083.15797832.4
01/04/0502/27/083.15797528.3
01/04/0502/27/083.15797431.8
Beginning priceEnding price
4847.06076.5
4847.06076.5
4847.06076.5
4847.06076.5
157
157
100 %00%
0100 %0%
System Parameters% change – days in the futureHidden neurons
207Input Contributions
BIXCACXOI
69 %031 %
226
Intermarket Trading Strategies
The out-of-sample and paper trading performance of all three systems are comparedin Tables 14.3 and 14.4. Trading signals and a graph of the system equity for thefirst (ROC) out-of-sample test are also presented in the chart in Figure 14.2. Areview of their comparative performance suggests that the simple price percentagedifference transformation may be the best to use as it beat all others on profitabilitymetrics, in both out-of-sample and in-sample tests. You should not, however, throwout the disparity transformation as it had significantly lower drawdown during theout-of-sample test.The option of full optimization was used, which means that the genetic algorithmcould optimize parameters but also discard any unnecessary inputs. It is interestingto note that in the second and third tests, which were fed with more elaboratelypreprocessed inputs, the genetic algorithm used only one intermarket security inconstructing the final model, whereas it used both the BIX and the XOI in the case ofthe simpler price rate of change (ROC) preprocessing method. In order to comparethe conventional system, which used all three intermarket securities in predicting theFTSE, with the current neural model, I had to construct a fourth strategy which usedthe outputs of the first three neural prediction models as inputs. Full optimization wasused again to select the best inputs and optimize the predicted thresholds. The resultwas a strategy that used inputs from the first (ROC) and the third systems (disparity)but excluded all inputs from the second system (relative ROC). The disparity inputswere only used for covering short positions.The combined system (Table 14.5) did not manage, however, to improve on theROC model by much on a profitability basis but reduced the drawdown considerably.The same conventional indicators that were used in the MetaStock system describedin the first part of this chapter were then added to the combined strategy to producea hybrid system.A moving average and a stochastic crossover were used to confirm neural intermarket signals and filter out any untimely entries. A full description of each modeland the rules and indicators used is included in Appendix B.Only the indicator parameters and the neural prediction thresholds were optimizedthis time. The additional indicators reduced the number of trades considerably but theymust have filtered out some profitable trades as well, because the overall performanceof the hybrid system was degraded (Table 14.5), although the average profit per tradewas actually higher.On enabling the genetic algorithm’s full optimization option the system reverted tothe combined model, discarding all additional conventional indicators. This suggestedthat the choice of indicators was not the best as they conflicted with the internalunknown neural network rules. A major drawback of neural networks is that a tradercannot see the rules that lead to the predictions. This makes the task of adding morerules a laborious and time-consuming process as the system developer has no otherchoice but to rely on a trial and error process. An alternative method is to extract thenetwork rules using sensitivity analysis. This can be accomplished by adjusting thelevel of inputs and recording the change in the outputs. The data can then be used to
Comparison of a Neural Network and a Conventional System for Trading FTSE Futures
227
Table 14.4 Profit/loss report. Testing sample results of the same intermarket neural networksystems presented in Table 14.3. This sample (from 1 February 2003 to 31 December 2004)was used to evaluate the optimized parameters derived from the training process. The last sixrows depict the contribution of the intermarket securities on each system and the parametersof the rate of change and disparity inputs as optimized by the genetic algorithm.Test
Buy & hold
Intermarket security
ROC
ROC (relative)
Disparity
BIX, XOI
BIX
CAC
Account requiredTotal net profitReturn on account %Return on trades %Annual return on trades %Total number of tradesWinning tradesLosing tradesPercent profitableGross profitGross lossAvg. winning tradeAvg. losing tradeAvg. win/avg. lossProfitability coefficientProfit factor
£10 225£804579 %20.1 %10.0 %110100 %£8045£0£8045
£4 218£27 416650 %914 %457 %78522666.7 %£36 747−£9331£707£3591.973.303.94
£8207£17 053208 %568 %284 %62431969.4 %£26 265−£9212£611−£4851.262.512.85
£5051£21 363423 %712 %356 %81562569.1 %£29 308−£7945£523−£3181.653.143.69
Max. drawdownMax. open drawdownMax. initial drawdownMax. consecutive lossesRisk/reward
−€7225−€4495−€7225090 %
−£2889−£2170−£1218411 %
−£6097−£6097−£5207336 %
−£2476−£1435−£2051512 %
Start date/testOutput end dateTest period (years)Test duration – barsAvg. trade length – barsTrades/year
1/2/0312/31/042.005045040.5
1/2/0312/31/042.00504739.1
1/2/0312/31/042.00504631.0
1/2/0312/31/042.00504440.6
Beginning priceEnding price
4009.54814.3
4009.54814.3
4009.54814.3
4009.54814.3
157
157
100 %002
0100 %0
System Parameters% change – days in the futureHidden neurons
207Input Contributions
BIXCACXOIROC – PeriodROC – PeriodMA periods
69 %031 %14
6
228
Intermarket Trading Strategies
Table 14.5 Combined neural and hybrid system profit/loss report. Out-of-sample testresults of two intermarket combined strategies tested on the FTSE from 4 January 2005 to27 February 2008. The first strategy (Combined) used the outputs of the three neural networktests described in Table 14.3, whereas the second strategy was a hybrid neural andconventional rule-based system. The last four rows indicate the best threshold parameters asoptimized by the genetic algorithm.Test
Buy & hold
Intermarket security
Combined neural
Hybrid
BIX, XOI, CAC
BIX, XOI, CAC
Account requiredTotal net profitReturn on account %Return on trades %Annual return on trades %Total number of tradesWinning tradesLosing tradesPercent profitableGross profitGross lossAvg. winning tradeAvg. losing tradeAvg. win/avg. lossProfitability coefficientProfit factor
£3750£12 293328 %25.4 %8.1 %110100 %£12 293£0£12 293
£3750£53 1641418 %1510 %480 %1761106662.5 %£85 491£32 327£777−£4901.592.382.64
£3750£23 703632 %790 %251 %63362757.1 %£44 943£21 240£1248−£7871.591.852.12
Max. drawdownMax. open drawdownMax. initial drawdownMax. consecutive lossesRisk/reward
−£11 458−€816−€635093 %
−£4641−£3471£059%
−£8064−£3858−£572334 %
Start date/testOutput end dateTest period (years)Test duration – barsAvg. trade length – barsTrades/year
01/04/0502/27/083.157977970.3
01/04/0502/27/083.15797556
01/04/0502/27/083.157971120
Beginning priceEnding price
4847.06076.5
4847.06076.5
4847.06076.5
0.41−0.21−0.020.00
0.14−0.4100
ThresholdsEnter long (ROC)Sell (ROC)Short (ROC)Cover (Disparity)
Comparison of a Neural Network and a Conventional System for Trading FTSE Futures
229
develop approximate rules. Unfortunately, this is also time-consuming as the numberof different input level combinations to be tested is very large.OutputsWhile it may seem appropriate to attempt to predict the price sometime in the future,this is a particularly difficult task because price changes do not tend to be smooth.Predicting price direction appears easier and is more likely to be successful. Usingthis approach, however, a different problem comes up: a high degree of directionalaccuracy may not translate to high returns after costs if the movement in the forecastdirection is small and therefore the strength of the move in that direction has to bepredicted as well. NeuroShell offer a number of choices and the one which best combined both strength and directional prediction seemed to be the 20-day optimal percentchange in the close. This, according to the NeuroShell help file, “in contrast to simplypredicting the change, the optimal change will try to predict the optimal closing pricechange to the next peak/valley within the specified number of bars into the future”.Trading SpecificationsThe default trade size was one contract per trade, the point value was set at £10 perFTSE point and the required initial margin to £3750. Long and short signals wereexecuted next day at the open and no interest was credited to the account when out ofthe market as this was assumed to cancel out additional slippage, skid and contractrollover costs.Returns were calculated as a percent of the account required to trade each systemand compared to the buy and hold method which involved buying and holding oneFTSE contract for the duration of the test. Rollover costs were ignored. NeuroShellcalculated also the return on trades which is achieved by taking the cumulative sum ofall returns for each trade. For long trades, this is calculated according to the followingformula:Return = 100 ∗ (exit price − entry price − commissions)/(entry price + commissions).The maximum open drawdown was calculated by subtracting the worst intradayprice during any trade from the entry price and multiplying by the point value. Theinitial drawdown was the maximum amount that the equity curve dipped below zerobefore the system started making profits.There are two ways of calculating the required account size. If you assume thatprofits are withdrawn from the account each time that a position is closed, then theaccount size is determined by the margin plus the maximum drawdown of the worsttrade. Alternatively, assuming that profits are compounded to the available account
230
Intermarket Trading Strategies
funds, the required account size should be calculated by adding the initial drawdownto the required margin. Most software (including NeuroShell) use the first method forcalculating the required account size. Maybe this is a more realistic representationof how traders utilize their available funds but since I used the second method for allprevious tests in this book, for the sake of consistency I decided to continue using itfor the current tests as well.The risk/reward was calculated by dividing the maximum drawdown by the totalnet profit. Obviously the less the risk/reward ratio, the better the system. NeuroShellalso offered a choice of specifying the desired longest and shortest average trade span.These are useful in adjusting the number of trades, as a longer time span will involveless trades. These settings, however, are not absolute commands to the optimizer;they are more like requests, which the optimizer will try to honor if it can, withoutsacrificing too much of the objective (profit, etc.). In this case, despite setting theminimum average trade span to seven bars, the last system was short of this target bythree bars, producing an average trade span of only four bars.Network ArchitectureAfter the input and output selection is complete, the training process can be initiated.There are basically three parameters to specify in order to control the size and structureof the model:The number of hidden neurons: Older artificial neural networks were composedof three types of neuron layers: an input layer, one or more hidden layers, and anoutput layer. They used any number of neurons to connect adjoining layers whichhad to be specified by the developer. Most modern ones actually have one layer foreach hidden neuron but the number of hidden neurons (and the associated layers) stillhas to be specified by the developer. This is not an easy task as there are no standardrules available for determining the appropriate number of hidden neurons. Ruggiero(see Bibliography) suggests starting with the same number of hidden neurons as thenumber of inputs and then retraining each model 10 times, adding nodes until resultsbegin to converge.In NeuroShell Trader there is no option to specify the number of initial hiddenneurons. The software actually chooses the correct number of neurons automaticallyby starting with zero hidden neurons (which is equivalent to linear regression) andadding nodes one by one as needed. There is an option, however, to specify themaximum number of hidden neurons. In the current analysis, in order to avoid overfitting, I limited the number of hidden neurons to seven.Training objective: There are obvious mismatches between the goals of neuralnetworks and real traders. While neural networks are attempting to minimize forecasterrors in training, typically traders focus on trying to maximize profits. While theseare both valid goals, a trader’s definition of “success” is different yet again. One
Comparison of a Neural Network and a Conventional System for Trading FTSE Futures
231
trader may seek to maximize profit while another risk-adverse trader may prefer tominimize drawdown.The training objective is vital in neural network systems as it is used for theoptimization of the network structure. Choosing different objectives could result in significantly different results. NeuroShell gives you a choice of 25 different target objectives, which include academic (for example the option to minimize forecast error) and trading (to maximize profits or minimize drawdown)objectives.After some experimentation I chose to maximize return on trades, as this objectiveproduced stable systems with good overall profit/loss statistics, moderate drawdownand a reasonable number of trades. Of course it is important to use the same objectivefor all tests, otherwise any comparisons will be meaningless.
Evaluation of ResultsThe current analysis was mainly intended to compare neural network with conventional rule based technical analysis systems. Because of the sampling restrictionsexplained above, the neural net out-of-sample segment was considerably shorter thanthe corresponding period used to test the conventional system. For obvious reasons,in a situation where time periods of different lengths are being compared, the totalnet profit criterion is misleading and therefore the comparison should be limited toother profitability criteria which are independent of the back-test sample length. Thedrawdown figures were also not comparable because the neural shorter out-of-samplesegment did not include the 2002–2003 bear market.Another important factor to take into account is the different optimization methodsused by the software. MetaStock uses the brute force approach while NeuroShell usesa genetic algorithm (for a full description and advantages or disadvantages of bothmethods please see Chapter 10). In addition, I used the genetic algorithm’s option tooptimize the input contribution, a feature not available from MetaStock. This optionwas disabled in the case of the last (hybrid) strategy.Before proceeding with analyzing the results I should make it clear that it is veryunlikely that you will get exactly the same results with the ones presented here inTables 14.3–14.5. This is because neural networks start training with an arbitrary setof starting weights which results in a slightly different solution each time that thenetwork is trained.Despite the shorter sample, none of the neural network systems managed to beat themultiple regression system (see Tables 14.2, 14.3 and 14.5). A major disadvantage ofthe conventional system, however, was the low turnover (about four trades per year)which makes it suitable only for patient traders or long-term investors.During my research into intermarket neural network systems I noticed that they tendto trade much more often than the corresponding conventional divergence systems.This is a significant advantage because filtering a conventional system leads to even
232
Intermarket Trading Strategies
fewer trades which makes them unsuitable for short-term traders. In addition, moretrades can be translated to higher profits and return on account. This was certainlytrue with the current neural systems which produced no less than 30 trades per yearon average, enough to satisfy most active traders.Curve-fitting is probably the most dangerous snare a trader can walk into but,fortunately, the consistent performance between the testing and out-of-sample results(in Tables 14.3 and 14.4) suggested this was not the case.In fact the only significant difference between the out-of-sample data (Table 14.3)and the testing data (Table 14.4) was the magnitude of the profits. The out-of-sampleproduced a higher overall net profit mainly because of the longer segment period butalso because of higher price levels of the FTSE during the test.When judging the system’s worth, it is important to compare it to the buy andhold strategy. All neural net systems succeeded in beating the buy and hold methodby a wide margin and considerably lower risk. In addition, they avoided the huge£11 500 drawdown which hit the buy and hold investor during the steep correction in January 2008. Although the neural systems avoided the sharp plunges inthe market and associated catastrophic losses they can, similarly to conventionalsystems, fail as well, so it is always a good idea to include a stop-loss condition. Stop-loss conditions were not included in the current study as they wouldhave distorted results by improving the bad systems and making any comparisonirrelevant.
14.6
CONCLUSION
While there is no assurance that neural networks can beat a typical rule-based systemon a profit/trade basis they can most certainly beat it on a total net profit basis. Amajor disadvantage of conventional systems is the low number of trades. This is not,however, the case with neural network systems which can produce five to ten timesas many trades which are usually associated with higher profits.In constructing a viable neural system all we would have to worry about is providingthe most appropriate inputs and then let the neural net train to arrive at the bestmodel. Of course our inputs cannot include the universe of factors that explain stockindex fluctuations because no formula or model exists that can predict accuratelyall the supply-and-demand dynamics that affect stock index prices. Fortunately, wedon’t need a perfect trading system but only a profitable one. Instead of perfection,we should aim to construct a viable system that can produce reasonable profitswhile avoiding large drawdowns that can wipe out all profits and lead to margincalls.Neural network models are excellent at deciphering hidden patterns and relationships in market data as they have the capability to model the ambiguity and identifythe nonlinear characteristics of financial time series which do not easily succumbto analysis by the classic statistical techniques. This is not to say that they can’t be
Comparison of a Neural Network and a Conventional System for Trading FTSE Futures
233
analyzed by conventional methods but neural networks simply make a better job ofanalyzing nonparametric price series without making any unrealistic assumptions.This does not imply, however, that neural networks are the “Holy Grail” that tradershave been looking for. A major drawback is their virtually non-existent explanatorycapability which makes it impossible to see the rules that led to the predictions.As my research has revealed, this makes it difficult to incorporate additional classictechnical conditions or risk management considerations into a neural network-basedtrading system as they may degrade the system’s performance by conflicting with itsunknown internal neural-based rules.I believe my findings may have also a practical significance in deciding on theappropriate data preprocessing techniques, in order to exploit more efficiently thehidden intermarket relationships.Finally, you should keep in mind that the world does not stand still once a model isdefined; network models age in the same way as conventional rule-based models andyou should always keep one step ahead by re-training your system on more recentdata.
15The Use of Intermarket Systemsin Trading Stocks
Successful strategies in trading often require doing what most people finddistinctly uncomfortable.–Jack SchwagerIf you own shares of Archer Daniels Midlands (ADM), have you ever thought offollowing corn futures? What is the possible impact of a steep drop of the priceof copper on the Phelps Dodge stock? It may be worth your effort to analyze suchcorrelations.Intermarket analysis can be a valuable tool when you trade individual orgroups of stocks. This can be accomplished by comparing commodity-relatedstocks with the corresponding commodity or index. Since many stock groups havestrong correlation with commodity markets, it also makes sense to analyze thisrelationship.Some classic examples include the relationship between energy stocks and theprice of crude oil, the correlation between gold miners and gold bullion or the impactof interest rate changes on financial stocks.The systems presented in this chapter for trading oil and gold stocks are examplesof using the correlation between a stock and a related commodity to develop a tradingsystem.
15.1
TESTING METHOD
The correlation matrix between sector indices and related commodities is presented in Table 15.1. The best correlated commodity was used to construct an
236
Intermarket Trading Strategies
Table 15.1 Correlation matrix (using 15-year data) of 10-day % yields.
S&PXOIXAUUTYCRBGoldOilGas
S&P500
XOI
XAU
UTY
CRBIndex
Gold
CrudeOil
NaturalGas
10.470.130.340.06−0.02−0.020.02
0.4710.300.340.390.140.410.26
0.130.3010.110.440.700.190.11
0.340.340.1110.040.04−0.030.10
0.060.390.440.0410.450.540.35
−0.020.140.700.040.4510.140.08
−0.020.410.19−0.030.540.1410.28
0.020.260.110.100.350.080.281
intermarket trading system based on the divergence of each stock from the corresponding commodity.My research has shown that using the relative strength between a stock and itscorresponding index (e.g. between an oil stock and the XOI) as a filter to excludeweak stocks can improve performance.A correlation between two related markets, however, doesn’t always mean that onemarket can always be used to predict the other. To deal with this issue I used Pearson’scorrelation between the stock and its corresponding index as a filter to excludestocks during periods that they decoupled from the corresponding index. This newcondition improved performance and decreased drawdown as it filtered out signals on stocks with specific problems having nothing to do with their industrygroup.All tests started with an initial equity of $100 000 and 10 % of total capital wasallocated per trade. In order to compare them with the buy and hold method, profitsor losses were compounded to the initial equity. No buying on margin was used foreither system.Portfolio test simulations were carried out using Tradesim Enterprise Edition version 4.2.2 (a MetaStock plug-in). The most useful test statistics are presented inTable 15.2. All orders were executed at next day’s opening price at the market, andthe commission charged was $10. No interest was credited when out of the market.The minimum trade size was specified at $3000 and any position was limited to 15 %of traded volume.If you wish to replicate the tests, please keep in mind that for the test to beginproducing signals, the indicators used in each should first be calculated and thisrequires a number of bars to be loaded.The buy and hold profit was calculated by buying equal dollar amount of all stocksin the corresponding index (e.g. all 12 constituents of the XOI index in the case ofthe oil stocks system) on the date of the first portfolio trade and selling them on thelast day of the test.
The Use of Intermarket Systems in Trading Stocks
237
Table 15.2 Profit/loss report of the intermarket oil stock system. In the first column is theprofit of buying and holding all XOI components for the entire test duration. In the secondcolumn are profit statistics using 10 % of capital per trade and in the last column using a fixed$10 000 capital per trade. Comparison with the buy and hold is only meaningful using thefirst method, as the second method used only one tenth of the initial buy-and-hold capital.System
Buy & hold
Intermarket securityNumber of stocksInitial equityCapital/tradeTotal net profitProfit/loss %Annual percent gain/lossTotal number of tradesWinning tradesLosing tradesPercent profitableAvg. winning tradeAvg. losing tradeRatio avg. win/avg. lossProfitability coefficientProfit factorDrawdown %Risk/rewardStart date/testEnd dateTest period (years)Trades/year
$100 000$100 000$354 347354 %30 %110100 %$354 347$0
−6.0 %18.7 %8/1/958/1/0712.00.1
Oil stocks (% of equity)
Oil stocks (equal dollar)
Crude oil244$100 00010 %$1 618 5731619 %135 %3472519672.3 %$8353−$49801.683.494.40−5.4 %3.5 %8/1/958/1/0712.029
Crude oil244$100 000$10 000$295 982296 %25 %3202318972.2 %$1677−$10261.633.424.24−5.5 %3.9 %8/1/958/1/0712.027
System ParametersCorrelation daysLRS oil stocksLRS intermarket SEC1LRS intermarket SEC2IMO – daysIMO – buyIMO – sellTime exit–bars
15.2
300202525200707100
300202525200707100
A SYSTEM FOR TRADING OIL STOCKS
The portfolio model consisted of 244 oil and gas stocks, trading in the three majorUS exchanges, the NYSE, AMEX and Nasdaq, and was tested in the preceding
238
Intermarket Trading Strategies
Figure 15.1 Oil stock system closed trade equity line.
12-year period from 8 August 2005 to 8 August 2007. The portfolio embraced oil andgas stocks across all sub industry groups, including drilling and exploration, majorintegrated oil and gas, pipelines, independent oil and gas, equipment and servicesand oil and gas ETFs.Penny stocks were excluded as a first run revealed that these did not move intandem with the rest of the group, mainly because of their own stock-specific financialproblems.Only long positions were considered as shorting individual stocks is not alwayspossible. It depends on the broker’s ability to borrow the stock but, even if this was possible, I wouldn’t advise it as you can find yourself in a very dangerous predicament incase of a takeover or a surge in oil prices because of an unexpected geopolitical event.
The Use of Intermarket Systems in Trading Stocks
239
Figure 15.2 Graphical representation of yearly profits (o