logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Flexi  
#1 Posted : Monday, January 31, 2011 9:53:31 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

How to count the number of peak or trough for a specific period? ibm has three peaks and two troughs for the previous 25 bars
johnl  
#2 Posted : Monday, January 31, 2011 6:42:30 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

Would PeakBars() and TroughBars() work?
Flexi  
#3 Posted : Tuesday, February 1, 2011 1:16:23 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

no not the peakbar or troughbar but counting the number of pivots make using the zigzag for the previous 25 bars
Flexi  
#4 Posted : Tuesday, February 1, 2011 1:19:25 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

NOT number of bars from one peak to another peak

there may be 6 bars from one peak to another but there are just two peak/pivot
wabbit  
#5 Posted : Tuesday, February 1, 2011 1:29:15 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
First off, you have to define what a peak and trough is. We can use the Zig() function only if we understand its limitations, and hence we can also use some forward referencing too (it makes things a little nicer).

After defining the events, its a simple matter to count them;

Code:

lookback:=25;
zz:=Zig(C,5,%);

ch:=ROC(zz,1,$);

pk:=ch>0 AND Ref(ch<0,+1);
tr:=ch<0 AND Ref(ch>0,+1);

{plot}
sum(pk,lookback);
-sum(tr,lookback);



wabbit [:D]

Flexi  
#6 Posted : Tuesday, February 1, 2011 2:04:24 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

hi wabbit how to determine if the most recent VALID zizag pivot is a peak or trough? Because u know that zigzag is dynamic. Wanted to get the indicator to plot 1 for most recent valid zigzag pivot is peak and -1 for most recent valid zigzag pivot is trough. Managed to define the pivot but how to differentiate whether the the most recent data has valid peak or trough
wabbit  
#7 Posted : Tuesday, February 1, 2011 2:43:34 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
There has been a lot already written on the forum, including all the code you need to determine the validity of the Zig(). Search for work by Spyros Raftopoulos.


wabbit [:D]

Flexi  
#8 Posted : Tuesday, February 1, 2011 11:16:56 AM(UTC)
Flexi

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/27/2006(UTC)
Posts: 135

Hi Wabbit,

Know the code for zigzag validity but wanted to determine the most recent zigzag pivot is a peak or trough

The zigzag validity code does not differentiate whether the most recent zigzag pivot is peak or trough
johnl  
#9 Posted : Tuesday, February 1, 2011 9:24:50 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

How about something like:

a1:=(C<Ref(C,-2))*(Ref(C,-2)>Ref(C,-4));
{----------------------------------}
count:=Cum(1);
reset:=a1;
counter:=count - ValueWhen(1,reset,count);
{----------------------------------}
b1:=(counter=0)*(Ref(counter,-1)>0);
b2:=Sum(b1,25);
b2

PS(I didn't test it)
ecureuil  
#10 Posted : Wednesday, February 2, 2011 5:13:27 PM(UTC)
ecureuil

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 2/2/2011(UTC)
Posts: 7

Hello,

I find this indicator: { Signal/Value accumulator v2.0
Accumulates & resets values between signals.
http://www.metastocktools.com }

{ Start count signal }
start:=TroughBars(1,C,5)=0;

{ End count signal }
end:=PeakBars(1,C,5)=0;

{ Value to accumulate - Volume }
value:=V;

{ Indicator output choice }
plot:=Input("plot: [1]Accumulation, [2]Signals",1,2,1);

{ Remove redundant interim start/end signals }
init:=Cum(IsDefined(start+end))=1;
flag:=ValueWhen(1,start-end<>0 OR init,start);
start:=flag*(Alert(flag=0,2)
OR start*Cum(start)=1);
end:=(flag=0)*(Alert(flag,2)
OR end*Cum(end)=1);

{ Accumulate values }
acc:=Cum(flag*value);
accVal:=acc-ValueWhen(1,end,acc);

{ Plot in own window }
If(plot=1,accVal,start-end)

Inside we have peak function. That mean the indicator can change is sinal next day ?

Ecureuil
Users browsing this topic
Guest (Hidden)
Similar Topics
Last value compare to Peak and Trough (Formula Assistance)
by empu 5/3/2013 7:41:42 PM(UTC)
Peak and trough alternative (Formula Assistance)
by Johandk 9/3/2010 6:54:29 AM(UTC)
Peak and Trough Formula (Formula Assistance)
by dklugmann 10/11/2005 2:19:13 PM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.