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

Re: [amibroker] Breakout Patterns



PureBytes Links

Trading Reference Links

I hope it will come full now.[the n1=na; was missing...]

na=10;nb=100;step=1;n1=na;
f=LastValue(abs(C-MA(C,na)));
for(n=na;n<=nb;n=n+step)
{
//Plot(MA(C,n),"",colorLightGrey,1);
d=LastValue(abs(C-MA(C,n)));
if(d<f)
{
n1=n;
f=d;
}
}
Plot(C,"\nC",1,8);
Plot(MA(C,n1),"MA(C,"+WriteVal(n1,1.0)+")",colorDarkRed,8);


--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx> 
wrote:
> If you have 5 different MAs [17, 35, 49, 112 and 238 bars] you 
should 
> compare the distances with
> min(d1,min(d2,min(d3,min(d4,d5)))).
> The second question is more interesting, you can use loops to find 
> the closest MA.
> If you search various MAs from na to nb, then the closest MA makes 
> the abs(C-MA(C,n)) minimum.
> 
> na=10;nb=100;step=1;
> f=LastValue(abs(C-MA(C,na)));
> for(n=na;n<=nb;n=n+step)
> {
> //Plot(MA(C,n),"",colorLightGrey,1);
> d=LastValue(abs(C-MA(C,n)));
> if(d<f)
> {
> n1=n;
> f=d;
> }
> }
> Plot(C,"\nC",1,8);
> Plot(MA(C,n1),"MA(C,"+WriteVal(n1,1.0)+")",colorDarkRed,8);
> 
> Uncomment the //Plot... line to see the rest MAs.
> Calibrate the na, nb, step according to your research field.
> Dimitris Tsokakis
> --- In amibroker@xxxxxxxxxxxxxxx, "mmqp" <mmqp@xxxx> wrote:
> > Hi, I have 5 different moving average.  I'd like to know/measure 
> the 
> > least distance of last close to these average.  Another word is 
> > which moving average is closest to today close.  I understand 
that 
> > this can be done in a brute force way however I would like to 
know 
> > if there is a better mathematical way to do this in case of more 
> > than 5 moving average.  TIA.



Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
     amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/