That being the case then why wouldn't Z =(A*B)+(C*Ref(Z,-1)); work without using loops? I guess that has been explored and there is more to the problem than I understand.
Barry --- In [email protected], Thomas Ludwig <thomas.lud...@...> wrote: > > Barry, > > PREV is NOT ref(c,-1) in this example but yesterday's value of Z. Otherwise > PREV wouldn't be necessary im Metastock since MS has the same ref function > like Amibroker. > > Regards, > > Thomas > > On 07.07.2009, 02:36:10 Barry Scarborough wrote: > > If PREV works only on C in the example, wouldn't this run faster than using > > a loop in AFL? Z =(A*B)+(C*Ref(C,-1)); Unless something has changed in the > > latest AFL releases Tomasz's array processing is much faster than using > > loops to perform the same function in AFL. > > > > Barry > > > > --- In [email protected], Thomas Ludwig <Thomas.Ludwig@> wrote: > > > Hello, > > > > > > TJ once wrote: > > > > > > [quote] > > > Hello, > > > > > > PREV in MS is needed because MS does NOT have looping. > > > > > > In AB, there are loop constructs so there is no need for PREV > > > because loops give faster and more general way of solving coding > > > problems. > > > > > > Since loops are more general they allow easy translation of every > > > case where MS needs PREV. > > > > > > Statment like this: > > > Z =(A*B)+(C*PREV); > > > > > > Using loop looks as follows: > > > > > > z = 0; // initialize > > > for( i = 1; i < BarCount; i++ ) > > > { > > > prev = Z[ i - 1 ]; // PREV is previous value of Z. > > > Z[ i ] = A[ i ] * B[ i ] + C[ i ] * prev; > > > } > > > > > > As you can see the statement is identical with the exception that > > > AFL looping code uses [ ] operator to access individual array elements. > > > > > > Good thing is that AFL looping code is BarCount-times faster than MS > > > code. Since 5 years of EOD data is 1300 bars, AFL looping code is 1300 > > > times faster than MS in that case. > > > > > > It is also possible to use AMA/AMA2 instead of PREV: > > > > > > Z = AMA2( A, B, C ); > > > > > > which is shorter but AMA is less general than looping code. > > > [/quote] > > > > > > HTH > > > > > > Greetings, > > > > > > Thomas > > > > > > On 15.06.2009, 13:06:00 Mubashar virk wrote: > > > > Hi all, > > > > > > > > Has any one worked out a universal AFL Function = the perversity in > > > > MetaStock that is called PREV. > > > > > > > > Thanks > > > > ------------------------------------ > > > > **** 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/ > > > > Yahoo! Groups Links > > > > > > >
