<60 AND STOCH(15,3)<MOV(STOCH(15,3),4,S) AND SEC2<MOV(SEC2,15,E) AND C<MOV(C,15,E)Buy to coverSEC2:=Security(“C:\Metastock Data\INTERMARKET\T2108”,C);STOP:=LLV(C,4)+2.2∗ ATR(8);(STOCH(15,3)>MOV(STOCH(15,3),3,S) AND LLV(SEC2,9)<25AND (SEC2>30 OR SEC2>MOV(SEC2,5,E)))OR CROSS(C,STOP) OR (LLV(SEC2,9)<40 AND CROSS(C,MOV(C,5,E)))
S&P 500 E-mini 15-min Intraday System(Copyright Markos Katsanos 2008)To recreate the tests click on enhanced system tester, click on new system and typethe buy, sell, sell short and buy to cover code. Then to run the test, click on newsimulation, next, add securities, select ES, select periodicity 15 min, click on next,type in initial equity 40000, select Number of units 250 (5 contracts x 50), select bothlong and short trades. Click on more. . ., fill in interest rate margin 0 %, Money Market0 %, and fill in 12 (2.4x5) points per transaction for the commissions, and then fillin the following margin requirements: Long Initial:5.5 %, Long Maintenance:4.4 %,Short Initial:105.5 %, Short Maintenance:104.4 %. Click on trade execution, uncheck
Appendix A
325
realistic market prices and select buy price and sell price at open and then fill in1 day for the delay. The first line of the code should be modified to point to the folderin your computer that Euro Stoxx futures data are located and the 12th line should bemodified to your local time (e.g. if you are located in France this should be changedto HOUR()<=15).LongSEC2:=Security(“C:\Metastock Data\RT\FESX”,C);D1:=9;{LRS ES}D2:=9;{LRS ESTX}D3:=Stdev(C,200)/(Stdev(SEC2,200)+.01);LRSI:=LinRegSlope(SEC2,D2)/Abs(Ref(SEC2,-D2+1))∗ 100;LRS:=LinRegSlope(C,D1)/Abs(Ref(C,-D1+1))∗ 100;DIV1:=(D3∗ LRSI-LRS)∗ 100;DIVERG:=Mov(DIV1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,250), 3,S) ∗ 100)/(Mov(HHV(DIVERG,250)-LLV(DIVERG,250),3,S)+.01);CI:=ROC(C,14,%)∗ 100/((HHV(H,15)-LLV(L,15)+.001)/(LLV(L,15)+.1)∗100);(HOUR()<=9 AND HHV(DIVERG,2)>0 AND IM>70 AND IM<REF(IM,-1) AND Stoch(5,3)>Mov(Stoch(5,3),4,S) AND ROC(SEC2,5,%)>.2AND CI>REF(CI,-1)) {DIVERGENCE}OR (ABS(CI)<20 AND Stoch(15,3)>Mov(Stoch(15,3),4,S) AND LLV(Stoch(15,3),3)<30 AND ROC(C,1,%)>.1 AND ROC(SEC2,1,%)>.1){CONGESTION}OR (IM>50 AND ROC(C,10,%)>.2 AND ROC(SEC2,9,%)>.4 ANDC>MOV(C,40,E) AND MACD()>MOV(MACD(),9,E) AND CI>20 ANDCI<85) {TRENDING}SellSEC2:=Security(“C:\Metastock Data\RT\FESX”,C);D1:=9;{LRS ES}D2:=9;{LRS ESTX}D3:=Stdev(C,200)/(Stdev(SEC2,200)+.01);LRSI:=LinRegSlope(SEC2,D2)/Abs(Ref(SEC2,-D2+1))∗ 100;LRS:=LinRegSlope(C,D1)/Abs(Ref(C,-D1+1))∗ 100;DIV1:=(D3∗ LRSI-LRS)∗ 100;DIVERG:=Mov(DIV1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,250), 3,S) ∗ 100)/(Mov(HHV(DIVERG,250)-LLV(DIVERG,250),3,S)+.01);STOP:=HHV(C,4)-1.6∗ ATR(8);CI:=ROC(C,14,%)∗ 100/((HHV(H,15)-LLV(L,15)+.001)/(LLV(L,15)+.1)∗100);
326
Intermarket Trading Strategies
(HOUR()<=9 AND DIVERG<0 AND STOCH(15,3)<MOV(STOCH(15,3),4,S)AND LLV(IM,4)<15 AND IM>REF(IM,-1) AND ROC(SEC2,2,%)<0){DIVERGENCE}OR (ABS(CI)<20 AND Stoch(15,3)<Mov(Stoch(15,3),4,S) AND HHV(Stoch(15,3),3)>90 AND IM<50) {CONGESTION}OR (CI<-20 AND ROC(C,9,%)<-.4 AND ROC(SEC2,9,%)<-.4) {TRENDING}OR (HHV(CI,3)>85 AND ABS(CI)<60 AND Stoch(15,3)<Mov(Stoch(15,3),4,S) AND HHV(Stoch(15,3),3)>80 AND ROC(C,1,%)<-.1) {REVERSAL}OR CROSS(STOP,C)Sell ShortSEC2:=Security(“C:\Metastock Data\RT\FESX JUN 07”,C);D1:=9;{LRS ES}D2:=9;{LRS ESTX}D3:=Stdev(C,200)/(Stdev(SEC2,200)+.01);LRSI:=LinRegSlope(SEC2,D2)/Abs(Ref(SEC2,-D2+1))∗ 100;LRS:=LinRegSlope(C,D1)/Abs(Ref(C,-D1+1))∗ 100;DIV1:=(D3∗ LRSI-LRS)∗ 100;DIVERG:=Mov(DIV1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,250), 3,S) ∗ 100)/(Mov(HHV(DIVERG,250)-LLV(DIVERG,250),3,S)+.01);CI:=ROC(C,14,%)∗ 100/((HHV(H,15)-LLV(L,15)+.001)/(LLV(L,15)+.1)∗ 100);(HOUR()<=9 AND LLV(DIVERG,2)<0 AND STOCH(15,3)<MOV(STOCH(15,3),4,S) AND LLV(IM,4)<5 AND IM>REF(IM,-1) AND ROC(SEC2,5,%)<0 AND CI<REF(CI,-1)) {DIVERGENCE}OR (ABS(CI)<20 AND Stoch(15,3)<Mov(Stoch(15,3),4,S) AND HHV(Stoch(15,3),3)>80 AND ROC(C,1,%)<-.1 AND ROC(SEC2,1,%)<-.1 ANDIM<50) {CONGESTION}OR (IM<50 AND ROC(C,10,%)<-.2 AND ROC(SEC2,9,%)<-.4 ANDC<MOV(C,40,E) AND MACD()<MOV(MACD(),9,E) AND CI<-20 ANDCI>-85) {TREND}Buy to CoverSEC2:=Security(“C:\Metastock Data\RT\FESX JUN 07”,C);D1:=9;{LRS ES}D2:=9;{LRS ESTX}D3:=Stdev(C,200)/(Stdev(SEC2,200)+.01);LRSI:=LinRegSlope(SEC2,D2)/Abs(Ref(SEC2,-D2+1))∗ 100;LRS:=LinRegSlope(C,D1)/Abs(Ref(C,-D1+1))∗ 100;DIV1:=(D3∗ LRSI-LRS)∗ 100;DIVERG:=Mov(DIV1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,250), 3,S) ∗ 100)/(Mov(HHV(DIVERG,250)-LLV(DIVERG,250),3,S)+.01);
Appendix A
327
CI:=ROC(C,14,%)∗ 100/((HHV(H,15)-LLV(L,15)+.001)/(LLV(L,15)+.1)∗ 100);STOP:=LLV(C,4)+1.6∗ ATR(8);(HOUR()<=9 AND IM>75 AND ROC(SEC2,2,%)>0 ANDStoch(15,3)>Mov(Stoch(15,3),4,S)) {DIVERGENCE}OR (ABS(CI)<20 AND Stoch(15,3)>Mov(Stoch(15,3),4,S) AND LLV(Stoch(15,3),3)<30) {CONGESTION}OR (CI>20 AND ROC(C,9,%)>.4 AND ROC(SEC2,9,%)>.4) {TRENDING}OR (LLV(CI,3)<-85 AND ABS(CI)<60 AND Stoch(15,3)>Mov(Stoch(15,3),4,S) AND LLV(Stoch(15,3),3)<30 AND ROC(C,1,%)>.1) {REVERSAL}OR CROSS(C,STOP)A.4 METASTOCK CODE FOR THE DAX SYSTEMS DESCRIBEDIN CHAPTER 13DAX Daily Disparity System(Copyright Markos Katsanos 2008)To recreate the tests click on enhanced system tester, click on new system and type thebuy and sell code. Then to run the test, click on new simulation, next, add securities,select Dax Futures continuous (@:FDXc1), select periodicity daily, click on next,select points only test. Click on more. . ., and fill in the commissions 0.08 points pertransaction (€2). Click on trade execution, uncheck realistic market prices and selectbuy price and sell price at open. Then fill in 1 day for the delay.You will need also to change the first line of the code to point to the appropriatefolder in your hard drive where CAC 40 futures are located.LongSEC2:=Security(“C:\Metastock Data\REUTERSFUTURES\@:FCEc1”,C);CI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);D1:=10;DIS1:=((C-Mov(C,D1,S)) /Mov(C,D1,S))∗ 100;DIS2:=((SEC2-Mov(SEC2,D1,S))/Mov(SEC2,D1,S))∗ 100;DIV2:=DIS2-DIS1;DIVERG:=Mov(DIV2,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));LRS20:=LinRegSlope(C,20)/Abs(Ref(C,-19))∗ 100;LRS:=LinRegSlope(C,40)/Abs(Ref(C,-39))∗ 100;(HHV(DIVERG,2)>0 AND IM>65 AND IM<REF(IM,-1) ANDStoch(5,3)>Mov(Stoch(5,3),4,S) AND ROC(SEC2,6,%)>.4AND ROC(C,1,%)>0){Buy Condition 1 -DIVERGENCE}
328
Intermarket Trading Strategies
OR (ABS(CI)<35 AND LRS20< .2 AND LLV(STOCH(15,3),4)<30 ANDSTOCH(15,3)>30 AND STOCH(5,3)>MOV(STOCH(5,3),4,S)){Buy Condition 2 CONGESTION}SellSEC2:=Security(“C:\Metastock Data\REUTERSFUTURES\@:FCEc1”,C);CI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);D1:=10;DIS1:=((C - Mov(C,D1,S)) / Mov(C,D1,S))∗ 100;DIS2:=((SEC2 - Mov(SEC2,D1,S)) / Mov(SEC2,D1,S)) ∗ 100;DIV2:=DIS2DIS1;DIVERG:=Mov(DIV2,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));(DIVERG<0 AND LLV(IM,4)<5 AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S)) {Sell Condition 1: DIVERGENCE}OR (hhv(CI,3)-CI>40 AND DIV2<0 AND ROC(C,3,%)<-.1) {Sell Condition2: Trend reversal}OR (MOV(C,10,S)<MOV(C,150,S) AND CROSS(MOV(MACD(),7,E),MACD())AND DIV2<0) {Sell Condition 3- Bear Market downtrend}OR (DIVERG<-1 AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND ROC(C,2,%)<-.5 AND ROC(SEC2,2,%)<-.6) {Sell Condition 4: Intermarket}Sell shortSEC2:=Security(“C:\Metastock Data\REUTERSFUTURES\@:FCEc1”,C);CI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);LRS20:=LinRegSlope(C,20)/Abs(Ref(C,-19))∗ 100;LRS:=LinRegSlope(C,40)/Abs(Ref(C,-39))∗ 100;(hhv(CI,3)-CI>50 AND LRS<0 AND MACD()<MOV(MACD(),7,E)){Short condition 1: Trend reversal} OR(ABS(CI)<30 AND LRS20< .1 AND HHV(STOCH(25,3),4)>85 ANDSTOCH(25,3)<70 AND STOCH(5,3)<MOV(STOCH(5,3),4,S)) {Short condition 2: CONGESTION}Buy to coverSEC2:=Security(“C:\Metastock Data\REUTERSFUTURES\@:FCEc1”,C);CI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);D1:=10;DIS1:=((C - Mov(C,D1,S)) / Mov(C,D1,S)) ∗ 100;DIS2:=((SEC2 - Mov(SEC2,D1,S)) / Mov(SEC2,D1,S))∗ 100;DIV2:=DIS2DIS1;
Appendix A
329
DIVERG:=Mov(DIV2,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));(DIVERG>0 AND HHV(IM,4)>60 AND IM< REF(IM,-1)AND STOCH(5,3)>MOV(STOCH(5,3),3,S)) {Cover condition 1: Divergence}OR (LLV(CI,3)-CI<-40) {Cover condition 2: Trend reversal}OR (MOV(C,10,S)>MOV(C,150,S) AND CROSS(MACD(),MOV(MACD(),7,E))){Cover condition 3: Trend}OR (ABS(CI)<30 AND LLV(STOCH(25,3),4)<30 AND STOCH(25,3)>40AND STOCH(5,3)>MOV(STOCH(5,3),4,S)) {Cover condition 4: CONGESTION}DAX MA Crossover SystemLongCI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);(CI>30 AND STOCH(5,3)>MOV(STOCH(5,3),3,S) AND MOV(C,15,S)>MOV(C,20,S)) OR (ABS(CI)<25 AND STOCH(5,3)>MOV(STOCH(5,3),3,S) ANDLLV(STOCH(40,3),2)<30) {CONGESTION}SellCI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);(hhv(CI,3)-CI>40) OR (ABS(CI)<20 AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND HHV(STOCH(40,3),4)>85 AND STOCH(40,3)<75){CONGESTION}ShortCI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);(CI<-30 AND ROC(CI,3,%)<0 AND STOCH(5,3)<MOV(STOCH(5,3),3,S)AND MOV(C,10,S)<MOV(C,20,S) AND MOV(C,2,S)<MOV(C,150,S)) OR(ABS(CI)<25 AND ROC(CI,3,%)<0 AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND HHV(STOCH(40,3),2)>70) {CONGESTION}Buy to coverCI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);LLv(CI,3)-CI<-40 OR (CROSS(MACD(),MOV(MACD(),7,E)) AND C>MOV(C,7,E))DAX Intermarket Enhanced MA Crossover SystemLongSEC2:=Security(“C:\Metastock Data\REUTERSFUTURES\@:STXEc1”,C);CI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);
330
Intermarket Trading Strategies
D1:=10;DIS1:=((C - Mov(C,D1,S)) / Mov(C,D1,S)) ∗ 100;DIS2:=((SEC2 - Mov(SEC2,D1,S)) / Mov(SEC2,D1,S)) ∗ 100;DIV2:=DIS2DIS1;(CI>30 AND STOCH(5,3)>MOV(STOCH(5,3),3,S) AND MOV(C,15,S)>MOV(C,20,S)) OR (ABS(CI)<25 AND STOCH(5,3)>MOV(STOCH(5,3),3,S)AND LLV(STOCH(40,3),2)<30 AND ROC(SEC2,1,%)>0 AND DIV2>0){CONGESTION}SellSEC2:=Security(“C:\Metastock Data\REUTERSFUTURES\@:STXEc1”,C);CI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);D1:=10;DIS1:=((C - Mov(C,D1,S)) / Mov(C,D1,S)) ∗ 100;DIS2:=((SEC2 - Mov(SEC2,D1,S)) / Mov(SEC2,D1,S)) ∗ 100;DIV2:=DIS2DIS1;(hhv(CI,3)-CI>40) OR (ABS(CI)<20 AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND HHV(STOCH(40,3),4)>85 AND STOCH(40,3)<75 AND DIV2<0){CONGESTION}ShortSEC2:=Security(“C:\Metastock Data\REUTERSFUTURES\@:STXEc1”,C);CI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);D1:=10;DIS1:=((C - Mov(C,D1,S)) / Mov(C,D1,S)) ∗ 100;DIS2:=((SEC2 - Mov(SEC2,D1,S)) / Mov(SEC2,D1,S)) ∗ 100;DIV2:=DIS2DIS1;(CI<-30 AND ROC(CI,3,%)<0 AND DIV2<0 AND ROC(SEC2,2,%)<-.5 ANDSTOCH(5,3)<MOV(STOCH(5,3),3,S) AND MOV(C,10,S)<MOV(C,20,S)AND MOV(C,2,S)<MOV(C,150,S))OR (ABS(CI)<25 AND ROC(CI,3,%)<0 AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND HHV(STOCH(40,3),2)>70 AND ROC(SEC2,1,%)<0 ANDDIV2<0 AND MOV(SEC2,10,S)<MOV(SEC2,20,S)) {CONGESTION}Buy to coverSEC2:=Security(“C:\Metastock Data\REUTERSFUTURES\@:STXEc1”,C);CI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);D1:=10;DIS1:=((C - Mov(C,D1,S)) / Mov(C,D1,S)) ∗ 100;DIS2:=((SEC2 - Mov(SEC2,D1,S)) / Mov(SEC2,D1,S)) ∗ 100;DIV2:=DIS2DIS1;
Appendix A
331
LLv(CI,3)-CI<-40 OR (CROSS(MACD(),MOV(MACD(),7,E)) AND C>MOV(C,7,E))
MetaStock Code for Tradesim Simulation of the DAX Component StockDisparity SystemThis test can only be run with Tradesim (a MetaStock plug-in) which can be obtainedfrom http://www.compuvision.com.au/.After running the MetaStock exploration open Tradesim and load the followingDAX component stocks: ALV,BAS,BAY,DAI,DBK,DTE,EOA,SIE,RWE, SAP.Check the Pyramid profits and Equal dollar units boxes and fill in the followingtrade parameters:Initial trading capital: 28 000Maximum open positions: 20Transaction cost: 10Margin: 50 %Capital per trade: 20 000Minimum trade size: 5000SEC2:=Security(“C:\Metastock Data\REUTERSFUTURES\@:FCEc1”,C);CI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);D1:=10;STOP:=HHV(C,3)-2.2∗ ATR(10);DIS1:=((C-Mov(C,D1,S)) /Mov(C,D1,S))∗ 100;DIS2:=((SEC2-Mov(SEC2,D1,S))/Mov(SEC2,D1,S))∗ 100;DIV2:=DIS2-DIS1;DIVERG:=Mov(DIV2,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));LRS20:=LinRegSlope(C,20)/Abs(Ref(C,-19))∗ 100;LRS:=LinRegSlope(C,40)/Abs(Ref(C,-39))∗ 100;ENTRYTRIGGER:=(HHV(DIVERG,2)>0 AND IM>65 AND IM<Ref(IM,1) AND Stoch(5,3)>Mov(Stoch(5,3),4,S) AND ROC(SEC2,6,%)>.4 ANDROC(C,1,%)>0) {DIVERGENCE}OR (Abs(CI)<35 AND LRS20< .2 AND LLV(Stoch(15,3),4)<30 ANDStoch(15,3)>30 AND Stoch(5,3)>Mov(Stoch(5,3),4,S)) {CONGESTION};EXITTRIGGER:=(DIVERG<0 AND LLV(IM,4)<5 AND IM> Ref(IM,-1)AND Stoch(5,3)<Mov(Stoch(5,3),3,S))OR (HHV(CI,3)-CI>40 AND DIV2<0 AND ROC(C,3,%)<-.1)OR (Mov(C,10,S)<Mov(C,150,S) AND Cross(Mov(MACD(),7,E),MACD())AND DIV2<0)
332
Intermarket Trading Strategies
OR (DIVERG<-1 AND Stoch(5,3)<Mov(Stoch(5,3),3,S) AND ROC(C,2,%)<-.5AND ROC(SEC2,2,%)<-.6) OR Cross(STOP,L);ExtFml(“TradeSim.SetTimeStop”,50);ExtFml(“TradeSim.EnableDelayOfEntryByOneBar”);ExtFml(“TradeSim.EnableDelayOfAllExitsByOneBar”);ExtFml(“TradeSim.RecordTrades”,"DAX10DIS”,LONG, EntryTrigger,OPEN,0,EXITTRIGGER,OPEN,START);MetaStock Exploration of the DAX Component StocksTo create the DAX Stock exploration, go to The Explorer and choose the New button.Enter in the following code in the filter column. To explore for possible hits, open theExplorer (click on binocular icon), click on Options and load 500 records, then clickexplore and select the folder in your hard drive with the 30 DAX component stocks.Be sure to change the first line of the code to point to the appropriate folder on yourhard drive where the CAC 40 futures continuous data are located. Alternatively, ifyou don’t have a futures data provider you can use data for the CAC 40 Index fromYahoo (ticker: ˆFCHI) or other sources.SEC2:=Security(“C:\Metastock Data\REUTERSFUTURES\@:FCEc1”,C);CI:=ROC(C,39,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);D1:=10;STOP:=HHV(C,3)-2.2∗ ATR(10);DIS1:=((C-Mov(C,D1,S)) /Mov(C,D1,S))∗ 100;DIS2:=((SEC2-Mov(SEC2,D1,S))/Mov(SEC2,D1,S))∗ 100;DIV2:=DIS2-DIS1;DIVERG:=Mov(DIV2,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));LRS20:=LinRegSlope(C,20)/Abs(Ref(C,-19