From: owner-metastock@xxxxxxxxxxxxx [mailto:owner-metastock@xxxxxxxxxxxxx]On
Behalf Of Kevin Johnson
Sent: Thursday, February 01, 2001 3:26 PM
Subject: ADX rising...
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...
adx(14)>ref (adx(14), -5)
...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.
RE: ADX rising...
* To: "MetaStock Listserver" <metastock@xxxxxxxxxxxxx>
* Subject: RE: ADX rising...
* From: "Dave Nadeau" <dave_nadeau@xxxxxxxxx>
* Date: Fri, 2 Feb 2001 22:08:53 -0700
* Importance: Normal
* Reply-To: metastock@xxxxxxxxxxxxx
* 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.
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
Or more quickly, since each will be =1 if true:
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: