materiallyaltered, which of course removes them from the category of statistics, they tell theirown true story in a very clear and understandable way.The test data presented in this book showed significantly superior returns of intermarket transaction timing models compared to a buy and hold policy.The paradox of investing is that since stocks have a long-term upward bias, increasing your holding period increases the probability of profit. The mantra of mutualfund managers don’t lose sleep over large drawdowns, as long as they don’t underperform the S&P 500 and are more concerned about missing the next upside rather than
294
Intermarket Trading Strategies
losing billions during a bear market. However buy and hold investors who embracethis philosophy make unrealistic assumptions about their tolerance for pain and loss,because a small correction – and not even a primary bear market – may wipe themout financially.In addition, the approach of most investors is to have no risk management at alland it becomes obvious too late that this is extremely dangerous. Transaction timingis of course one, but not the only, strategy for reducing portfolio risk.Diversification provides substantial risk reduction if the components of a portfolioare uncorrelated. The benefits of diversification are well known; most investmentmanagers extend their operations by including bonds and cash in a stock portfolioalready expanded across many industry groups. Less well known is the fact thatcommodity futures are an attractive diversification candidate. While it would beunrealistic to expect the spectacular returns of the past few years most of the nonindustrial commodities have weak to non existent correlation with equities and caneffectively decrease the overall volatility of a properly structured portfolio whilemaintaining or improving return characteristics.In addition, individual commodities tend to be uncorrelated which will reduceportfolio risk even more.Another overlooked asset class which should be included in one’s portfolio isforeign currencies or forex. Banks and other institutions already use the forex marketsin order to hedge foreign exposure but this is not so widely used by individualinvestors. An example would make this easier to understand.Consider a European investor who invested in the S&P 500. In 2007 he would havemade a 3.5 % profit in dollar terms but on converting his account to his local currencyhe would be looking at a 7 % loss. Hedging the currency exposure would requireonly 2 % margin (or $2000) on a $100 000 account which would have resulted inrepatriation of all profits unimpaired. A US investor, on the other hand, by selling thedollar short (or buying euros) would have increased his paltry 3.5 % to a respectable14 % return on account. These dramatic differences are due to the weak dollar andinternational investors should always take into account the direction of the currencymarkets.A combination of market timing and asset diversification (discussed in Chapter16) is an alternative approach to a static diversification allocation. The return/riskcharacteristics could be increased even more by utilizing classical market timing toshift capital among several asset classes, depending on relative performance.It is beginning to appear that technical analysis is becoming too popular as computer models proliferate and stress short-term results. You should remember thatclassic technical analysis indicators such as moving averages are lagging indicatorscalculated from past data and are limited in assessing the current trend. Regardlessof the hours spent in back-testing, there is a limit beyond which a system based on alagging indicator can be improved any more. Thus the addition of leading indicatorsthat anticipate reversals in trend direction is essential and beneficial to the system’s
Conclusion
295
performance. These can only be implemented by taking into consideration directionalmovements of correlated markets.Although the performance results that appear in this book may create the impressionthat all market turns can be identified by intermarket divergence indicators, this is notalways the case. No market timing technique or indicator is infallible. Just about thetime you become convinced that one is, and you are comfortable with its applicationand performance results, it will invariably fail. Intermarket divergence indicatorsare no exception and they usually fail in periods of temporary decoupling betweentraditionally correlated markets.Having a good exit strategy, therefore, should be an essential part of your tradingsystem. Then, like the pilot getting ready to bail out from his falling aircraft, the onlychallenge left is in summoning the courage to push the mouse button (or call yourbroker).It should be noted that while the scope of this book was to demonstrate the efficacyof intermarket analysis when applied to market averages or financial futures, thesame methods can also be applied in a similar manner to stock trading. Since manystock groups are hooked to commodity markets, it also makes sense to use theserelationships to enhance your stock trading system.The inferences drawn from the tests presented in this book are by no meansexhaustive. They are presented as a challenge to the serious trader to stimulatehis reevaluation of intermarket techniques as a working tool and to introduce atesting framework which amalgamates both intermarket and classic technical analysisindicators.Anyone who has become even semi-scholarly about the market knows that thereare no mathematical formulas that produce black or white results, or reliable andimmutable intermarket relationships that can predict every market quirk but youshould instead seek out strategies based on probabilities.You should not aspire for a perfect system but must completely accept the fact thatoccasionally your system is going to be wrong.Fortunately, you don’t need a perfect trading system, for trading profits anyway.Instead of perfection you should aim to construct a viable system that can producereasonable profits, while avoiding large drawdowns that can wipe you out of thegame.Finally, I cannot stress enough that effective money management is essential forlong-term survival. Most traders approach a trading decision considering only theexpected gain but they overlook what is far more important: the potential loss. Theobjective of any money management system is to cut losses short and let profits run.Avoiding losses is far more important to long-term performance than making bigprofits because of one basic mathematical principle: It takes a far greater percentagegain to make up for a given percentage loss.
Appendix AMetaStock Code and TestSpecifications
A.1 METASTOCK CODE FOR THE INDICATORS DESCRIBEDIN CHAPTER 9(Copyright Markos Katsanos 2008)Intermarket Relative Strength IndicatorTo create this indicator click on the indicator builder f(x) , click on new and then copythe following code in the formula box.You will also need to change the first line of the code to point to the appropriatefolder in your hard drive where data for the dollar index are located.SEC2:=Security(“C:\Metastock Data\INTERMARKET\DXY0”,C);D1:=Input(“MA DAYS”,1,300,3);RS:=Mov((C/SEC2),3,E);RS
Intermarket Bollinger Band DivergenceThe indicator should be applied on the plot of the related intermarket security.D1:=Input(“PERIOD FOR BB”,5,1000,40);D2:=Input(“PERIOD FOR BB INTERMARKET ”,5,1000,40);sec1BOL:=1+((C- Mov(C,D1,S)+2∗ Stdev(C,D1))/(4∗ Stdev(C,D1)));sec2BOL:=1+(INDICATOR-
298
Intermarket Trading Strategies
Mov(INDICATOR,D2,S)+2∗ Stdev(INDICATOR,D2))/(4∗ Stdev(INDICATOR,D2));DIVERG1:=(sec2BOL-sec1BOL)/SEC1BOL∗ 100;diverg:=Mov(diverg1,3,E);DIVERGIntermarket DisparityYou will also need to change the first line of the code to point to the appropriatefolder in your hard drive where data for the dollar index are located.SEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:=Input(“MA PERIOD BASE SECURITY”,5,200,30);D2:=Input(“MA PERIOD INTERMARKET SECURITY”,5,200,30);D3:=Input(“ FOR +VE CORRELATION +1, FOR -VE -1”,-1,1,-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);DIVERGIntermarket LRS DivergenceThe indicator should be applied on the plot of the related intermarket security.D1:=Input(“DAYS FOR DIVERG”,1,200,15);D2:=Input(“DIVERG POSITIVE +1,-VE-1”,-1,1,1);D3:=D2∗ Stdev(C,200)/Stdev(P,200);LRSI:=LinRegSlope(P,D1)/Abs(Ref(P,-D1+1))∗ 100;LRS:=LinRegSlope(C,D1)/Abs(Ref(C,-D1+1))∗ 100;DIVERG:=(D3∗ LRSI-LRS)∗ 100;Mov(DIVERG,3,E)The formula above should only be used when comparing securities at similar pricelevels. When applied to compute the divergence between a high and a low pricedsecurity (e.g. Gold and Silver futures) then both prices should be normalized or thethird line of the code should be modified to adjust for the price level as follows:D3:=D2∗ Stdev(C,200)/Stdev(P,200)∗ Mov(P,200,S)/Mov(S,200,S);Intermarket Regression Divergence IndicatorIn the first line of the code, SEC2 should be the symbol of the appropriate intermarketsecurity and its correct folder in your hard drive.SEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=Input(“DAYS FOR REGRESSION”,1,2000,300);
Appendix A
299
D2:=Input(“ROC DAYS”,1,100,15);RS1:=ROC(C,D2,%);RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/Stdev(RS2,D1);PRED:=b∗ RS2;DIVERG:=(PRED-RS1);Mov(DIVERG,3,E)Intermarket Regression Divergence Indicator with InterceptSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=Input(“DAYS FOR REGRESSION”,1,2000,300);D2:=Input(“ROC DAYS”,1,100,15);RS1:=ROC(C,D2,%);RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/Stdev(RS2,D1);a:=Mov(RS1,D1,S)-b∗ Mov(RS2,D1,S);PRED:=b∗ RS2+a;DIVERG:=(PRED-RS1);Mov(DIVERG,3,E)Intermarket Momentum OscillatorThe oscillator should be applied on the plot of the intermarket divergence indicator.D1 := Input(“Days for Oscillator”, 2, 400, 200);(Mov(INDICATOR - LLV(INDICATOR,D1), 3,S) ∗ 100)/(Mov(HHV(INDICATOR,D1) - LLV(INDICATOR,D1), 3,S))Double LRS DivergenceYou will need to change the first two lines of the code to point to the appropriatefolder in your hard drive where data for the silver ETF (SLV) and the dollar indexare located.SEC1:=Security(“C:\Metastock Data\METAS\SLV”,C);SEC2:=Security(“C:\Metastock Data\METAS\DXY0”,C);D1:=Input(“DAYS FOR DIVERG”,1,200,15);D2:=Input(“DAYS FOR CORRELATION”,1,1000,300);sY:=Stdev(C,D2)/Mov(C,D2,S);s1:=Stdev(SEC1,D2)/Mov(SEC1,D2,S);s2:=Stdev(SEC2,D2)/Mov(SEC2,D2,S);
300
Intermarket Trading Strategies
rY1:=Correl(SEC1,C,D2,0);rY2:=Correl(SEC2,C,D2,0);r12:=Correl(SEC1,SEC2,D2,0);rY12:=(rY1-rY2∗ r12)/Sqrt(1-r12∗ r12);rY21:=(rY2-rY1∗ r12)/Sqrt(1-r12∗ r12);LRS1:=LinRegSlope(SEC1,D1)/Abs(Ref(SEC1,-D1+1))∗ 100;LRS2:=LinRegSlope(SEC2,D1)/Abs(Ref(SEC2,-D1+1))∗ 100;LRS:=LinRegSlope(C,D1)/Abs(Ref(C,-D1+1))∗ 100;DIVERG:=(rY12∗ sY/s1∗ LRS1+rY21∗ sY/s2∗ LRS2-LRS)∗ 100;Mov(DIVERG,3,E)Intermarket Multiple Regression DivergenceThe regression formula is only applicable for trading gold and the regression coefficients a and bi in the fifth line should be modified for other markets. You will need tochange the first three lines of the code to point to the appropriate folder in your harddrive where data for the XAU, silver and the dollar index are located.SEC1:=Security(“C:\Metastock Data\METAS\XAU”,C);SEC2:=Security(“C:\Metastock Data\METAS\SLV”,C);SEC3:=Security(“C:\Metastock Data\METAS\DXY0”,C);D2:=Input(“DAYS FOR ROC”,1,100,9);a:=.071;b1:=.216;b2:=.166;b3:=-.43;ROCY:=ROC(C,D2,%);ROC1:=ROC(SEC1,D2,%);ROC2:=ROC(SEC2,D2,%);ROC3:=ROC(SEC3,D2,%);PRED:=a+b1∗ ROC1+b2∗ ROC2+b3∗ ROC3;DIVERG:=(PRED-ROCY)∗ 10;Mov(DIVERG,3,E)Intermarket (Predicted) Moving AverageThe formula is only applicable for gold. The regression coefficients a and bi in thefifth line should be modified for other markets. You will need to change the first threelines of the code to point to the appropriate folder in your hard drive where data forthe XAU, silver and the dollar index are located.SEC1:=Security(“C:\Metastock Data\METAS\XAU”,C);SEC2:=Security(“C:\Metastock Data\METAS\SLV”,C);SEC3:=Security(“C:\Metastock Data\METAS\DXY0”,C);
Appendix A
301
D1:=Input(“MA DAYS”,1,1000,13);D2:=Input(“DAYS FOR ROC”,1,100,11);a:=.16;b1:=.2;b2:=.175;b3:=-.5;ROCY:=ROC(C,D2,%);ROC1:=ROC(SEC1,D2,%);ROC2:=ROC(SEC2,D2,%);ROC3:=ROC(SEC3,D2,%);PR11:=a+b1∗ ROC1+b2∗ ROC2+b3∗ ROC3;PRED:=Ref(C,-D2)∗ (1+PR11/100);Mov(PRED,D1,S)Intermarket (Predicted) Moving Average UniversalThis formula can be used for all markets by changing the appropriate intermarketsecurity in the first line.SEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D3:=Input(“MA DAYS”,1,1000,13);D1:=Input(“DAYS FOR REGRESSION”,1,2000,500);D2:=Input(“ROC DAYS”,1,100,11);RS1:=ROC(C,D2,%);RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/Stdev(RS2,D1);a:=Mov(RS1,D1,S)-b∗ Mov(RS2,D1,S);PR11:=b∗ RS2+a;PRED:=Ref(C,-D2)∗ (1+PR11/100);Mov(PRED,D3,S)Congestion IndexD1:=Input(“DAYS IN CONGESTION”,1,500,15);CI:=ROC(C,D1-1,%)/((HHV(H,D1)-LLV(L,D1))/(LLV(L,D1)+.01)+.000001);Mov(CI,3,E)
A.2 METASTOCK CODE FOR THE GOLD COMPARISON TESTSIN CHAPTER 11(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 new
302
Intermarket Trading Strategies
simulation, next, add securities, select GLD, select periodicity daily, click on next,type in initial equity 111111, select default size 90 % available equity, select bothlong trades and short trades. Click on more . . ., fill in interest rate 4 %, and fill in10 points per transaction for the commissions. Click on trade execution, uncheckrealistic market prices and select buy price and sell price at open. Then fill in 1 dayfor the delay.Gold bullion or World Gold Index data should be appended to GLD data before18 November 2004 when the GLD first started trading in the NYSE.Regression DivergenceEnter longSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=400; {REGRESSION DAYS}D2:=12; {ROC DAYS}RS1:=ROC(C,D2,%);RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/Stdev(RS2,D1);a:=mov(RS1,D1,S)-b∗ MOV(RS2,D1,S);pred:=b∗ RS2+a;DIVERG1:=(PRED-RS1);DIVERG:=Mov(DIVERG1,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(60,IM),4) ANDSTOCH(5,3)>MOV(STOCH(5,3),3,S) AND ROC(SEC2,2,%)>1Sell orderD1:=400; {REGRESSION DAYS}D2:=12; {ROC DAYS}RS1:=ROC(C,D2,%);RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/Stdev(RS2,D1);a:=mov(RS1,D1,S)-b∗ MOV(RS2,D1,S);pred:=b∗ RS2+a;DIVERG1:=(PRED-RS1);DIVERG:=Mov(DIVERG1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<0 AND STOCH(5,3)<MOV(STOCH(5,3),3,S) AND LLV(IM,4)<15AND IM>REF(IM,-1)
Appendix A
303
Sell shortSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=400; {REGRESSION DAYS}D2:=12; {ROC DAYS}RS1:=ROC(C,D2,%);RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/Stdev(RS2,D1);a:=mov(RS1,D1,S)-b∗ MOV(RS2,D1,S);pred:=b∗ RS2+a;DIVERG1:=(PRED-RS1);DIVERG:=Mov(DIVERG1,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));DIVERG<-1 AND STOCH(5,3)<MOV(STOCH(5,3),3,S)AND ALERT(CROSS(IM,8),4) AND ROC(SEC2,2,%)<0Buy to coverSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=400; {REGRESSION DAYS}D2:=12; {ROC DAYS}RS1:=ROC(C,D2,%);RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/Stdev(RS2,D1);a:=mov(RS1,D1,S)-b∗ MOV(RS2,D1,S);pred:=b∗ RS2+a;DIVERG1:=(PRED-RS1);DIVERG:=Mov(DIVERG1,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 STOCH(5,3)>MOV(STOCH(5,3),3,S)HHV(IM,4)>OPT6 AND IM<REF(IM,-1)
AND
Relative Strength (Divergence)BuySEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);RS:=MOV((C/SEC2),3,E);IM:=Mov(RS - LLV(RS,300), 3,S) /(Mov(HHV(RS,300) - LLV(RS,300),3,S))∗ 100;LLV(IM,4)<20 AND IM >REF(IM,-1) AND IM>(1+10/100)∗ LLV(IM,4)AND STOCH(5,3)>MOV(STOCH(5,3),3,S)
304
Intermarket Trading Strategies
SellSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);RS:=MOV((C/SEC2),3,E);IM:=Mov(RS - LLV(RS,300), 3,S) /(Mov(HHV(RS,300) - LLV(RS,300),3,S))∗ 100;(HHV(IM,4)>35 AND IM <REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S))ShortSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);RS:=MOV((C/SEC2),3,E);IM:=Mov(RS - LLV(RS,300), 3,S) /(Mov(HHV(RS,300) - LLV(RS,300),3,S))∗ 100;HHV(IM,4)>85 AND IM <REF(IM,-1) AND IM<(1-10/100)∗ HHV(IM,4)AND STOCH(5,3)<MOV(STOCH(5,3),3,S)CoverSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);RS:=MOV((C/SEC2),3,E);IM:=Mov(RS - LLV(RS,300), 3,S) /(Mov(HHV(RS,300) - LLV(RS,300),3,S))∗ 100;LLV(IM,4)<20 AND IM >REF(IM,-1)AND STOCH(5,3)>MOV(STOCH(5,3),3,S)
Relative StrengthBuySEC2:=Security(“C:\Metastock Data\METAS\dxy0”,C);D1:=200; {REGRESSION}D2:=15; {REF}RS:=MOV((C/SEC2),3,E);LR1:=REF(LinearReg(RS,D1+D2,E,3),-D2);ALERT(CROSS(RS,LR1),8) AND RS>(1+3/100)∗ LR1AND STOCH(5,3)>MOV(STOCH(5,3),3,S)SELLSEC2:=Security(“C:\Metastock Data\METAS\dxy0”,C);D1:=50; {REGRESSION}D2:=6; {REF}RS:=MOV((C/SEC2),3,E);
Appendix A
305
LR1:=REF(LinearReg(RS,D1+D2,E,3),-D2);ALERT(CROSS(LR1,RS),6) AND RS<(1-3/100)∗ LR1AND STOCH(5,3)<MOV(STOCH(5,3),3,S)
Disparity (XAU)BuySEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=15;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>0 AND ALERT(CROSS(80,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:=15;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<0 AND LLV(IM,4)<30 AND IM> REF(IM,-1)AND STOCH(5,3)<MOV(STOCH(5,3),3,S)ShortSEC2:=Security(“C:\Metastock Data\METAS\XAU”,C);D1:=15;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;
306
Intermarket Trading Strategies
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\XAU”,C);D1:=15;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)>60 AND STOCH(5,3)> MOV(STOCH(5,3),3,S)Disparity (DXY)BuySEC2:=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,