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

[amibroker] Re: Real-Time Trading System Examples



PureBytes Links

Trading Reference Links

Steve,
The copy/paste daimon is always here !!
[a n1=na; was missing at the first line...]
Enjoy the most close/most remote MA with

na=5;nb=200;step=1;n1=na;n2=na;
f=LastValue(abs(C-MA(C,na)));
g=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;
}
if(d>g)
{n2=n;g=d;}
}
Plot(C,"\nC",1,8);
Plot(MA(C,n1),"close MA(C,"+WriteVal(n1,1.0)+")",colorDarkRed,8);
Plot(MA(C,n2),"remote MA(C,"+WriteVal(n2,1.0)+")",colorDarkBlue,8);

The result is not always the expected. In the [10,100] range, MA
(C,10) is not always the most close and MA(C,100) is not always the 
most remote....
Dimitris Tsokakis

--- In amibroker@xxxxxxxxxxxxxxx, "Steve Almond" <steve2@xxxx> wrote:
> 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@xxxx>
> 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@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
> >
> >
> >
> >
> >
> >
> >



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com.  Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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/