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

[amibroker] Re: Mathematical question.



PureBytes Links

Trading Reference Links

Dimitris,

Interesting charts! I uncommented the //Plot... as you suggested and changed
STEP from 1 to 10. Very interesting chart!
As I clicked through various tickers with this plot, SOME of them produced
an error:

Variable 'n1' used without having been initialized

Why do only some tickers show this error?

Steve


----- Original Message ----- 
From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, April 10, 2004 10:22 AM
Subject: [amibroker] Re: Mathematical question.


> 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
>
>
>
>
>
>
>



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/