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

Re: [amibroker] Is Array Processing correct?



PureBytes Links

Trading Reference Links



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,"",colorYellow);
//----------------------------------------------
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!


__._,_.___


**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___