PureBytes Links
Trading Reference Links
|
Graham,
Thank you. The valuewhen function
worked the way I wanted my result to work. I spent many hours trying
various methods with no success. AFL is too good not to have a easy
(if you know how) method to do whatever one can do in Excel.
Stan
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
<A title=gkavanagh@xxxxxxxxxxxxx
href="">Graham
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Friday, April 25, 2003 6:17
PM
Subject: RE: [amibroker] Re:
Learning
<SPAN
>As a thought you could maybe use
the valuewhen function
<SPAN
>
<SPAN
>PosRoc = IIf (CRoc >= 0, CRoc,
valuewhen(Croc>=0,croc,1) );
<FONT face="Times New Roman" color=teal
size=3><SPAN
>Cheers,Graham
<FONT
face="Times New Roman" color=#339966 size=2><SPAN
><A
href=""><SPAN
>http://groups.msn.com/ASXShareTrading
<FONT
face="Times New Roman" color=#339966 size=2><SPAN
><A
href=""><SPAN
>http://groups.msn.com/FMSAustralia
<SPAN
>-----Original
Message-----From: sjsolak
[mailto:sjsolak@xxxxxxxxxxx] <SPAN
>Sent: Friday, 25 April 2003 9:34
PMTo: <A
href="">amibroker@xxxxxxxxxxxxxxx<SPAN
>Subject: Re: [amibroker] Re:
Learning
<FONT face="Times New Roman"
size=2>
<SPAN
>Peter,
<SPAN
>Thank you for the suggestion, but
it still is not what I want. I added my prevCRoc = Ref(CRoc,-1) to
your suggested code and here is what I got (Minus a few columns). I ran
an Explore on SPX starting with 3/8/02..
<FONT face="Times New Roman"
size=2>
<TABLE class=MsoNormalTable
cellSpacing=0 cellPadding=0 width=336 border=0>
<TD
width="20%" height=16>
<SPAN
>Date
<TD
width="20%" height=16>
<SPAN
>Close
<TD
width="20%" height=16>
<SPAN
>ROC
<TD
width="20%" height=16>
<SPAN
>P Col
<TD
width="20%" height=16>
<SPAN
>N
Col
<TD
width="20%" height=16>
<SPAN
>03/10/02
<TD
width="20%" height=16>
<SPAN
>1,164.31
<TD
width="20%" height=16>
<SPAN
>0.58
<TD
width="20%" height=16>
<SPAN
>0.58
<TD
width="20%" height=16>
<SPAN
>-0.45
<TD
width="20%" height=16>
<SPAN
>03/11/02
<TD
width="20%" height=16>
<SPAN
>1,168.26
<TD
width="20%" height=16>
<SPAN
>0.34
<TD
width="20%" height=16>
<SPAN
>0.34
<TD
width="20%" height=16>
<SPAN
>0.58
<TD
width="20%" height=16>
<SPAN
>03/12/02
<TD
width="20%" height=16>
<SPAN
>1,165.58
<TD
width="20%" height=16>
<SPAN
>-0.23
<TD
width="20%" height=16>
<SPAN
>0.34
<TD
width="20%" height=16>
<SPAN
>-0.23
<TD
width="20%" height=16>
<SPAN
>03/13/02
<TD
width="20%" height=16>
<SPAN
>1,154.09
<TD
width="20%" height=16>
<SPAN
>-0.99
<TD
width="20%" height=16>
<SPAN
>-0.23
<TD
width="20%" height=16>
<SPAN
>-0.99
<TD
width="20%" height=16>
<SPAN
>03/14/02
<TD
width="20%" height=16>
<SPAN
>1,153.04
<TD
width="20%" height=16>
<SPAN
>-0.09
<TD
width="20%" height=16>
<SPAN
>-0.99
<TD
width="20%" height=16>
<SPAN
>-0.09
<TD
width="20%" height=16>
<SPAN
>03/15/02
<TD
width="20%" height=16>
<SPAN
>1,166.16
<TD
width="20%" height=16>
<SPAN
>1.14
<TD
width="20%" height=16>
<SPAN
>1.14
<TD
width="20%" height=16>
<SPAN
>-0.09
<TD
width="20%" height=16>
<SPAN
>03/18/02
<TD
width="20%" height=16>
<SPAN
>1,165.55
<TD
width="20%" height=16>
<SPAN
>-0.05
<TD
width="20%" height=16>
<SPAN
>1.14
<TD
width="20%" height=16>
<SPAN
>-0.05
<TD
width="20%" height=16>
<SPAN
>03/19/02
<TD
width="20%" height=16>
<SPAN
>1,170.29
<TD
width="20%" height=16>
<SPAN
>0.41
<TD
width="20%" height=16>
<SPAN
>0.41
<TD
width="20%" height=16>
<SPAN
>-0.05
<FONT face="Times New Roman"
size=2>
<FONT face="Times New Roman"
size=2>
<SPAN
>I did not want the P Col or N Col
to change if the ROC is the opposite sign.
<FONT face="Times New Roman"
size=2>
<TABLE class=MsoNormalTable
cellSpacing=0 cellPadding=0 width=336 border=0>
<TD
width="20%" height=16>
<SPAN
>Date
<TD
width="20%" height=16>
<SPAN
>Close
<TD
width="20%" height=16>
<SPAN
>ROC
<TD
width="20%" height=16>
<SPAN
>P Col
<TD
width="20%" height=16>
<SPAN
>N
Col
<TD
width="20%" height=16>
<SPAN
>03/08/02
<TD
width="20%" height=16>
<SPAN
>1,164.31
<TD
width="20%" height=16>
<SPAN
>0.58
<TD
width="20%" height=16>
<SPAN
>0.58
<TD
width="20%" height=16>
<SPAN
>-0.45
<TD
width="20%" height=16>
<SPAN
>03/11/02
<TD
width="20%" height=16>
<SPAN
>1,168.26
<TD
width="20%" height=16>
<SPAN
>0.34
<TD
width="20%" height=16>
<SPAN
>0.34
<TD
width="20%" height=16>
<SPAN
>-0.45
<TD
width="20%" height=16>
<SPAN
>03/12/02
<TD
width="20%" height=16>
<SPAN
>1,165.58
<TD
width="20%" height=16>
<SPAN
>-0.23
<TD
width="20%" height=16>
<SPAN
>0.34
<TD
width="20%" height=16>
<SPAN
>-0.23
<TD
width="20%" height=16>
<SPAN
>03/13/02
<TD
width="20%" height=16>
<SPAN
>1,154.09
<TD
width="20%" height=16>
<SPAN
>-0.99
<TD
width="20%" height=16>
<SPAN
>0.34
<TD
width="20%" height=16>
<SPAN
>-0.99
<TD
width="20%" height=16>
<SPAN
>03/14/02
<TD
width="20%" height=16>
<SPAN
>1,153.04
<TD
width="20%" height=16>
<SPAN
>-0.09
<TD
width="20%" height=16>
<SPAN
>0.34
<TD
width="20%" height=16>
<SPAN
>-0.09
<TD
width="20%" height=16>
<SPAN
>03/15/02
<TD
width="20%" height=16>
<SPAN
>1,166.16
<TD
width="20%" height=16>
<SPAN
>1.14
<TD
width="20%" height=16>
<SPAN
>1.14
<TD
width="20%" height=16>
<SPAN
>-0.09
<TD
width="20%" height=16>
<SPAN
>03/18/02
<TD
width="20%" height=16>
<SPAN
>1,165.55
<TD
width="20%" height=16>
<SPAN
>-0.05
<TD
width="20%" height=16>
<SPAN
>1.14
<TD
width="20%" height=16>
<SPAN
>-0.05
<TD
width="20%" height=16>
<SPAN
>03/19/02
<TD
width="20%" height=16>
<SPAN
>1,170.29
<TD
width="20%" height=16>
<SPAN
>0.41
<TD
width="20%" height=16>
<SPAN
>0.41
<TD
width="20%" height=16>
<SPAN
>-0.05
<FONT face="Times New Roman"
size=2>
<SPAN
>If you or anyone else can help me
with this (simple?) example, I would appreciate it.
<SPAN
>I can do it in Excel but really
want to learn AFL.
<FONT face="Times New Roman"
size=2>
<SPAN
>Thanks
<SPAN
>Stan Solak
<FONT face="Courier New"
size=1><SPAN
>
<BLOCKQUOTE
>
<SPAN
>----- Original Message -----
<FONT
face=Arial size=2><SPAN
>From:<FONT
face=Arial> <A title=amiabilityy@xxxxxxxxx
href="">amiabilityy
<FONT face=Arial
size=2><SPAN
>To:<FONT
face=Arial> <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
<FONT face=Arial
size=2><SPAN
>Sent:<FONT
face=Arial> Friday, April 25, 2003 12:37
AM
<FONT face=Arial
size=2><SPAN
>Subject:<FONT
face=Arial> [amibroker] Re:
Learning
<FONT face="Times New Roman"
size=2>
<FONT face="Courier New"
size=2>Hi sjsolak.<FONT
face="Courier New"><SPAN
>Im
not sure of what yopu want but this formula places all the
positive ROC in 1 column and
the negative ROC in another column.<FONT
face="Courier New">It also has 2 other column, 1 has the last time the
positive ROC was true,and the
other contains the last time the negative ROC was true.
Run it as an
exploration.CRoc =
ROC(C,1);PosRoc = IIf (CRoc
>= 0, CRoc, prevCRoc);NegRoc
= IIf (CRoc < 0, CRoc, prevCRoc);<FONT
face="Courier New">barnumberpos = Cum(PosRoc);<FONT
face="Courier New">lastbarpos = barnumberpos == LastValue( barnumberpos
);lastbarpos
=Cross(Lastbarpos,0.1);<FONT
face="Courier New">barnumberneg = Cum(NegRoc );<FONT
face="Courier New">lastbarneg = barnumberneg == LastValue( barnumberneg
);lastbarneg
=Cross(Lastbarneg,0.1);<FONT
face="Courier New">Filter = Croc;//1;<FONT
face="Courier New">AddColumn(Ref(C,-1),"yesterdaysclose
today");AddColumn(C,"close
today");<FONT
face="Courier New">AddColumn(CRoc,"ROC");<FONT
face="Courier New">AddColumn(PosRoc,"P Col");<FONT
face="Courier New">AddColumn(NegRoc,"N Col");<FONT
face="Courier New">AddColumn(Lastbarpos,"Lastpos");<FONT
face="Courier New">AddColumn(Lastbarneg,"Lastneg");<FONT
face="Courier New">Peter.<FONT
face="Courier New">--- In amibroker@xxxxxxxxxxxxxxx, "sjsolak"
<sjsolak@xxxx> wrote:>
I am still trying learn Amibroker. I have a question. I am OK
with <FONT
face="Courier New">> Excel so I can explain my question using an Excel
example.>
> Col A is the ROC for the
Close (of SPX in my test)>
> I want Col B to be the ROC
if the Close ROC is postive and the last <FONT
face="Courier New">> postive value if the new ROC is
negative.>
> I want Col C to be the ROC
if the Close ROC is negative and the <FONT
face="Courier New">last >
negative value if the new ROC is postive.<FONT
face="Courier New">> >
Will someone please help? Here is the code I have, but willing to
> start over. This
gives values for the prevCRoc and I don't want <FONT
face="Courier New">that >
value.>
> In Excel it is (B1)
=If(a1>=0,a1,b2)<FONT
face="Courier New">>
(C1) =If (a1<0,a1,c2) <FONT
face="Courier New">> >
AmiBroker Test:>
> CRoc =
ROC(C,1);> prevCRoc =
Ref(CRoc,-1);>
> PosRoc = IIf (CRoc >=
0, CRoc, prevCRoc);> NegRoc
= IIf (CRoc < 0, CRoc, prevCRoc);<FONT
face="Courier New">> <FONT
face="Courier New">> Filter = Close >1;<FONT
face="Courier New">> <FONT
face="Courier New">> AddColumn(C,"close today");<FONT
face="Courier New">> AddColumn(CRoc,"ROC");<FONT
face="Courier New">> AddColumn(PosRoc,"P Col");<FONT
face="Courier New">> AddColumn(NegRoc,"N Col");<FONT
face="Courier New">> >
> // Not sure below is
correct. Why do you need Buy and Sell for
>
Explore?> Buy = Cross(
Close, EMA( Close, 45 ) );>
Sell = Cross( EMA( Close, 45 ), Close );<FONT
face="Courier New">> >
Stan Solak<FONT
face="Courier New">Send BUG REPORTS to bugs@xxxxxxxxxxxxx<FONT
face="Courier New"><FONT
face="Courier New">Send SUGGESTIONS to
suggest@xxxxxxxxxxxxx<FONT
face="Courier New">-----------------------------------------<FONT
face="Courier New">Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">--------------------------------------------<FONT
face="Courier New">Check group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to
the Yahoo! Terms of
Service.
<FONT face="Times New Roman"
size=2><SPAN
><FONT
face="Courier New">Send BUG REPORTS to bugs@xxxxxxxxxxxxx<FONT
face="Courier New"><FONT
face="Courier New">Send SUGGESTIONS to
suggest@xxxxxxxxxxxxx<FONT
face="Courier New">-----------------------------------------<FONT
face="Courier New">Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">--------------------------------------------<FONT
face="Courier New">Check group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to
the Yahoo! Terms of
Service.
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
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Yahoo! Groups Sponsor
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
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|