PureBytes Links
Trading Reference Links
|
There is another interesting application.
The upper limit MA and the lower limit MA [all the rest MAs
are "between"] define the %Width.
Stocks with higher %Width are trendy, the ones with lower %Width are
recently more or less congestive.
Explore for the last n=1 quotations with
na=5;nb=200;step=1;n1=na;n2=na;
f=LastValue((C-MA(C,na)));
g=LastValue((C-MA(C,na)));
for(n=na;n<=nb;n=n+step)
{
//Plot(MA(C,n),"",colorLightGrey,1);
d=LastValue((C-MA(C,n)));
if(d<f)
{
n1=n;
f=d;
}
if(d>g)
{n2=n;g=d;}
}
Plot(C,"\nC",1,64);
Plot(MA(C,n1),"\nupper limit MA(C,"+WriteVal(n1,1.0)
+")",colorDarkRed,8);
Plot(MA(C,n2),"\nlower limit MA(C,"+WriteVal(n2,1.0)
+")",colorDarkBlue,8);
Width=100*LastValue(abs(MA(C,n1)-MA(C,n2))/C);
Filter=1;
AddColumn(Width,"% Width");
and paste the same formula in IB to see what I mean.
When all the MAs belong to a narrow range of 3% or 5% of the last
price, there should have been many congestive days.
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx>
wrote:
> Yes. If the hypothesis
> if(d<f)
> is wrong for all n, then n1 can not have a value and remains
> undefined.
> With the initial n1=na, if the hypothesis is wrong, n1 will have a
> final value equal to na.
> It happens when the MA(C,10) is the closest MA.
> Dimitris Tsokakis
> --- In amibroker@xxxxxxxxxxxxxxx, "Steve Almond" <steve2@xxxx>
wrote:
> > Dimitris,
> >
> > Yes, that works perfectly. Do you understand why the previous
> version worked
> > some times, but not others?
> >
> > Steve
> >
> > ----- Original Message -----
> > From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Saturday, April 10, 2004 11:37 AM
> > Subject: [amibroker] Re: Mathematical question.
> >
> >
> > > 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@xxxx
> > > Send SUGGESTIONS to suggest@xxxx
> > > -----------------------------------------
> > > 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/
|