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

Re: Peaks and Troughs detection



PureBytes Links

Trading Reference Links

And here is the full formula for any use [AA explore mode and 
indicator builder]

perc=5;//Calibrate sensitivity
//Last Peak detection
p1=PeakBars(H,perc,1)==0;
H1=ValueWhen(p1,H,1);p2=H1>LastValue(C);
p=p1 AND p2;x1=Cum(p);x1max=LastValue(x1);
//Last Trough Detection
t1=TroughBars(L,perc,1)==0;
L1=ValueWhen(t1,L,1);t2=L1<LastValue(C);
t=t1 AND t2;y1=Cum(t);y1max=LastValue(y1);
PeakA=p AND x1==x1max;
TroughA=t AND y1==y1max;
Filter= PeakA OR TroughA;
AddColumn(IIf(PeakA,H,0),"Last Peak",1.2);
AddColumn(IIf(TroughA,L,0),"Last Trough",1.2);
Sell=p AND x1==x1max;
Buy=t AND y1==y1max;
LastPt=ValueWhen(PeakA,Cum(1),1);
LastPeak=ValueWhen(PeakA,H,1);
LastTt=ValueWhen(TroughA,Cum(1),1);
LastTrough=ValueWhen(TroughA,L,1);
Plot(C,"",1,64);
Plot(IIf(Cum(1)>=LastPt,LastPeak,-1e10),"",4,1);
Plot(IIf(Cum(1)>=LastTt,LastTrough,-1e10),"",5,1);
Plot(IIf(Cum(1)>=Max(LastPt,LastTt),LastValue(C),-1e10),"",7,1);

I do not think I have something more to add.
DT
--- In amibroker@xxxx, "dtsokakis" <TSOKAKIS@xxxx> wrote:
> Franco,
> If the previous code was confusing you, try this one.
> In AA select a stock and EXPLORE for all quotations.
> Then double click on the results list.
> You read the values of the last Peak [Last trough] above [below] 
last 
> close value [I forced the useless reading to zero] and the arrows 
> mark the respective points.
> If you need anything else, please advise.
> DT
> 
> perc=5;//Calibrate sensitivity
> //Last Peak detection
> p1=PeakBars(H,perc,1)==0;
> H1=ValueWhen(p1,H,1);p2=H1>LastValue(C);
> p=p1 AND p2;x1=Cum(p);x1max=LastValue(x1);
> //Last Trough Detection
> t1=TroughBars(L,perc,1)==0;
> L1=ValueWhen(t1,L,1);t2=L1<LastValue(C);
> t=t1 AND t2;y1=Cum(t);y1max=LastValue(y1);
> PeakA=p AND x1==x1max;
> TroughA=t AND y1==y1max;
> Filter= PeakA OR TroughA;
> AddColumn(IIf(PeakA,H,0),"Last Peak",1.2);
> AddColumn(IIf(TroughA,L,0),"Last Trough",1.2);
> Sell=p AND x1==x1max;
> Buy=t AND y1==y1max;
> 
> --- In amibroker@xxxx, "dtsokakis" <TSOKAKIS@xxxx> wrote:
> > Franco, 
> > please, read again 
> > http://groups.yahoo.com/group/amibroker/message/14929
> > It is an exploration. It works in Automatic Analysis.
> > Select a stock, Explore for All quotations and then doubleclick 
on 
> > the results list.
> > You will see the arrows marking the points you ask.
> > It is NOT an ind. builder formula, there is nothing to be plotted.
> > The arrows are at the last peak [last trough] which satisfies the 
> > above LastValue(close) requirement [respectively below LastValue
> > (close)]. If a peak [trough] does not fulfil this criterion is 
> > skipped [we may change this priority, if you like.]
> > DT
> > 
> > --- In amibroker@xxxx, franco fornari <ffpsi@xxxx> wrote:
> > > Dimitris,
> > > 
> > > I'm manifestly not able to make me clear. Probably it
> > > depends on my poor english.
> > > Since I received more than one messages, out of
> > > chronological order (because Yahoo mail), I'll try to
> > > summarize my (maybe wrong) point of view.
> > > 
> > > 1. Look, please, at the first two attached gif. They
> > > plot my and your formulas, respectively. Do you see
> > > any difference? I can't. Moreover, I suppose for the
> > > two lines of code:
> > > 
> > > AddColumn(H,"Last Peak",1.2);
> > > AddColumn(L,"Last Trough",1.2);
> > > 
> > > you really meant as follows:
> > > 
> > > AddColumn(H1,"Last Peak",1.2);
> > > AddColumn(L1,"Last Trough",1.2);
> > > 
> > > 2. Look, now, at the third attached gif. I have
> > > manually added a yellow line, wich shows what level I
> > > wish to detect: the last trough higher than last
> > > closing price. Not the last trough by absolute. In
> > > this case it is the second last, but sometimes it
> > > could be the third from last or more.
> > > 
> > > 3. Running your exploration system, I don't find the
> > > value I need on the last line of results, but on the
> > > second last one. Then, it is not available for further
> > > applications.
> > > 
> > > 4. You said "Single points localization is not the
> > > easiest AFL sport". Well, I think AmiBroker is very
> > > powerful, but I don't expect it is omnipotent. If you,
> > > or any other person so expert as you are, says a
> > > certain thing is not possible, 
> > 
> > As far as I read my text, I did not say anything impossible.
> > [how should I write such a thing !!]
> > Although this discussion is a bit confused, we could simplify 
> things.
> > 
> > I can accept this.
> > > Maybe Tomasz will turn it possible in future, or maybe
> > > not. Anyway, the life will go on.
> > > 
> > > Best regards and thanks again for the time you spend
> > > to help me.
> > > 
> > > Franco
> > > 
> > > 
> > 
> 
______________________________________________________________________
> > > Vinci i Mondiali - La Grande Sfida dei Mondiali FIFA
> > > http://it.yahoo.com/mail_it/foot/?http://lasfida.yahoo.net/
> > > 
> > > 
> > 
> 
______________________________________________________________________
> > > Vinci i Mondiali - La Grande Sfida dei Mondiali FIFA
> > > http://it.yahoo.com/mail_it/foot/?http://lasfida.yahoo.net/
> > > 
> > > 
> > 
> 
______________________________________________________________________
> > > Vinci i Mondiali - La Grande Sfida dei Mondiali FIFA
> > > http://it.yahoo.com/mail_it/foot/?http://lasfida.yahoo.net/