[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Metastockusers] How to reproduce the zig zag formula



PureBytes Links

Trading Reference Links

Steve


If you want to learn the formula language I suggest to you pick another exercise. There are 
certainly enough to choose from. I'm not one to give up easily on challenges, but ZigZag and SAR are 
two that have proved to be beyond me. Then there are others that have, shall we say, been on the 
back-burner for a long time.

Limitations with the formula language make it very difficult to string an indeterminate number of 
lines together, particularly when they are not horizontal or equal in pitch or length. When you can 
string just two lines together, such that one starts where the other finishes, you'll have a better 
appreciation of the difficulties involved.

For a competent programmer with access to the MetaStock Development Kit it's probably a breeze, but 
for us mere mortals confined to the MetaStock Formula Language I think this particular challenge 
should be left sitting out of sight in the "too hard" basket.


Kind regards

Roy Larsen
www.metastocktips.co.nz





----- Original Message ----- 
From: "Steve Grala" <stevegrala@xxxxxxxxxxx>
To: <Metastockusers@xxxxxxxxxxxxxxx>
Sent: Monday, January 24, 2005 3:30 PM
Subject: [Metastockusers] How to reproduce the zig zag formula









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








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/zMEolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/Metastockusers/

<*> To unsubscribe from this group, send an email to:
    Metastockusers-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/