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

Re: [amibroker] A Dumb Basic Question on Array Shifting



PureBytes Links

Trading Reference Links

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 <zoopfree@xxxxxxxxxxx>:
>
>
> 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


------------------------------------

**** 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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/