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

RE: [amibroker] Re: Percentile



PureBytes Links

Trading Reference Links

Hello,

You must NOT use function call statement g ( n ) in the LEFT SIDE of the assignment statement.
=============================================================
Function calls can be only on RIGHT side of the assignment.
Function call stament triggers CALLING the function while all you really need and want to do
is just to assign the value to the certain cell of result array. 
Use local variable instead.

Also the loop is constructed wrong in your code. 
If you want to achieve this:
 g(N) = f(10) + f(11) + f(12) + ... + f(N)

Then correct would need to iterate from 10 to N.

Corrected code is:

function g(n)
{
  local result ; // we are using temporary local variable here

  result = f(10);

   for ( i = 11; i <= n;  i++)
   {
      result = result + f( i );
   }

   return result;
}


Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Graham" <gkavanagh@xxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, March 09, 2004 9:46 AM
Subject: RE: [amibroker] I need some loop-programming help


> I think the problem comes that you are using the functioning you are trying
> to define within the function itself. Try changing that g() inside the
> function. Also I am not sure if you can use another function within a
> function ie f(n) within g(n) ?
> 
> function g(n)
> {
> gr(10) = f(10);
> for (n=11;n<=30,n++)
> {
> gr(n) = gr(n-1) + f(n);
> }
> return gr(n);
> }
> 
> Cheers,
> Graham
> http://e-wire.net.au/~eb_kavan/
> 
> -----Original Message-----
> From: treliff [mailto:treliff@xxxxxxxxx] 
> Sent: Tuesday, March 09, 2004 4:04 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] I need some loop-programming help
> 
> Hi,
> I need some loop-programming help.
> 
> I have already defined a function f(n) (n are integers 10,11,...) 
> and now I want to define function g(n) such that
> 
> g(10) = f(10)
> g(11) = f(10) + f(11)
> g(12) = f(10) + f(11) + f(12)
> ...
> etc. say up to g(30)
> 
> As a clumsy mathematician (not a programmer) I would write something 
> like:
> 
> function g(n)
> {
> g(10) = f(10);
> for (n=11;n<=30,n++)
> {
> g(n) = g(n-1) + f(n);
> }
> return g(n);
> }
> 
> but this is obviously wrong, the first syntax error is the use of
> "g(10)" within the code.
> 
> Can anyone help me get this code right? Thanks much in advance.
> 
> PS
> Though this seems irrelevant to my question, the function f is 
> defined as follows:
> 
> function f(n)
> {
> return  log(C/Ref(C,-n))/(StDev(log(C/Ref(C,-1)),n)*sqrt(n)) ;
> }
> 
> 
> 
> 
> 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
> 
> 
> 
>  
> 
> 
> 
> 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
> 
> 
> 
>  
> 
> 


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/