3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG>0 AND ALERT(CROSS(85,IM),4) AND IM< REF(IM,-1) ANDSTOCH(5,3)>MOV(STOCH(5,3),3,S)AND ROC(SEC2,2,%)>0SellSEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:=20;D2:=15;D3:=-1;
Appendix A
307
DIS1:=((C - Mov(C,D1,S)) / Mov(C,D1,S)) ∗ 100;DIS2:=((SEC2 - Mov(SEC2,D2,S)) / Mov(SEC2,D2,S)) ∗ 100;DIV1:=(D3∗ DIS2-DIS1);DIVERG:=Mov(DIV1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<0 AND {ALERT(CROSS(IM,OPT5),4)} LLV(IM,4)<25 AND IM>REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S)ShortSEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:=20;D2:=15;D3:=-1;DIS1:=((C - Mov(C,D1,S)) / Mov(C,D1,S)) ∗ 100;DIS2:=((SEC2 - Mov(SEC2,D2,S)) / Mov(SEC2,D2,S)) ∗ 100;DIV1:=(D3∗ DIS2-DIS1);DIVERG:=Mov(DIV1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<-1 AND ALERT(CROSS(IM,25),3) AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND ROC(SEC2,2,%)<0CoverSEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:=20;D2:=15;D3:=-1;DIS1:=((C - Mov(C,D1,S)) / Mov(C,D1,S)) ∗ 100;DIS2:=((SEC2 - Mov(SEC2,D2,S)) / Mov(SEC2,D2,S)) ∗ 100;DIV1:=(D3∗ DIS2-DIS1);DIVERG:=Mov(DIV1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));ALERT(DIVERG>0,3) AND HHV(IM,3)>50 AND STOCH(5,3)>MOV(STOCH(5,3),3,S)
LRS (XAU)BuySEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=40;{LRS GOLD}
308
Intermarket Trading Strategies
D2:=50;{LRS INTERMARKET}D3:=STDEV(C,200)/STDEV(SEC2,200);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,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG>0 AND ALERT(CROSS(70,IM),4) AND IM< REF(IM,-1) ANDSTOCH(5,3)>MOV(STOCH(5,3),3,S)AND ROC(SEC2,2,%)>0SellSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=40;{LRS GOLD}D2:=50;{LRS INTERMARKET}D3:=STDEV(C,200)/STDEV(SEC2,200);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,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<0 AND LLV(IM,4)<15 AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S)ShortSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=40;{LRS GOLD}D2:=50;{LRS INTERMARKET}D3:=STDEV(C,200)/STDEV(SEC2,200);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,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<-1 AND ALERT(CROSS(IM,5),3) AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND ROC(SEC2,2,%)<0CoverSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=40;{LRS GOLD}
Appendix A
309
D2:=50;{LRS INTERMARKET}D3:=STDEV(C,200)/STDEV(SEC2,200);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,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));ALERT(DIVERG>0,3) AND HHV(IM,3)>50 AND STOCH(5,3)>MOV(STOCH(5,3),3,S)
LRS (DXY)BuySEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:=30;{LRS GOLD}D2:=40;{LRS INTERMARKET}D3:=-STDEV(C,200)/STDEV(SEC2,200);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,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG>0 AND ALERT(CROSS(85,IM),4) AND IM< REF(IM,-1) ANDSTOCH(5,3)>MOV(STOCH(5,3),3,S)AND ROC(SEC2,2,%)>0SellSEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:=30;{LRS GOLD}D2:=40;{LRS INTERMARKET}D3:=-STDEV(C,200)/STDEV(SEC2,200);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,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<0 AND LLV(IM,4)<25 AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S)
310
Intermarket Trading Strategies
ShortSEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:=30;{LRS GOLD}D2:=40;{LRS INTERMARKET}D3:=-STDEV(C,200)/STDEV(SEC2,200);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,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<-1 AND ALERT(CROSS(IM,25),3) AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND ROC(SEC2,2,%)<0CoverSEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:=30;{LRS GOLD}D2:=40;{LRS INTERMARKET}D3:=-STDEV(C,200)/STDEV(SEC2,200);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,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));ALERT(DIVERG>0,3) AND HHV(IM,3)>60 AND STOCH(5,3)>MOV(STOCH(5,3),3,S)
Bollinger Band (XAU)BuySEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=100;{BB PERIOD GOLD}D2:=100;{BB PERIOD INTERMARKET}sec1BOL:= 1+((C- Mov(C,D1,S)+2∗ Stdev(C,D1))/(4∗ Stdev(C,D1)));sec2BOL:=1+((SEC2- Mov(SEC2,D2,S)+2∗ Stdev(SEC2,D2))/(4∗ Stdev(SEC2,D2)));DIVERG1:=(sec2BOL-sec1BOL)/sec1bol∗ 100;diverg:=Mov(diverg1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));
Appendix A
311
DIVERG>0 AND ALERT(CROSS(70,IM),4) AND IM< REF(IM,-1) ANDSTOCH(5,3)>MOV(STOCH(5,3),3,S)AND ROC(SEC2,2,%)>0SellSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=100;{BB PERIOD GOLD}D2:=100;{BB PERIOD INTERMARKET}sec1BOL:= 1+((C- Mov(C,D1,S)+2∗ Stdev(C,D1))/(4∗ Stdev(C,D1)));sec2BOL:=1+((SEC2- Mov(SEC2,D2,S)+2∗ Stdev(SEC2,D2))/(4∗ Stdev(SEC2,D2)));DIVERG1:=(sec2BOL-sec1BOL)/sec1bol∗ 100;diverg:=Mov(diverg1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));((DIVERG<-5 AND DIVERG>REF(DIVERG,-1)) OR (LLV(IM,4)<30 ANDIM> REF(IM,-1)))AND STOCH(5,3)<MOV(STOCH(5,3),3,S)ShortSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=100;{BB PERIOD GOLD}D2:=100;{BB PERIOD INTERMARKET}sec1BOL:= 1+((C- Mov(C,D1,S)+2∗ Stdev(C,D1))/(4∗ Stdev(C,D1)));sec2BOL:=1+((SEC2- Mov(SEC2,D2,S)+2∗ Stdev(SEC2,D2))/(4∗ Stdev(SEC2,D2)));DIVERG1:=(sec2BOL-sec1BOL)/sec1bol∗ 100;diverg:=Mov(diverg1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<-10 AND ALERT(CROSS(IM,5),3) AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND ROC(SEC2,2,%)<0CoverSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=100;{BB PERIOD GOLD}D2:=100;{BB PERIOD INTERMARKET}sec1BOL:= 1+((C- Mov(C,D1,S)+2∗ Stdev(C,D1))/(4∗ Stdev(C,D1)));sec2BOL:=1+((SEC2- Mov(SEC2,D2,S)+2∗ Stdev(SEC2,D2))/(4∗ Stdev(SEC2,D2)));DIVERG1:=(sec2BOL-sec1BOL)/sec1bol∗ 100;diverg:=Mov(diverg1,3,E);
312
Intermarket Trading Strategies
IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));ALERT(DIVERG>0,3) AND HHV(IM,3)>50 AND STOCH(5,3)>MOV(STOCH(5,3),3,S)
Z-Score (XAU)BuySEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:= 100;r:=Correl(SEC2,C,D1,0);Z1:=(C-Mov(C,D1,S))/Stdev(C,D1);Z2:=(SEC2-Mov(SEC2,D1,S))/Stdev(SEC2,D1);ZDIV:=(Z2∗ r/Abs(r)-Z1)∗ Abs(r);diverg:=Mov(ZDIV,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));ALERT(CROSS(80,IM),4) AND IM< REF(IM,-1) AND STOCH(5,3)>MOV(STOCH(5,3),3,S)AND ROC(SEC2,2,%)>0SellSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:= 100;r:=Correl(SEC2,C,D1,0);Z1:=(C-Mov(C,D1,S))/Stdev(C,D1);Z2:=(SEC2-Mov(SEC2,D1,S))/Stdev(SEC2,D1);ZDIV:=(Z2∗ r/Abs(r)-Z1)∗ Abs(r);diverg:=Mov(ZDIV,3,E);;IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));LLV(IM,4)<50 AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S)ShortSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:= 100;r:=Correl(SEC2,C,D1,0);Z1:=(C-Mov(C,D1,S))/Stdev(C,D1);Z2:=(SEC2-Mov(SEC2,D1,S))/Stdev(SEC2,D1);ZDIV:=(Z2∗ r/Abs(r)-Z1)∗ Abs(r);diverg:=Mov(ZDIV,3,E);;
Appendix A
313
IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<0 AND ALERT(CROSS(IM,10),3) AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND ROC(SEC2,2,%)<0CoverSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:= 100;r:=Correl(SEC2,C,D1,0);Z1:=(C-Mov(C,D1,S))/Stdev(C,D1);Z2:=(SEC2-Mov(SEC2,D1,S))/Stdev(SEC2,D1);ZDIV:=(Z2∗ r/Abs(r)-Z1)∗ Abs(r);diverg:=Mov(ZDIV,3,E);;IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));HHV(IM,3)>40 AND STOCH(5,3)>MOV(STOCH(5,3),3,S)
Z-Score (DXY)BuySEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:= 500;r:=Correl(SEC2,C,D1,0);Z1:=(C-Mov(C,D1,S))/Stdev(C,D1);Z2:=(SEC2-Mov(SEC2,D1,S))/Stdev(SEC2,D1);ZDIV:=(Z2∗ r/Abs(r)-Z1)∗ Abs(r);diverg:=Mov(ZDIV,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));ALERT(CROSS(90,IM),4) AND IM< REF(IM,-1) AND STOCH(5,3)>MOV(STOCH(5,3),3,S)AND ROC(SEC2,2,%)>0SellSEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:= 500;r:=Correl(SEC2,C,D1,0);Z1:=(C-Mov(C,D1,S))/Stdev(C,D1);Z2:=(SEC2-Mov(SEC2,D1,S))/Stdev(SEC2,D1);ZDIV:=(Z2∗ r/Abs(r)-Z1)∗ Abs(r);diverg:=Mov(ZDIV,3,E);;
314
Intermarket Trading Strategies
IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));LLV(IM,4)<50 AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S)ShortSEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:= 500;r:=Correl(SEC2,C,D1,0);Z1:=(C-Mov(C,D1,S))/Stdev(C,D1);Z2:=(SEC2-Mov(SEC2,D1,S))/Stdev(SEC2,D1);ZDIV:=(Z2∗ r/Abs(r)-Z1)∗ Abs(r);diverg:=Mov(ZDIV,3,E);;IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<0 AND ALERT(CROSS(IM,5),3) AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND ROC(SEC2,2,%)<0CoverSEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:=500;r:=Correl(SEC2,C,D1,0);Z1:=(C-Mov(C,D1,S))/Stdev(C,D1);Z2:=(SEC2-Mov(SEC2,D1,S))/Stdev(SEC2,D1);ZDIV:=(Z2∗ r/Abs(r)-Z1)∗ Abs(r);diverg:=Mov(ZDIV,3,E);;IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));HHV(IM,3)>50 AND STOCH(5,3)>MOV(STOCH(5,3),3,S)
Multiple Regression Divergence (XAU-SLV-DXY)BuySEC1:=Security(“C:\Metastock Data\METAS\XAU”,C);SEC2:=Security(“C:\Metastock Data\METAS\SLV”,C);SEC3:=Security(“C:\Metastock Data\METAS\DXY0”,C);D2:=11; {ROC DAYS}a:=.16;b1:=.2;b2:=.175;b3:=-.5;ROCY:=ROC(C,D2,%);ROC1:=ROC(SEC1,D2,%);ROC2:=ROC(SEC2,D2,%);ROC3:=ROC(SEC3,D2,%);
Appendix A
315
PRED:=a+b1∗ ROC1+b2∗ ROC2+b3∗ ROC3;DIVERG1:=(PRED-ROCY)∗ 10;DIVERG:=Mov(DIVERG1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,300), 3,S) ∗ 100)/(Mov(HHV(DIVERG,300) - LLV(DIVERG,300), 3,S));DIVERG>1 AND ALERT(CROSS(70,IM),4) AND STOCH(5,3)>MOV(STOCH(5,3),3,S)SellSEC1:=Security(“C:\Metastock Data\METAS\XAU”,C);SEC2:=Security(“C:\Metastock Data\METAS\SLV”,C);SEC3:=Security(“C:\Metastock Data\METAS\DXY0”,C);D2:=11; {ROC DAYS}a:=.16;b1:=.2;b2:=.175;b3:=-.5;ROCY:=ROC(C,D2,%);ROC1:=ROC(SEC1,D2,%);ROC2:=ROC(SEC2,D2,%);ROC3:=ROC(SEC3,D2,%);PRED:=a+b1∗ ROC1+b2∗ ROC2+b3∗ ROC3;DIVERG1:=(PRED-ROCY)∗ 10;DIVERG:=Mov(DIVERG1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,300), 3,S) ∗ 100)/(Mov(HHV(DIVERG,300) - LLV(DIVERG,300), 3,S));STOCH(15,3)<MOV(STOCH(15,3),5,S) AND HHV(STOCH(15,3),3)>80 ANDLLV(IM,4)<14ShortSEC1:=Security(“C:\Metastock Data\METAS\XAU”,C);SEC2:=Security(“C:\Metastock Data\METAS\SLV”,C);SEC3:=Security(“C:\Metastock Data\METAS\DXY0”,C);D2:=11; {ROC DAYS}a:=.16;b1:=.2;b2:=.175;b3:=-.5;ROCY:=ROC(C,D2,%);ROC1:=ROC(SEC1,D2,%);ROC2:=ROC(SEC2,D2,%);ROC3:=ROC(SEC3,D2,%);PRED:=a+b1∗ ROC1+b2∗ ROC2+b3∗ ROC3;DIVERG1:=(PRED-ROCY)∗ 10;DIVERG:=Mov(DIVERG1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,300), 3,S) ∗ 100)/(Mov(HHV(DIVERG,300) - LLV(DIVERG,300), 3,S));DIVERG<-4 AND STOCH(5,3)<MOV(STOCH(5,3),5,S)AND ALERT(CROSS(IM,7),4) AND IM>1.2∗ REF(IM,-2)
316
Intermarket Trading Strategies
CoverSEC1:=Security(“C:\Metastock Data\METAS\XAU”,C);SEC2:=Security(“C:\Metastock Data\METAS\