To any smart Metastock formula
writer:
I have asked this question before
but never got an answer. I would
like to know how to reproduce the zigzag formula. The zigzag formula is used and talked
about here but I do believe no one here knows how to reproduce it with the basic
metastock formulas. Obviosly one
can not use the peak or troughs function since this is derived from the zig zag
itself. I wanted to write the
equivalent formula using the basic MetaStock formulas. In order to reproduce the zigzag you
need to draw a linear line from point A to point B. I created a simple formula to do
this. First I needed to know the
slope of point A to point B. In my
sample formula point A is the first day of data loaded and point B is the last
day of data loaded. Slope = rise
over run. Rise is the difference
between point A and point B. The
run is the number of days over the data.
Once you have the slope you just add this each day to the previous day of
the data. The result is a nice
linear line going from point A to point B.
The problem I need to figure out is how to get point A and point B to
change according to a certain percentage like in the zig zag formula.
Sample formula for drawing a
linear line from first to last day of data.
slope:=(LastValue(C)-ValueWhen(1,Cum(1)=1,C))/LastValue(Cum(1));
line:=ValueWhen(1,Cum(1)=1,C)+Cum(slope);
line;
You might ask why write a formula
to do what the basic zig(data array, min change,diff method) all ready
does. I guess it is just
curiosity. I figure it could help
in writing other formulas.
Thanks
Steve