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)
|
No need for external formulae for this simple request. 8)
Try this MS indicator:
[code:1:06c76c70d6]
=============================
Peak/Trough zone-strike count
=============================
---8<--------------------------
{©Copyright 2005 Jose Silva
For private use only.
http://www.metastocktools.com }
{ User inputs }
level:=Input("Select price level: (0 = last Close)",0,100000,0);
zone:=Input("Price strike zone, +/- % of price",
.01,100,5)/100;
pr:=Input("Peak/Trough %minimum change",
.01,100,5);
plot:=Input("[1]All Pk/Tr, [2]Zone Pk/Tr, [3]Strike count, [4]%",1,4,3);
{ Peaks, values }
pk:=PeakBars(1,C,pr)=0;
pkVal:=Peak(1,C,pr);
{ Troughs, values }
tr:=TroughBars(1,C,pr)=0;
trVal:=Trough(1,C,pr);
{ Price level }
prLevel:=If(level=0,LastValue(C),level);
{ Price strike zone }
ClHi:=prLevel*(1+zone);
ClLo:=prLevel*(1-zone);
{ Peaks within price strike zone }
pkZone:=pk AND pkVal>=ClLo AND pkVal<=ClHi;
pkZonePer:=Cum(pkZone)/Max(Cum(pk),.00001)*100;
{ Troughs within price strike zone }
trZone:=tr AND trVal>=ClLo AND trVal<=ClHi;
trZonePer:=Cum(trZone)/Max(Cum(tr),.00001)*100;
{ Plot strike count in own window }
If(plot=1,pk,If(plot=2,pkZone,
If(plot=3,Cum(pkZone),pkZonePer)));
-If(plot=1,tr,If(plot=2,trZone,
If(plot=3,Cum(trZone),trZonePer)))
---8<--------------------------
[/code:1:06c76c70d6]
jose '-)
|