 MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

 A B C D E F G H I J K L M N O P R S T U V W Y Z #

Moving Average Crossovers Explorer by Dimitris Tsokakis

Dimitris Tsokakis' article in this issue, "Anticipating Moving Average Crossovers,"
introduces a new indicator and two explorations to analyze it. The formula for the indicator and the instructions for adding it to MetaStock are as follows:

1. In the Tools menu, select Indicator Builder.
2. Click New to open the Indicator Editor for a new indicator.
3. Type the name of the formula.
4. Click in the larger window and type in the formula.
5. Click OK to close the Indicator Editor.

Name: the TC graph
Formula:
y:=Input("short MA time periods", 2, 200, 20);
z:=Input("long MA time periods", 3, 200, 30);
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
test:=If(z-y=0,-9999,z-y);
tc:=If(test=-9999, 0,
(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/test);
tc;
C

This indicator will prompt for the time periods of the two moving averages, but it defaults to the values suggested in the article. The explorations and instructions for recreating them in MetaStock are as follows:

1. Select Tools > the Explorer.
2. Click New
3. Enter a name, "SMA cross stats - ascending"
4. Select the Column A tab and enter the following formula.

SMA cross stats - ascending

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
Cum(ascxpred);

5. Click in the Col Name box and enter the text: "Total."
6. Select the Column B tab and enter the following formula.

Total

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
asctotpred:=Cum(ascxpred);
acc0ascxpred:=Cum(confascx AND Ref(ascxpred,-1));
100*(acc0ascxpred/asctotpred)

7. Click in the Col Name box and enter the text: "1 day".
8. Select the Column C tab and enter the following formula.

1 day

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
asctotpred:=Cum(ascxpred);
acc1ascxpred:=Cum(confascx AND Ref(ascxpred,-2));
100*(acc1ascxpred/asctotpred)

9. Click in the Col Name box and enter the text: "2 day."
10. Select the Column D tab and enter the following formula.

2 day

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
asctotpred:=Cum(ascxpred);
acc2ascxpred:=Cum(confascx AND Ref(ascxpred,-3));
100*(acc2ascxpred/asctotpred)

11. Click in the Col Name box and enter the text: "3 day."
12. Select the Column E tab and enter the following formula.

3 day

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
asctotpred:=Cum(ascxpred);
uslsascxpre:=Cum(confascx AND ascxpred);
100*(uslsascxpre/asctotpred)

13. Click in the Col Name box and enter the text: "useless."
14. Select the Column F tab and enter the following formula.

useless

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
ascxpred:=Cross(C,tc);
confascx:=Cross(may,maz);
asctotpred:=Cum(ascxpred);
acc0ascxpred:=Cum(confascx AND Ref(ascxpred,-1));
acc1ascxpred:=Cum(confascx AND Ref(ascxpred,-2));
acc2ascxpred:=Cum(confascx AND Ref(ascxpred,-3));
uslsascxpre:=Cum(confascx AND ascxpred);
100-(100*(acc0ascxpred+acc1ascxpred+acc2ascxpred+uslsascxpre)/asctotpred)

15. Click in theFilter box and enter the text: "false"
16. Click OK to close the exploration editor.

I also suggest that before closing the editor, adding the following text to the Notes field to provide a more detailed description of the column names:

Columns descriptions:
1: total ascending predictions
2: percent confirmed 1 day later
3: percent confirmed 2 days later
4: percent confirmed 3 days later
5: percent useless (confirmed same day as prediction)
6: percent of false predictions

The second exploration is added in the same manner, but the formulas and notes are different. The column names are the same. The steps to create it are:

1. Select Tools > the Explorer.
2. Click New
3. Enter a name, "SMA cross stats - descending"
4. Select the Column A tab and enter the following formula.

SMA cross stats - descending

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
Cum(decxpred);

5. Click in the Col Name box and enter the text: "Total".
6. Select the Column B tab and enter the following formula.

Total

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
destotpred:=Cum(decxpred);
acc0desxpred:=Cum(confdecx AND Ref(decxpred,-1));
100*(acc0desxpred/destotpred)

7. Click in the Col Name box and enter the text: "1 day".
8. Select the Column C tab and enter the following formula.

1 day

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
destotpred:=Cum(decxpred);
acc1desxpred:=Cum(confdecx AND Ref(decxpred,-2));
100*(acc1desxpred/destotpred)

9. Click in the Col Name box and enter the text: "2 day".
10. Select the Column D tab and enter the following formula.

2 day

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
destotpred:=Cum(decxpred);
acc2desxpred:=Cum(confdecx AND Ref(decxpred,-3));
100*(acc2desxpred/destotpred)

11. Click in the Col Name box and enter the text: "3 day".
12. Select the Column E tab and enter the following formula.

3 day

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
destotpred:=Cum(decxpred);
uslsdesxpred:=Cum(confdecx AND decxpred);
100*(uslsdesxpred/destotpred)

13. Click in the Col Name box and enter the text: "useless".
14. Select the Column F tab and enter the following formula.

Useless

y:=20;
z:=30;
may:=Mov(C,y,S);
maz:=Mov(C,z,S);
tc:=(y*(z-1)*Mov(C,z-1,S)-z*(y-1)*Mov(C,y-1,S))/(z-y);
decxpred:=Cross(tc,C);
confdecx:=Cross(maz,may);
destotpred:=Cum(decxpred);
acc0desxpred:=Cum(confdecx AND Ref(decxpred,-1));
acc1desxpred:=Cum(confdecx AND Ref(decxpred,-2));
acc2desxpred:=Cum(confdecx AND Ref(decxpred,-3));
uslsdesxpre:=Cum(confdecx AND decxpred);
100-(100*(acc0desxpred+acc1desxpred+acc2desxpred+uslsdesxpre)/destotpred)

15. Click in the Col Name box and enter the text: "false"
16. Click OK to close the exploration editor.

The recommended notes for this exploration are:

Columns descriptions:
1: total descending predictions
2: percent confirmed 1 day later
3: percent confirmed 2 days later
4: percent confirmed 3 days later
5: percent useless (confirmed same day as prediction)
6: percent of false predictions

It should also be noted that MetaStock version 10 users can put all 12 columns -- both explorations -- into a single exploration. It would only require changing the column names a bit in order to easily tell which ones are for the ascending crosses and which ones are for the descending crosses. The second exploration would then have its formulas put in columns G through L.

--William Golson
MetaStock Support Representative
Equis International (A Reuters Company)
801 265-9998, www.metastock.com

Source / From: TOP