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

RE: [amibroker] Re: Learning



PureBytes Links

Trading Reference Links










As a thought you could maybe use the valuewhen function

 

PosRoc = IIf (CRoc >= 0, CRoc, valuewhen(Croc>=0,croc,1) );



<font size=3 color=teal
face="Times New Roman">Cheers,
Graham

<font size=2
color="#339966" face="Times New Roman"><font
color="#339966">http://groups.msn.com/ASXShareTrading

<font size=2
color="#339966" face="Times New Roman"><font
color="#339966">http://groups.msn.com/FMSAustralia



<span
>-----Original Message-----
From: sjsolak
[mailto:sjsolak@xxxxxxxxxxx] 
Sent: Friday, 25 April 2003 9:34
PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Re: Learning

<font size=2
face="Times New Roman"> 



<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 size=2
face="Times New Roman"> 





<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=336
 >
 
  
  <span
  >Date
  
  
  <span
  >Close
  
  
  <span
  >ROC
  
  
  <span
  >P Col
  
  
  <span
  >N Col
  
 
 
  
  <span
  >03/10/02
  
  
  <span
  >1,164.31
  
  
  <span
  >0.58
  
  
  <span
  >0.58
  
  
  <span
  >-0.45
  
 
 
  
  <span
  >03/11/02
  
  
  <span
  >1,168.26
  
  
  <span
  >0.34
  
  
  <span
  >0.34
  
  
  <span
  >0.58
  
 
 
  
  <span
  >03/12/02
  
  
  <span
  >1,165.58
  
  
  <span
  >-0.23
  
  
  <span
  >0.34
  
  
  <span
  >-0.23
  
 
 
  
  <span
  >03/13/02
  
  
  <span
  >1,154.09
  
  
  <span
  >-0.99
  
  
  <span
  >-0.23
  
  
  <span
  >-0.99
  
 
 
  
  <span
  >03/14/02
  
  
  <span
  >1,153.04
  
  
  <span
  >-0.09
  
  
  <span
  >-0.99
  
  
  <span
  >-0.09
  
 
 
  
  <span
  >03/15/02
  
  
  <span
  >1,166.16
  
  
  <span
  >1.14
  
  
  <span
  >1.14
  
  
  <span
  >-0.09
  
 
 
  
  <span
  >03/18/02
  
  
  <span
  >1,165.55
  
  
  <span
  >-0.05
  
  
  <span
  >1.14
  
  
  <span
  >-0.05
  
 
 
  
  <span
  >03/19/02
  
  
  <span
  >1,170.29
  
  
  <span
  >0.41
  
  
  <span
  >0.41
  
  
  <span
  >-0.05
  
 






<font size=2
face="Times New Roman"> 





<font size=2
face="Times New Roman"> 





<span
>I did not want the P Col or N Col to
change if the ROC is the opposite sign.





<font size=2
face="Times New Roman"> 





<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=336
 >
 
  
  <span
  >Date
  
  
  <span
  >Close
  
  
  <span
  >ROC
  
  
  <span
  >P Col
  
  
  <span
  >N Col
  
 
 
  
  <span
  >03/08/02
  
  
  <span
  >1,164.31
  
  
  <span
  >0.58
  
  
  <span
  >0.58
  
  
  <span
  >-0.45
  
 
 
  
  <span
  >03/11/02
  
  
  <span
  >1,168.26
  
  
  <span
  >0.34
  
  
  <span
  >0.34
  
  
  <span
  >-0.45
  
 
 
  
  <span
  >03/12/02
  
  
  <span
  >1,165.58
  
  
  <span
  >-0.23
  
  
  <span
  >0.34
  
  
  <span
  >-0.23
  
 
 
  
  <span
  >03/13/02
  
  
  <span
  >1,154.09
  
  
  <span
  >-0.99
  
  
  <span
  >0.34
  
  
  <span
  >-0.99
  
 
 
  
  <span
  >03/14/02
  
  
  <span
  >1,153.04
  
  
  <span
  >-0.09
  
  
  <span
  >0.34
  
  
  <span
  >-0.09
  
 
 
  
  <span
  >03/15/02
  
  
  <span
  >1,166.16
  
  
  <span
  >1.14
  
  
  <span
  >1.14
  
  
  <span
  >-0.09
  
 
 
  
  <span
  >03/18/02
  
  
  <span
  >1,165.55
  
  
  <span
  >-0.05
  
  
  <span
  >1.14
  
  
  <span
  >-0.05
  
 
 
  
  <span
  >03/19/02
  
  
  <span
  >1,170.29
  
  
  <span
  >0.41
  
  
  <span
  >0.41
  
  
  <span
  >-0.05
  
 






<font size=2
face="Times New Roman"> 





<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 size=2
face="Times New Roman"> 





<span
>Thanks





<span
>Stan Solak





<span
> 







<span
>----- Original Message ----- 





<font
size=2 face=Arial>From: <a
href="" title="amiabilityy@xxxxxxxxx">amiabilityy






<span
>To:<font
face=Arial> <a
href="" title="amibroker@xxxxxxxxxxxxxxx">amibroker@xxxxxxxxxxxxxxx






<span
>Sent:<font
face=Arial> Friday, April 25, 2003 12:37 AM





<span
>Subject:<font
face=Arial> [amibroker] Re: Learning





<font size=2
face="Times New Roman"> 



<font size=2
face="Courier New">Hi sjsolak.<font
face="Courier New">

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.

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);
barnumberpos = Cum(PosRoc);
lastbarpos = barnumberpos == LastValue(
barnumberpos );
lastbarpos =Cross(Lastbarpos,0.1);

barnumberneg = Cum(NegRoc );
lastbarneg = barnumberneg == LastValue(
barnumberneg );
lastbarneg =Cross(Lastbarneg,0.1);

Filter = Croc;//1;

AddColumn(Ref(C,-1),"yesterdaysclose
today");
AddColumn(C,"close today");
AddColumn(CRoc,"ROC");
AddColumn(PosRoc,"P Col");
AddColumn(NegRoc,"N Col");
AddColumn(Lastbarpos,"Lastpos");
AddColumn(Lastbarneg,"Lastneg");




Peter.



--- In amibroker@xxxxxxxxxxxxxxx,
"sjsolak" <sjsolak@xxxx> wrote:
> I am still trying learn Amibroker.  I
have a question.  I am OK 
with 
> 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 
> postive value if the new ROC is negative.
> 
> I want Col C to be the ROC if the Close ROC
is negative and the 
last 
> negative value if the new ROC is postive.
> 
> 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 
that 
> value.
> 
> In Excel it is (B1) =If(a1>=0,a1,b2)
>               
(C1) =If (a1<0,a1,c2)   
> 
> AmiBroker Test:
> 
> CRoc = ROC(C,1);
> prevCRoc = Ref(CRoc,-1);
> 
> PosRoc = IIf (CRoc >= 0, CRoc, prevCRoc);
> NegRoc = IIf (CRoc < 0, CRoc, prevCRoc);
>  
> Filter = Close >1;
>  
> AddColumn(C,"close today");
> AddColumn(CRoc,"ROC");
> AddColumn(PosRoc,"P Col");
> AddColumn(NegRoc,"N Col");
> 
> 
> // 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 );
> 
> Stan Solak



Send BUG REPORTS to bugs@xxxxxxxxxxxxx<font
face="Courier New">
Send 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.




<font size=2
face="Times New Roman">



Send
BUG REPORTS to bugs@xxxxxxxxxxxxx<span
>
Send 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.