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
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
Would PeakBars() and TroughBars() work?
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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]
|
|
|
|
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
|
|
|
|
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]
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
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)
|
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.