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)
|
TopKat, it's best to stay away from the "P" variable when using explorations - it can be confusing if the wrong plot is selected.
To replace price by an indicator, just replace the "pr" variable in the original formula, thus:
[code:1:ef25d4fa16]
{ Complete ZigZag-based indicator set - RSI(14)}
{ 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,4);
method:=Input("Method: [1]$ points, [2]% percent",1,2,1);
Nth:=Input("Nth Peak/Trough",1,100,1);
pds:=Input("RSI periods",1,260,14);
plot:=Input("Peaks/Troughs: [1]Values, [2]Signals, [3]ZigZag",1,3,3);
{ Indicator }
pr:=RSI(pds);
{ 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))
[/code:1:ef25d4fa16]
jose '-)
|