Dear keith,
 
Thanks very much for your explanations.
 
 
Regards
Kus

--- Pada Sen, 25/5/09, Keith McCombs <[email protected]> menulis:


Dari: Keith McCombs <[email protected]>
Topik: Re: [amibroker] Is Array Processing correct?
Kepada: [email protected]
Tanggal: Senin, 25 Mei, 2009, 2:14 AM








Kus --
You are making a classic afl mistake that almost all of us have made before 
(more than once for me).  The mistake is that:
nn is an array which you have on both the left and right side of the = sign in 
your equation nn = IIf(etc.  You are assuming, incorrectly, that the new value 
of Ref(nn, -1) will always be calculated before it is used in the equation.

This is a good example of when you need use looping with explicit array 
indexing.

One alternative which could reduce the code within the loop might be:

temp = (C-Ref(C,-1) )/Ref(C,- 1);
n[0]=100;
for(i-1; i<BarCount; i++){
  n[i] = n[i-1];
  if(V[i]<V[i-1]) n[i] *= 1 + temp[i];
}

-- Keith

Kusnady wrote: 






Dear All,

I found some un-answered questions about array processing of the AFL.
------------ --------- --------- --------- --------- --------- --------- --
nn = 100;
nn    = IIf(V<Ref(V,-1), Ref(nn,-1) + (C-Ref(C,-1) )/Ref(C,- 1) * Ref(nn,-1), 
Ref(nn,-1));
Plot(nn,"",colorYel low);
//---------- --------- --------- --------- ---------
n[0]=100;
for(i=1;i<BarCount;i++ )
{
    if(V[i] < V[i-1])
        n[i] = n[i-1] + (C[i]-C[i-1] )/C[i-1] * n[i-1];
    else
        n[i] = n[i-1];
}
Plot(n,"",colorRed) ;
------------ --------- --------- --------- --------- --------- --------- 
--------- ---
Array of "n" is supp osed to be the same as "nn" in the AFL below, but when 
they are plotted, they are not the same...It is the formula of NVI....

Could you help whey "n" is not the same as "nn"? or Do I make a mistake?



Thanks
Kus



Yahoo! Mail Sekarang Lebih Cepat dan Lebih Bersih. Rasakan bedanya! 















      Berbagi video sambil chatting dengan teman di Messenger. Sekarang bisa 
dengan Yahoo! Messenger baru. http://id.messenger.yahoo.com

Reply via email to