PureBytes Links
Trading Reference Links
|
Hello,
if Prev is self referencing ( something like [i-1]
in a loop) the whole formula
and after checking that AMA is the same than in a
loop , I suppose that the code I have sent is true
stephane
//vma = (0.78 * source) + (1 - 0.78 ) * prev;
Len = 20;
Factor = 2<FONT
size=1>/(Len+1);
Vma[0]=<FONT
color=#ff00ff size=1>0;
source[0<FONT
size=1>]=C[0<FONT
size=1>];
for(i=1<FONT
size=1>;i<BarCount;i++)
{
vma[i] = (Factor *
C[i]) +
(1 - Factor ) *
Vma[i-1];
}
Plot(Vma,<FONT color=#ff00ff
size=1>"vma",colorRed,<FONT color=#ff00ff
size=1>1);
vma = AMA(
C, Factor
);
Plot(Vma,<FONT color=#ff00ff
size=1>"vma",2<FONT
size=1>,1<FONT
size=1>);
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
john gibb
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Friday, April 23, 2004 10:56
PM
Subject: Re: [amibroker] Re: CMS Trailing
Stop System in AFL
hi d,
No; good catch. I think it should
read:
z =
AMA2(A,B,C);
and is derived from message 24163, where Tomasz suggested that
this:
<FONT face="Courier New"
size=3>vma = <FONT
color=#ffffff>AMA2( source, 078 * vr, 1 - 0.78 * vr
);
replaces:
<FONT
face="Courier New">vma = (0.78 * vr* source) + (1 - 0.78 * vr) * <FONT
color=#ffffff>prev
I can't remember where I got the table info, but
A(rray) was meant to suggest that the first AMA2 parameter is an array; the
last two are not.
Also note that '=' assignment operators in
Amibroker should actually be replacing ':=' operators in
Metastock.
-john
<BLOCKQUOTE dir=ltr
>
----- Original Message -----
<DIV
>From:
dingo
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Friday, April 23, 2004 12:38
PM
Subject: RE: [amibroker] Re: CMS
Trailing Stop System in AFL
<FONT face=Arial
color=#0000ff size=2>Nice table duude!
<FONT face=Arial
color=#0000ff size=2>
<FONT face=Arial
size=2>is this line correct:
<SPAN
><FONT
color=#0000ff>Z = AMA2( A(rray), B, C );
<SPAN
><FONT
color=#0000ff>
<SPAN
><SPAN
class=890303719-23042004><FONT
color=#0000ff>d
From: john gibb
[mailto:jgibb1@xxxxxxxxxxxxx] Sent: Friday, April 23, 2004 3:36
PMTo: <A
href="">amibroker@xxxxxxxxxxxxxxxSubject:
Re: [amibroker] Re: CMS Trailing Stop System in AFL
Hi rocou,
this may help
<TABLE
cellSpacing=0 cellPadding=0 border=1>
<TD
vAlign=top width=289>
<FONT
face="Times New Roman"><FONT
color=#008000>Metastock
<TD
vAlign=top width=306>
<FONT
face="Times New Roman"><FONT
color=#008000>AmiBroker
<TD
vAlign=top width=289>
<P class=MsoCommentText
align=center><SPAN
>Input(“prompt”,min,max,default)
<TD
vAlign=top width=306>
<SPAN
>Param(“prompt”,default,min,max,step)
<TD
vAlign=top width=289>
<SPAN
>MOV(?,?,E)
<TD
vAlign=top width=306>
<SPAN
>EMA(?,?)
<TD
vAlign=top width=289>
<SPAN
>MOV(?,?,S)
<TD
vAlign=top width=306>
<SPAN
>MA(?,?)
<TD
vAlign=top width=289>
<SPAN
>:=
<TD
vAlign=top width=306>
<SPAN
>=
<TD
vAlign=top width=289>
<SPAN
>expression
<TD
vAlign=top width=306>
<SPAN
>Plot(expression,....)
<TD
vAlign=top width=289>
<SPAN
>{comment}
<TD
vAlign=top width=306>
<SPAN
>//
comment
<TD
vAlign=top width=289>
<SPAN
>{comment}
<TD
vAlign=top width=306>
<SPAN
>/*
comment */
<TD
vAlign=top width=289>
<SPAN
>Z
=(A*B)+(C*PREV);
<TD
vAlign=top width=306>
<SPAN
>Z
= AMA2( A(rray), B, C );
<TD
vAlign=top width=289>
<SPAN
>x
= FactorA*Close+(FactorB*PREV(x));
<TD
vAlign=top width=306>
<SPAN
>x
=
AMA2(Close,FactorA,FactorB);
-john
----- Original Message -----
From: "rocou" <<A
href=""><FONT face=Arial
size=2>rocou@xxxxxxxxx>
To: <<A
href=""><FONT face=Arial
size=2>amibroker@xxxxxxxxxxxxxxx<FONT face=Arial
size=2>>
Sent: Friday, April 23, 2004 12:18
PM
Subject: [amibroker] Re: CMS Trailing Stop
System in AFL
<FONT
face=Arial size=2>Hello Stephane, thanks for your answer. The
definition of "PREV" and "Ref" is:PREVThe PREV constant allows
you to create self-referencing formulas. A self referencing formula is
one that is able to reference the "previous" period''s value of
itself.RefReferences a previous OR subsequent element in a
DATA ARRAY. A positive PERIOD references "n" periods in the
future; a negative PERIOD references "n" periods ago.So how
could we "translate" these formula from CMS´s language into AFL
?The trading system should look like this - we still have to
substitute "PREV" and "Ref"
..._________________________________________________________________nPips=Optimize("nPips",1,1,50,1);TrStopLevel
= if(C=PREV, PREV, if(((Ref(C,-1)<PREV)AND (C<PREV)),
Min(PREV,C*(1+nPips)), if((Ref(C,-1)>PREV) AND (C>PREV),
Max(PREV,C*(1-nPips)),
if(C>PREV,C*(1-nPips),C*(1+nPips)))));Buy =
Cross(Close,TrStopLevel);Sell = Cross(TrStopLevel,Close);Short
= Cross(TrStopLevel,Close);Cover =
Cross(Close,TrStopLevel);PositionSize =
100000;_________________________________________________________________Thanks
for your help again in
advanceRegardsRobert--- In <A
href=""><FONT face=Arial
size=2>amibroker@xxxxxxxxxxxxxxx,
"Stephane Carrasset" <<FONT
face=Arial size=2>s.carrasset@x...>
wrote:> Hello,> > I am not sure to have done a
correct interpretation of Prev but it is a begin> >
Stephane> > > > TrStop[0]=Null;>
> nP=0.1;> > for(i=1;i<BarCount;i++)>
> {> > if(C[i]==TrStop[i-1])> >
{> > TrStop[i]=TrStop[i-1];> > }>
> else> > {> > if(C[i-1]<TrStop[i-1]
&& C[i]<TrStop[i-1])> > {> >
TrStop[i]=Min(TrStop[i-1],C[i]*(1+nP));> > }>
> else> > {> > if(C[i-1]>TrStop[i-1]
&& C[i]>TrStop[i-1])> > {> >
TrStop[i]=Max(TrStop[i-1],C[i]*(1-nP));> > }>
> else> > {> >
if(C[i]>TrStop[i-1])> > {> >
TrStop[i]=C[i]*(1-nP);> > }> > else>
> {> > TrStop[i]=C[i]*(1+nP);> >
}> > }> > }> > }>
> }> > > > > > Up=
Cross(Close,TrStop);> > Down= Cross(TrStop,C);>
> > > /*> > if(C=PREV, PREV,
if(((Ref(C,-1)<PREV)> > AND (C<PREV)),
Min(PREV,C*(1+nPips)), if((Ref(C,-1)>PREV) > > AND
(C>PREV), Max(PREV,C*(1-nPips)), if(C>PREV,C*(1-nPips),C*>
> (1+nPips)))));> > */> >
Plot(C,"",1,64);> > Plot(TrStop,"TrStop",2,1);>
> PlotShapes(IIf(up,> >
shapeUpArrow,shapeNone),colorGreen,0,L,-10); > >
PlotShapes(IIf(down,> >
shapeDownArrow,shapeNone),colorRed,0,H,-10); > >
----- Original Message ----- > From: rocou
> To: <A
href=""><FONT face=Arial
size=2>amibroker@xxxxxxxxxxxxxxx
> Sent: Friday, April 23, 2004 8:47
AM> Subject: [amibroker] CMS Trailing Stop System in
AFL> > > Dear Traders, >
> may I please ask for your help - how do I have to
program the > following > "trailing
stop system" of my broker CMS in AFL, to backtest/optimize
> the "n pips" stop values ?>
> Thank you for your help in
advance.> Kind regards>
Robert> > > {Trailing Stop
Loss}> TrStopLevel:=If(C=PREV, PREV,
If(((Ref(C,-1)<PREV)> AND (C<PREV)),
Min(PREV,C*(1+nPips)), If((Ref(C,-1)>PREV) > AND
(C>PREV), Max(PREV,C*(1-nPips)),
If(C>PREV,C*(1-nPips),C*> (1+nPips)))));>
> {Signal Up and Down}> Up:=
Cross(Close,TrStopLevel);> Down:=
Cross(TrStopLevel,C);> > {OpenBuy, CloseBuy,
OpenSell, CloseSell}> OpenBuy:= Up and
(eventCount('OpenBuy')= eventCount('CloseBuy'));>
CloseBuy:= Down and
(eventCount('OpenBuy')>eventCount('CloseBuy'));>
OpenSell:= Down and (eventCount('OpenSell')=
eventCount> ('CloseSell'));>
CloseSell:= Up and
(eventCount('OpenSell')>eventCount('CloseSell'));> >
> > > > > Send BUG REPORTS
to <FONT face=Arial
size=2>bugs@x...>
Send SUGGESTIONS to <FONT face=Arial
size=2>suggest@x...>
-----------------------------------------> Post
AmiQuote-related messages ONLY to: <A
href=""><FONT face=Arial
size=2>amiquote@xxxxxxxxxxxxxxx
> (Web page: <A
href=""><FONT face=Arial
size=2>http://groups.yahoo.com/group/amiquote/messages/<FONT
face=Arial size=2>)>
--------------------------------------------> Check
group FAQ at: <A
href=""><FONT
face=Arial
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
face=Arial size=2> > >
> Yahoo! Groups
Sponsor
>
ADVERTISEMENT>
>
> > >
>
------------------------------------------------------------------------------>
Yahoo! Groups Links> > a.. To visit
your group on the web, go to:> <A
href=""><FONT face=Arial
size=2>http://groups.yahoo.com/group/amibroker/<FONT
face=Arial size=2>>
> b.. To unsubscribe from this group, send
an email to:> <A
href=""><FONT face=Arial
size=2>amibroker-unsubscribe@xxxxxxxxxxxxxxx<FONT
face=Arial size=2>>
> c.. Your use of Yahoo! Groups is subject
to the Yahoo! Terms of Service. > > >
> __________ NOD32 1.732 (20040422) Information
__________> > This message was checked by NOD32
antivirus system.> <A
href=""><FONT face=Arial
size=2>http://www.nod32.com<FONT face=Arial
size=2>Send BUG REPORTS to <A
href=""><FONT face=Arial
size=2>bugs@xxxxxxxxxxxxxSend
SUGGESTIONS to <FONT
face=Arial size=2>suggest@xxxxxxxxxxxxx<FONT face=Arial
size=2>-----------------------------------------Post AmiQuote-related
messages ONLY to: <FONT
face=Arial size=2>amiquote@xxxxxxxxxxxxxxx<FONT face=Arial
size=2> (Web page: <A
href=""><FONT face=Arial
size=2>http://groups.yahoo.com/group/amiquote/messages/<FONT
face=Arial
size=2>)--------------------------------------------Check group
FAQ at: <A
href=""><FONT
face=Arial
size=2>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
face=Arial size=2> Yahoo! Groups Links<*> To visit your
group on the web, go to: <A
href=""><FONT face=Arial
size=2>http://groups.yahoo.com/group/amibroker/<FONT
face=Arial size=2><*> To unsubscribe from this group, send an email
to: <A
href=""><FONT face=Arial
size=2>amibroker-unsubscribe@xxxxxxxxxxxxxxx<FONT
face=Arial size=2><*> Your use of Yahoo! Groups is subject
to: <A
href=""><FONT face=Arial
size=2>http://docs.yahoo.com/info/terms/<FONT face=Arial
size=2> Send BUG REPORTS to
bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend
SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Send BUG REPORTS to
bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
__________
NOD32 1.732 (20040422) Information __________This message was checked
by NOD32 antivirus system.<A
href="">http://www.nod32.com
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 Sponsor
ADVERTISEMENT
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 the Yahoo! Terms of Service.
|