[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with pattern detection code?



PureBytes Links

Trading Reference Links

Eugene,
It is not sure that there will be a "previous peak that is higher 
than it".
If the last peak is the highest since, say, 6 months or 1 year, what 
is the meaning of a trendline linking the last peak with another 15 
months ago.
If you except this term, things are "normal".
Here is the trendline linking the last two "peaks".

X=Cum(1);
condP=Ref(H,-1)>Ref(H,-2) AND Ref(H,-1)>H AND Ref(H,-1)>Ref(C,-2);
P=Ref(CONDP,1)*(X!=LastValue(X));
Plot(C,"",4*P+1,64);
endt= LastValue(ValueWhen( P, x, 1 ));
startt=LastValue(ValueWhen( P, x, 2 ));dtS =endt-startt;
endS = LastValue(ValueWhen( P, H, 1 ) );
startS = LastValue( ValueWhen( P, H, 2 ));
aS = (endS-startS)/dtS;bS = endS;
tH = aS * ( x -endt ) + bS; 
tH1=IIf(X>STARTT-3,tH,-1E10);
Plot(tH1,"",5,1);

For easier reference I painted the peak candles.
If you dont need it replace the Plot(C,"",4*P+1,64); with the Plot
(C,"",1,64);
DT
--- In amibroker@xxxx, "Eugene" <johngalt1234@xxxx> wrote:
> A peak is determined by me to have the following Characteristics
> ref(h,-2) < ref(h,-1) and h<ref(h,-1) and ref(h,-1)>ref(close,-3)
> 
> A trough is determined to be as follows
> 
> ref(l,-2) > ref(l,-1) and L>ref(L,-1) and ref(l,-1)<ref(close,-3)
> 
> 
> if 4 peak and 4 troughs are calculated, I want a trendline between 
the
> nearest peak to the previous peak that is higher than it
> 
> If you look at an SPY chart
> 
> the peaks are 09/11/2002 and 09/17/2002 and on 08/27/02 and 8/30/02
> 
> the troughs are 09/24/02 and 7/24/02 and 09/13/02 and 09/05
> 
> the peaks of 09/11 and 09/17 need to be connected and also that of
> 08/30 and 09/11
> 
> 
> the trough of 09/24 and 7/24 need to be connected. the trough of 
09/05
> and 09/13 needs to be connected.