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.lud...@...> 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 >
