Thanks, G. That clarifies.
--- In [email protected], Graham <kavemanpe...@...> wrote: > > each array is aligned with the data that it is based on. MA(C,5) is > aligned to the close array, no offset applied > This would align the ma with the Close3 > > Close3 = ref( C, -3 ); > Centreline3 = ma( Close3, 5 ); > Buy = Close3 >Centreline3; > > If you want the signal to be C>MA and just have entry 3 bars later, > then B is correct > Of course you could always use something like this > > settradedelays(3,1,3,1); > Buy = c>ma(c,5); > > or if you only want to scan on bar before the entry then simplified > settradedelays(1,1,1,1); > Buy = ref( c>ma(c,5), -3 ); > > > > -- > Cheers > Graham Kav > AFL Writing Service > http://www.aflwriting.com > > > > 2009/4/15 ozzyapeman <zoopf...@...>: > > > > > > I know this is AFL 101 but I'm a bit confused on it. > > > > Let's say I wanted to Buy today if the Close of three days ago was higher > > than its "center line" moving average. I know I have to shift the Close > > array, but do I also have to shift the MA array to make this comparison? My > > thought is yes. > > > > So of the two formulas below, Formula B should be the correct one. Or is it? > > Does AFL automatically shift built-in function arrays when making > > comparisons? In that case, Formula A would be correct. > > > > > > Formula A > > > > CenterLine = MA(C, 5); > > > > Close3 = Ref(Close, -3); > > > > Buy = Close3 > CenterLine > > > > > > Formula B > > > > CenterLine = MA(C, 5); > > > > CenterLine3 = Ref(CenterLine, -3); > > > > Close3 = Ref(Close, -3); > > > > Buy = Close3 > CenterLine3 >
