trading with MetaStock and get an accurate result butthere are two ways that you can get around it.The first one is to select a points-only simulation and convert the profit/loss foreach transaction manually to your base currency according to the formula:Profit/loss=((Sell price−Buy price)−(min move*spread pips))*units/home currency.
Appendix A
353
In the yen test with USD as the home currency this reduces to:Profit/loss=((Sell price−Buy price)−(0.01*1.5))*100000/Sell price.You’ll then have to calculate the test statistics manually.A quicker way is to select transaction cost=$100 000 and exit commission=$13(100 000 ∗ 0.015/average yen price during the test duration).In this case you will get a good enough approximation of the actual test statistics.I used the second method with the following code.You will need also to change the first line of the code to point to the appropriatefolder in your hard drive where the S&P 500 (SPX), 10-year Treasury yield (TNX)and dollar index (DXY) are located.LongSEC1:=Security(“C:\Metastock Data\REUTERSINDEX\.SPX”,C);SEC3:=Security(“C:\Metastock Data\REUTERSINDEX\.TNX”,C);SEC2:=Security(“C:\Metastock Data\REUTERSINDEX\.DXY”,C);D1:=200; {REGERSSION DAYS} D2:=15; {ROC DAYS}RS1:=ROC(C,D2,%);RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/(Stdev(RS2,D1)+.001);a:=mov(RS1,D1,S)-b∗ MOV(RS2,D1,S);pred:=b∗ RS2+a;DIVERG:=(PRED-RS1); DIVERG:=Mov(DIVERG,3,E);IM:=(Mov(DIVERG - LLV(DIVERG,200), 3,S) ∗ 100)/(Mov(HHV(DIVERG,200) - LLV(DIVERG,200), 3,S));SDC:=Stdev(C,15)/Mov(C,15,S);SDADX:=SDC∗ ADX(15);DISY:=(C-Mov(C,OPT1,E))/Mov(C,OPT1,E)∗ 100;DIS3:=(SEC3-Mov(SEC3,OPT1,E))/Mov(SEC3,OPT1,E)∗ 100;DIS:=MOV((DIS3-DISY),3,E);HHV(IM,4)>65 AND IM<HHV(IM,4)-10 ANDREF(MOV(C,2,S),-1)>REF(MOV(C,15,S),-1) AND MOV(C,2,S)>MOV(C,15,S) AND (DIS>0 OR roc(sec1,1,%)>1.2)SellSEC3:=Security(“C:\Metastock Data\REUTERSINDEX\.TNX”,C);SEC2:=Security(“C:\Metastock Data\REUTERSINDEX\.DXY”,C);D1:=200; {REGRESSION DAYS} D2:=15; {ROC DAYS}RS1:=ROC(C,D2,%); RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/(Stdev(RS2,D1)+.001);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));
354
Intermarket Trading Strategies
DISY:=(C-Mov(C,OPT1,E))/Mov(C,OPT1,E)∗ 100;DIS3:=(SEC3-Mov(SEC3,OPT1,E))/Mov(SEC3,OPT1,E)∗ 100;DIS:=MOV((DIS3-DISY),3,E);(LLV(IM,4)<30 and IM >LLV(IM,4) AND MACD()<MOV(MACD(),9,E))OR (ALERT(CROSS(80,STOCH(20,3)),3) AND STOCH(20,3)<78 ANDSTOCH(20,3)<mov(STOCH(20,3),4,S)ANDLLV(DIS,2)<0ANDDIS>REF(DIS,-1))Sell shortSEC3:=Security(“C:\Metastock Data\REUTERSINDEX\.TNX”,C);SEC2:=Security(“C:\Metastock Data\REUTERSINDEX\.DXY”,C);D1:=200; {REGERSSION DAYS}D2:=15; {ROC DAYS}RS1:=ROC(C,D2,%); RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/(Stdev(RS2,D1)+.001);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));SDC:=Stdev(C,15)/Mov(C,15,S);SDADX:=SDC∗ ADX(15);DISY:=(C-Mov(C,OPT1,E))/Mov(C,OPT1,E)∗ 100;DIS3:=(SEC3-Mov(SEC3,OPT1,E))/Mov(SEC3,OPT1,E)∗ 100;DIS:=MOV((DIS3-DISY),3,E);(LLV(IM,4)<30 and IM >LLV(IM,4)+10 ANDREF(MOV(C,2,S),-1)<REF(MOV(C,15,S),-1) AND MOV(C,2,S)<MOV(C,15,S))Buy to coverSEC3:=Security(“C:\Metastock Data\REUTERSINDEX\.TNX”,C);SEC2:=Security(“C:\Metastock Data\REUTERSINDEX\.DXY”,C);D1:=200; {REGERSSION DAYS} D2:=15; {ROC DAYS}RS1:=ROC(C,D2,%); RS2:=ROC(SEC2,D2,%);b:=Correl(RS1,RS2,D1,0)∗ Stdev(RS1,D1)/(Stdev(RS2,D1)+.001);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));DISY:=(C-Mov(C,OPT1,E))/Mov(C,OPT1,E)∗ 100;DIS3:=(SEC3-Mov(SEC3,OPT1,E))/Mov(SEC3,OPT1,E)∗ 100;DIS:=MOV((DIS3-DISY),3,E);(HHV(IM,4)>65 AND IM<HHV(IM,4) AND MACD()>MOV(MACD(),9,E))
Appendix A
355
OR (ALERT(CROSS(STOCH(20,3),20),3) AND STOCH(20,3)>22 ANDSTOCH(20,3)>mov(STOCH(20,3),4,S) and HHV(DIS,2)>0 ANDDIS<REF(DIS,-1))
Euro (EURO/USD) Daily MA-intermarket System(Copyright Markos Katsanos 2008)In this case select no. of units=100 000 and exit commission=10 (1 pip).You will need also to change the first line of the code to point to the appropriatefolder in your hard drive where the CRB Index and the 10-year Treasury yield (TNX)data are located.LongSEC1:=Security(“C:\Metastock Data\REUTERSINDEX\.CRB”,C);SEC3:=Security(“C:\Metastock Data\REUTERSINDEX\.TNX”,C);PC:=Log(MOV(C,10,S)/Ref(MOV(C,10,S),-1));FILT:=Stdev(PC,20);CI:=ROC(C,40-1,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);CI:=Mov(CI,7,E);MOV(C,10,S)>LLV(MOV(C,10,S),3)+.7∗ FILT AND C>SAR(.04,.1) ANDSEC1>MOV(SEC1,35,S) AND SEC3<MOV(SEC3,5,S) AND ABS(CI)>40AND CI>LLV(CI,3)+3SellC<SAR(.04,.1)Sell shortSEC1:=Security(“C:\Metastock Data\REUTERSINDEX\.CRB”,C);SEC3:=Security(“C:\Metastock Data\REUTERSINDEX\.TNX”,C);PC:=Log(MOV(C,10,S)/Ref(MOV(C,10,S),-1));FILT:=Stdev(PC,20);CI:=ROC(C,40-1,%)/((HHV(H,40)-LLV(L,40))/(LLV(L,40)+.01)+.000001);CI:=Mov(CI,7,E);MOV(C,10,S)<HHV(MOV(C,10,S),3)-.7∗ FILT AND C<SAR(.04,.1) AND(SEC1<MOV(SEC1,35,S) AND SEC3>MOV(SEC3,5,S)) AND ABS(CI)>40AND CI<HHV(CI,3)-3Buy to coverC>SAR(.04,.1)
Appendix BNeural Network Systems
There are two primary ways we make money trading; catching a big price movewith a small position or having a large position and catching a small move.–Bill MeehanThe following is a detailed procedure for recreating the neural network systemsdescribed in Chapter 14, using NeuroShell Trader.
B.1
ROC
All neural network systems were developed using Ward’s NeuroShell Day TraderProfessional v. 5.4 (www.neuroshell.com).To recreate this test open the FTSE chart and load data from 27 April 1993 to 27February 2008. Then load data for the French CAC 40, the Amex Oil Index (XOI)and the S&P Bank Index (BIX).Next, from the Insert menu select New prediction and add the following inputsthat the neural network is going to use for the prediction. Press Add Input/Indicatorand select Change/Percent Change (%) from the change category.To modify the input’s default parameters click on the small “+” beside the input.This will cause it to expand to show the parameters and range of variables that aregoing to be tested. In this case modify the Time Series to CAC 40 Close and thePeriods search space from 1 to 10 and click on Finish.Repeat the above procedure for the XOI and the BIX. You should now have thefollowing inputs for each intermarket security.%Change(Time Series,Periods)(Time Series, Periods)Time Series Search Space = CAC 40 INDEX ClosePeriods Search Space = 1 to 10
358
Intermarket Trading Strategies
%Change(Time Series,Periods)(Time Series, Periods)Time Series Search Space = S&P BANK INDEX ClosePeriods Search Space = 1 to 10%Change(Time Series,Periods)(Time Series, Periods)Time Series Search Space = AMEX Oil Index ClosePeriods Search Space = 1 to 10The next step is to modify the default parameters that the prediction will use whentraining. Among other things, parameters are used to determine the number andtype of walk-forward tests, as well as the training set size and the training objective(training by profit or error).To modify the parameters press next/Modify Prediction Parameters and press thefirst from the left (output) tab. On the top of the dialog box a list lets you select the“Indicator whose future value is to be predicted for each index in the current chart”.Select the “Optimal percent change in open” option from the dropdown list and fillin 20 trading days to the “How far into the future this indicator should be predicted”question at the bottom of the dialog box.Next select the input tab and choose the Full optimization option.The next (date) tab allows you to set the samples and dates for training andoptimization, testing the optimized parameters or, as NeuroShell calls it, “papertrading” and out-of-sample testing.To use all three samples you should first check the “save optimization whichperforms best on later paper trading” and “Start before last chart date” boxes. Thenfill in the dates for the Optimization sample (in grey) from 4/27/1993 to 1/1/2003, forthe Paper Trading sample (in orange) from 1/1/2003 to 1/1/2005 and for the Tradingsample (green) from 1/1/2005 to the last chart date.The next tabs (shares and costs) allow you to set the number of shares, commissionsand margins.Select “Buy a Fixed Number of 1 Contract” and fill in the entry and exit commissionof 1.7 per trade, the margin to £3000 per contract and the point value to £10 per FTSEpoint.Next press the positions tab and select “Both long and short” and “Find the optimaltrading rules”.The next (training) tab allows you to optimize against return on account, net profit,minimum drawdown, return on trades, error, etc.Choose “Maximize Return on Trades” from the drop down list. At the bottomof the dialog box you can also specify the maximum hidden neurons used by thetraining process. I have limited the maximum number of hidden neurons to seven.Then select the last (Optimization) tab and fill in seven bars for the shortest averagetrade span. The number of inputs should be left unchanged to the default value of10. The progress of the training and optimization process is displayed as you go alongand lets you know the approximate amount of time remaining until completion. Thisprogress is continually updated, and because of the way genetic algorithms evolve, a
Appendix B
359
remaining time of 15 minutes could change and take longer if the genetic algorithmsuddenly finds a better solution and decides to continue on the new path. You canretrain the neural network at any time if you are not satisfied with the results but youshould first save the chart with the final system before proceeding to the next test.Please note that it is very unlikely that you will get exactly the same results withthe ones presented in the book as I had to retrain the neural network a number oftimes before obtaining a satisfactory output.B.2
ROC (RELATIVE)
The test procedure is similar to the one described above. The only difference is inthe Inputs parameters. In this test I used the intermarket minus the FTSE percentagechange instead of just the intermarket security percentage change. The difference wasthen smoothed by a moving average.To recreate this test, choose “Edit/Modify Prediction Selection” from the pop-upmenu. Then remove all inputs from the previous (ROC) test and insert the new onesas follows:• Press Add Input/Indicator and select Indicator/Averages/Simple Moving Average.• Change the time periods to Arithmetic/subtract.• Set the parameters for Operand #1 by selecting from the Indicator listChange/Percent Change(%).• To modify the input’s default parameters press modify input and modify the TimeSeries to CAC40 Close.• Modify the No. of Periods to search space 1 to 10.• Click on Finish.• Repeat the same procedure for Operand #2, this time leaving the default parameters(Time series=close, periods 1 to 10).Repeat the above procedure for the XOI and the BIX. You should now have threeinputs, one for each intermarket security.Then click on the Modify Prediction Parameters tab and change the output tab the“How far into the future this indicator should be predicted” from 20 to 15 tradingdays.You are now ready to start the training process.If you are satisfied with the results, and before proceeding with the next test, youshould first save this chart with a different name.B.3
DISPARITY
The test procedure is similar to the ones described above. The only difference is inthe input parameters. In this test I used the disparity indicator instead of percentagechange.
360
Intermarket Trading Strategies
You will need first to create the disparity indicator as follows:• Select “New Indicator” from the Insert menu.• Using the Indicator Wizard, select “Arithmetic/Divide” from the indicator list. Theformula for the Numerator should be:Mul2(Sub(close,Avg(close,10)),100)and for the denominator:Avg(Close,10).• After, inserting both formulas, click Finish and name the new indicator “Disparity”and save it in the custom indicator list.• Choose Edit/modify Prediction Selection from the pop-up menu, remove all inputsfrom the first (ROC) test and insert the new ones as follows.• Press Add Input/Indicator and select Subtract from the Arithmetic indicator category.• Set the parameters for both Operands by selecting from the custom Indicatorcategory the disparity indicator.• To modify the indicator default parameters, press Modify Input and modify theTime Series to CAC40 Close and the search space from 2 to 30 for the first Operandof the subtraction only. You should modify the search space of the second Operandfrom 2 to 30 but leave the time series to the default (FTSE) close.• Repeat the above procedure for the XOI and the BIX. You should now have threeinputs, one for each intermarket security.• Click on the Modify Prediction Parameters tab and in the output field change the“How far into the future this indicator should be predicted” from 20 to 15 tradingdays.You are now ready to start the training process. The training and optimization processshould take a little more time than the first two systems as there are more parametersto optimize.• If you are satisfied with the results, and before proceeding with another test youshould first save this chart with a different name.• If you have any problems you can always phone or email NeuroShell technicalsupport at support@wardsystems.com. The quality of their technical support isvery high and the replies are prompt and to the point.B.4
COMBINED TRADING STRATEGY
To recreate this strategy select New Trading Strategy from the Insert menu and enterthe following entry and exit conditions in the appropriate locations of the Trading
Appendix B
361
Strategy Wizard:• Press on Add Condition\Indicator and from the menu select Relational A>B(A>B).• Then press Next and Finish.• Press Add Condition and click on the small + sign next to ROC Optimal % Changein Open as predicted 20 bars ago. This will cause it to expand to show more choices.• From these choices select Pred >Long Entry Threshold: Predicted 20 bar Optimal% Change in Open.• Repeat the same procedure to add the prediction signals for the ROC relative anddisparity conditions and then click Finish.• Modify the B search space as follows:Long EntryA>B(A,B)A Search Space= Prediction Signal: 20 bar Optimal % Change in OpenB Search Space= 0 to 0.5A>B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % ChangeB Search Space= 0 to 0.5A>B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % Change #2B Search Space= 0 to 1Finally select “Generate a buy long MARKET order if all of the following are true”Repeat the same procedure to enter the rest of the conditions.For the Short Entry and Long Exit conditions you should reverse the inequality fromA>B to A<B and choose the appropriate Thresholds from the Predicted outputs.You should now have the following conditions and associated threshold SearchSpaces:Long ExitA<B(A,B)A Search Space= Prediction Signal: 20 bar Optimal % Change in OpenB Search Space= −0.5 to 0A<B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % ChangeB Search Space= −0.5 to 0
362
Intermarket Trading Strategies
A<B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % Change #2B Search Space= −1 to 0Short EntryA<B(A,B)A Search Space= Prediction Signal: 20 bar Optimal % Change in OpenB Search Space= −1 to 0A<B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % ChangeB Search Space= −1 to 0A<B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % Change #2B Search Space= −1 to 0Short ExitA>B(A,B)A Search Space= Prediction Signal: 20 bar Optimal % Change in OpenB Search Space= 0 to 0.5A>B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % ChangeB Search Space= 0 to 0.5A>B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % Change #2B Search Space= 0 to 1The next step is to modify the default Trading Strategy Parameters used for theoptimization process.• To modify the parameters press next/Modify Prediction Parameters.• Press the first from the left (Rules) tab• Select Full Optimization from the bottom of the dialog box.• Select the Trading tab and check the “Long/Short entries exit existing short/longpositions” and “Match date ranges to the out of sample data ranges of predictionsused in the trading strategy” boxes.• The next tabs (costs) allow you to set the number of shares, commissions andmargins.
Appendix B
363
• Fill in the entry and exit commissions of 1.7 per trade, the margin to £3000 percontract and the point value to £10 per FTSE point.• The next (Optimization) tab allows you to optimize against return on account, netprofit, minimum drawdown, return on trades, error, etc.• Choose “Maximize Return on Trades” from the drop down list.After backtesting the trading strategy, use the “Detailed Analysis . . .” button to viewthe results for the combined system.
B.5
HYBRID STRATEGY
The test procedure is similar to the Combined Strategy described above. The onlydifference is the addition of the Stochastic Crossover and Moving Average Conditions.To recreate this strategy, copy the Combined Strategy and paste it in the same chart.Then change the name to Hybrid and add the additional conditions to the appropriatelocations after the prediction signal conditions. You should now have the followingentry and exit conditions:
Long Entry: Generate a buy long MARKET order if 3 of the following are trueA>B(A,B)A Search Space= Prediction Signal: 20 bar Optimal % Change in OpenB Search Space= 0 to 0.5A>B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % ChangeB Search Space= 0 to 0.5A>B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % Change #2B Search Space= 0 to 1A>B(A,ExpAvg(TimeSeries, ExpAvgPeriods))A Search Space=CloseTime Series Search Space=CloseSearch Space=CloseExpAvg Search Space= 5 to 15CrossAbove(%KAvg(High Price,Low Price,Closing Price,Stochastic Periods,AvgPeriods),Time Series #2)High Price Search Space=High
364
Intermarket Trading Strategies
Low Price Search Space=LowClosing Price Search Space=CloseStochastic Periods Search Space= 5 to 20Avg Periods Search Space=3 to 3Time Series #2 Search Space= 20 to 40Long Exit: Generate a sell long MARKET order if 2 of the following are true:A<B(A,B)A Search Space= Prediction Signal: 20 bar Optimal % Change in OpenB Search Space= −0.5 to 0A<B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % ChangeB Search Space= −0.5 to 0A<B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % Change #2B Search Space= −1 to 0CrossBelow(%KAvg(High Price,Low Price,Closing Price,Stochastic Periods,AvgPeriods),Time Series #2)High Price Search Space=HighLow Price Search Space=LowClosing Price Search Space=CloseStochastic Periods Search Space=5 to 20Avg Periods Search Space=3 to 3Time Series #2 Search Space= 70 to 90CrossBelow (Time Series #1,ExpAvg(TimeSeries, ExpAvgPeriods))Time Series #1 Search Space=CloseTime Series Search Space=CloseExpAvg Search Space= 5 to 15Short Entry: Generate a sell short MARKET order if 3 of the following are trueA<B(A,B)A Search Space= Prediction Signal: 20 bar Optimal % Change in OpenB Search Space= −1 to 0A<B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % ChangeB Search Space= −1 to 0
Appendix B
365
A<B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % Change #2B Search Space= −1 to 0A<B(A,ExpAvg(TimeSeries, ExpAvgPeriods))A Search Space=CloseTime Series Search Space=CloseSearch Space=CloseExpAvg Search Space= 5 to 15Short Exit: Generate a cover short MARKET order if 2 of the following are true:A>B(A,B)A Search Space= Prediction Signal: 20 bar Optimal % Change in OpenB Search Space= 0 to 0.5A>B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % ChangeB Search Space= 0 to 0.5A>B(A,B)A Search Space= Prediction Signal: 15 bar Optimal % Change #2B Search Space= 0 to 1A>B(A,ExpAvg(TimeSeries, ExpAvgPeriods))A Search Space=CloseTime Series Search Space=CloseSearch Space=CloseExpAvg Search Space= 5 to 15The only trading parameter that you will need to modify is the Rules tab where youshould select “parameters search “ instead of full optimization.
Appendix CRectangles
To measure is to know. If you can not measure it, you can not improve it.–Lord KelvinThis has nothing to do with intermarket trading but I decided to include it here becausesince the publication of my article on rectangles in the June 2007 issue of TechnicalAnalysis of STOCKS & COMMODITIES, I have received numerous emails frommagazine readers asking for the MetaStock code of a rectangle pattern recognitionsystem, obviously wanting to cash in on the article concepts.I always wanted my articles to be of some practical use to trading professionalsand active investors and the emails were all the motivation I needed to develop theMetaStock exploration which follows. But first, for the benefit of readers who havenot read the article, I thought it would be useful to include the following informationon rectangles.Rectangles consist of a sideways price action or congestion area bounded by twohorizontal or nearly horizontal parallel trendlines at top and bottom. At least twopoints are required to define each line but three points are more common. Rectanglescan be either continuation or reversal patterns depending on the direction of thebreakout in relation to the price trend before entering the formation. As reversals,rectangles appear more commonly at bottoms.In the article, I presented some useful rectangle statistics and also a statisticallyderived formula to estimate the breakout price target objective. I used the statistics in the article to come up with the following code for a MetaStock explorationthat will detect rectangles of up to two peaks and troughs. On trying to extendthe code to include more than two peaks or troughs I came up with all sorts ofproblems as the MetaStock formula language is not the best for pattern recognitionsystems. Nevertheless, even with only two peaks, the system produced outstandingresults.
368
C.1
Intermarket Trading Strategies
RECTANGLE EXPLORATION
MetaStock CodeCol B: TargetA1:=5;PK1:=Peak(1,H,A1);PK2:=Peak(2,H,A1);TR1:=Trough(1,L,A1);TR2:=Trough(2,L,A1);H1:=Max(PK1,PK2);L1:=Min(TR1,TR2);RH:=H1-L1;H1+2.3* Power(RH,.8)Col C: StopLossA1:=5;PK1:=Peak(1,H,A1);PK2:=Peak(2,H,A1);H1:=Max(PK1,PK2);H1* .98Col D: ProfStopA1:=5;PK1:=Peak(1,H,A1);PK2:=Peak(2,H,A1)H1:=Max(PK1,PK2);1.55* H1Filter(Copyright Markos Katsanos 2007)D1:=180;A1:=5;PK1:=Peak(1,H,A1);PK2:=Peak(2,H,A1);TR1:=Trough(1,L,A1);TR2:=Trough(2,L,A1);H1:=Max(PK1,PK2);L1:=Min(TR1,TR2);H2:=.98* H1;CI:=((HHV(C,140)-LLV(C,140))/LLV(C,140))* 100; {CONGESTION INDEX}P12:=PK1>.97* PK2 AND PK1<1.03* PK2 AND PeakBars(2,H,A1)<D1;T12:=TR1>.97* TR2 AND TR1<1.03* TR2 AND TroughBars(2,L,A1)<D1;Fml(“FVE”)>8 AND LinRegSlope(Fml(“FVE”),22)>.5 ANDRef(LinRegSlope(C,100)/Ref(C,-99),-2)* 100<.12 ANDRef(LinRegSlope(C,100)/Ref(C,-99),-2)* 100>-.09 AND Cross(C,H1) ANDV>Ref(M