Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Below is a complete ZigZag-based indicator toolkit.
Unlike the standard MetaStock version, it allows the use of points ($) in Peak/Trough functions. It has multiple output choices for ZigZag, Peak/Trough values (support & resistance), and Peak/Trough signals.
As usual, beware of the hindsight used to determine the last (dynamic) leg of the ZigZag & Peak/Trough.
MetaStock -> Tools -> Indicator Builder -> New -> Copy and paste complete formulae between "---8<---" lines.
[code:1:081a14c7f9] ================ ZigZag-based set ================ ---8<--------------------------
{ Complete ZigZag-based indicator set v1.0 } { Allows use of points in Peak/Trough functions}
{ ©Copyright 2005 Jose Silva The grant of this license is for personal use only - no resale or repackaging allowed. All code remains the property of Jose Silva. http://www.metastocktools.com }
{ User inputs } ch:=Input("Minimum reversal amount", .001,100000,.5); method:=Input("Method: [1]$ points, [2]% percent",1,2,1); x:=Input("[1]Open [2]High [3]Low [4]Close [5]WClose [6]Pvar",1,6,4); Nth:=Input("Nth Peak/Trough",1,100,1); plot:=Input("Peaks/Troughs: [1]Values, [2]Signals, [3]ZigZag",1,3,1);
{ Select price field } pr:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,WC(),If(x=6,P,C)))));
{ Zig Zag } zzPts:=Zig(pr,ch,$); zzPer:=Zig(pr,ch,%); zz:=If(method=1,zzPts,zzPer);
{ Peak/Trough values } pkPts:=Peak(Nth,zzPts,.001); pkVal:=If(method=1,pkPts,Peak(Nth,pr,ch)); trPts:=Trough(Nth,zzPts,.001); trVal:=If(method=1,trPts,Trough(Nth,pr,ch));
{ Peak/Trough signals } pkPts:=PeakBars(Nth,zzPts,.001)=0; pk:=If(method=1,pkPts,PeakBars(Nth,pr,ch)=0); trPts:=TroughBars(Nth,zzPts,.001)=0; tr:=If(method=1,trPts,TroughBars(Nth,pr,ch)=0);
{ Plot ZigZag/Peaks/Troughs on chart, Peak & Trough signals in own window } If(plot=1,pkVal,If(plot=2,pk,zz)); If(plot=1,trVal,If(plot=2,-tr,zz))
---8<--------------------------
[/code:1:081a14c7f9]
jose '-)
|