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

[amibroker] Re: Example using functions in MathLib (for Jayson)



PureBytes Links

Trading Reference Links

This will do the same as what the function crLinearcorrelation
does:

x= BarIndex();
r=Correlation(C,x,20);
Plot(r^2,"",4,8);


and is shorter because it is already in AFL. 

nand






--- In amibroker@xxxxxxxxxxxxxxx, "Jayson" <jcasavant@xxxx> wrote:
> Thanks Chuck,
> 
> My questions were aimed at developing my own functions and I think 
you
> answered my questions. I will do some experimenting. If you decide 
to add
> array to the function please share it so I can compare the syntax.
> 
> Regards,
> 
> Jayson
> -----Original Message-----
> From: Chuck Rademacher [mailto:chuck_rademacher@x...]
> Sent: Wednesday, May 07, 2003 4:42 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Example using functions in MathLib (for 
Jayson)
> 
> 
> 
> I'm lost, Jayson, sorry.
> 
> Are you interested in writing functions or using the functions I 
uploaded?
> 
> To use RSquared, you don't even have to look at it.  I've 
documented the
> fact that you only pass the number of bars and it returns the value 
of the
> function.
> 
> If you are asking me how to write a function, you can have as 
many "things"
> being passed to the function as you want.   As long as the AFL 
calling the
> function and the function itself agree on how many parameters are 
being
> passed and in what order, everything is peachy.
> 
> I could have written the function like this:
> 
> function crLinearCorrelation (crArray, crLength);
> 
> I may, in fact, change it to that form in case someone wants to use 
the
> function on something other than the closing price.   If I wrote it 
that
> way, then the AFL calling it has to pass two, corresponding 
parameters to
> it.
> 
> Finally, you can return only one value and that is achieved with the
> "return" statement as you have noted below.
> 
> I'm happy to help, but I'm not sure whether you are seeking 
assistance with
> using my functions or writing your own.   If you want help with 
writing one,
> just make an attempt at it and send it to me for comment.   You'll 
get
> comments and assistance from others, too.
>   -----Original Message-----
>   From: Jayson [mailto:jcasavant@x...]
>   Sent: Wednesday, May 07, 2003 4:22 PM
>   To: amibroker@xxxxxxxxxxxxxxx
>   Subject: RE: [amibroker] Example using functions in MathLib (for 
Jayson)
> 
> 
>   Thanks Chuck,
> 
>   Forgive me the rudimentary questions and please correct me if I 
am wrong.
> First you declare the function with
>   function crLinearCorrelation (crLength)
> 
>   then you make your calculations with in the {   } and you base 
the results
> of the function with your IIf statement and the result of the 
calculations
> you call with..
> 
>   return IIf(crLowEQT == 0, 0, crUpEQ / crLowEQT);
> 
>   Is it always assumed that following the function name
> (crLinearCorrelation ) that the next argument is a period 
(crlength)??
> 
> 
>   Regards,
> 
>   Jayson
>   -----Original Message-----
>   From: Chuck Rademacher [mailto:chuck_rademacher@x...]
>   Sent: Wednesday, May 07, 2003 3:22 PM
>   To: amibroker@xxxxxxxxxxxxxxx
>   Subject: [amibroker] Example using functions in MathLib (for 
Jayson)
> 
> 
>   Jayson...
> 
>   Perhaps you missed another posting on the subject.
> 
>   Here is an example using R-Squared that you might have in a 
trading
> system:
> 
>   #INCLUDE  "........................./crMathLib.afl";
>   ..
>   Buy = LinRegSlope > 0 and crRSquared(20) > 0.80;
>   Sell = LinRegSlope < 0 and crRSquared(20) > 0.80;
> 
> 
>   or, you might just want to graph R-Squared:
> 
>   graph(0) = crRSquared(20);
> 
> 
> 
>     -----Original Message-----
>     From: Jayson [mailto:jcasavant@x...]
>     Sent: Wednesday, May 07, 2003 9:01 AM
>     To: amibroker@xxxxxxxxxxxxxxx
>     Subject: RE: [amibroker] New math functions added to AFL library
> (AmiBroker.com)
> 
> 
>     Chuck,
>     Thanks for sharing this. Could perhaps post an example afl  
showing the
> use of one or both?
> 
>     Regards,
> 
>     Jayson
>     -----Original Message-----
>     From: Chuck Rademacher [mailto:chuck_rademacher@x...]
>     Sent: Tuesday, May 06, 2003 3:57 PM
>     To: amibroker@xxxxxxxxxxxxxxx
>     Subject: [amibroker] New math functions added to AFL library
> (AmiBroker.com)
> 
> 
>     I've just uploaded a (very) small library of math functions to 
the AFL
> library at AmiBroker.com.  It is a "work in progress" library and 
this first
> posting is purely to get things going.  More functions will be added
> regularly.  Users may cut and paste functions into their own code.  
The name
> of the file is crMathLib.afl and the current version only includes:
> 
>     crLinearCorrelation (bars)
> 
>     crRSquare (bars)
> 
> 
>     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
> 
>     Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
> 
>     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
> 
>     Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
> 
> 
>   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
> 
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
> 
>   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
> 
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
> 
>       Yahoo! Groups Sponsor
> 
> 
> 
> 
> 
> 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
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/YoVfrB/XP.FAA/uetFAA/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 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/