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 #

-----Original Message-----
From: owner-metastock@xxxxxxxxxxxxx [mailto:owner-metastock@xxxxxxxxxxxxx]On
Behalf Of Kevin Johnson
Sent: Thursday, February 01, 2001 3:26 PM
To: metastock@xxxxxxxxxxxxx

I'm just learning MS's formula language. To this end I've been working on simple exercises to get my feet wet.

I'm currently attempting to write a bit of code (for a MS Expert) that as part of the Expert's criteria, requires that the ADX be rising.

I thought perhaps I could accomplish this by writing:
(in non-code language, for example's sake)

"want current ADX to be greater than the ADX 5 bars ago and ADX 5 bars ago to be greater than ADX 10 bars ago, etc."

I suppose I could do this using the "ref" function, i.e...

...and just keep stacking the prior periods (-5, -10, etc).

This would ensure that the ADX is rising, but I'm sure there is a more elegant way to pull this off, and perhaps with more control over the slope of the ADX.

Any ideas?

* To: "MetaStock Listserver" <metastock@xxxxxxxxxxxxx>
* Date: Fri, 2 Feb 2001 22:08:53 -0700
* Importance: Normal
* Sender: owner-metastock@xxxxxxxxxxxxx

As many people that there are with opinions on this, I believe that there are just as many solutions.

Here are some of my ideas:

First, your approach is correct. It will do the job that you want it to do.

I find that in learning something, it really helps me to think the problem through in a way that I wouldn't have used right away. Here's one idea: my first thought is to approach this in "clusters." By that I mean, you can take your formula below, and rather than adding a single comparison of coding for each new data point that you want to test 5 bars back, I'd make a variable out of your comparison, then test it five bars back, then make a variable out of that, and test it five bars back. This way you've at least minimized your coding.

BB:=AA>Ref(AA,-5);
CC:=BB>Ref(BB,-5);

This covers 20 bars into the past. It accomplishes the same thing, in another way, and I don't have to type ADX(14) so many times. <grin>

Now to test this to be "rising", I'm going to assume that you want each of the comparisons to be true.

You can say

If(AA=1,If(BB=1,If(CC=1,1,0)));

Or more quickly, since each will be =1 if true:

If(AA+BB+CC=3,1,0);

As you look at the ADX() function, you'll see that it's fairly smooth. Compare this with the Vertical Horizontal Filter, VHF(), which does a similar function with less smoothing.

You might consider messing around with the linear regression function or the linear regression slope especially. Set an acceptable level for LinRegSlope(), and use that as your test for an increasing ADX(). Because of the smoothness of the ADX(), the Linear Regression Line will fit the curve fairly well.

Moving averages are another way to guage trend. You can compare the ADX() with a Moving average of itself. Do consider the lag in this sort of a system, and determine if it fits with the type of trading you are doing. If a line remains above a moving average, it is trending up. You could use:

Sum(ABOVE,20)=20;

I'm using 5 periods and 20 bars for the test just as an arbitrary example.

So these are just some of many ways to approach this problem. I'm sure other listmembers will have additional ideas.

Fort Collins, CO

Source / From: TOP
http://purebytes.com/archives/metastock/

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.