forget about loops first
myMA = ma(c, 3)
myweeklyma = timeframecompress(myma, inweekly);
myweekly5 = ref(myweeklyma, -5);
myweekly10 = ref(myweeklyma, -10);
myweekly15 = ref(myweeklyma, -15);
trend = myweekly5 > myweekly10 and myweekly10 > myweekly15;
 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of foginthehills
Sent: Thursday, 23 November 2006 10:54 PM
To: [email protected]
Subject: [amibroker] Re: TimeFrameSet and compress/expand





Thank you very much for your answers... very helpful.

So, how should I write my code if I want to examine a 3-day MA but "five
weeks ago" and 10 weeks ago and 15 weeks ago and 20 weeks ago, and so on.

I want to compare a 3-day MA at points which are 5 weeks apart, to see if it
is rising. Does this do it:

myMA = MA(Close, 3);    // I think this is a 3-day MA
TimeFrameCompress(myMA, inWeekly);  // now we can access the 3-day MA
'weekly'
TimeFrameSet(inWeekly);  // Close will be 'week close' value
trending = true;
// 'trending' is when week close is UP on previous, and 3-day MA is UP on
last week's 3-day MA
for (i = 0; i < 25; i = i + 5)
{
  trending = trending AND Ref(myMA,  i*-1) > Ref(myMA,  (i+5)*-1);
  trending = trending AND Ref(Close, i*-1) > Ref(Close, (i+5)*-1);
}


......does that do the job?


 


--- In [email protected], Graham <[EMAIL PROTECTED]> wrote:
>
> it will be 3 weekly
> 
> then after you apply
> *TimeFrameRestore();*
> You will get a compressed plot of the weekly MA. This will show at the end
> of the chart at 1 bar per week overlaid on the daily X axis
> You will not be able to see the dates that apply for the weekly
> Using the expan functions then stretches out the values of the weekly to
> apply them to the applicable daily days (Mon-Sun)
> You will see a step type plot with the weekly value showing the same for
> each day of that week
> 
> You can nsee how to do this in the help examples
> 
> 
> 
> 
> -- 
> Cheers
> Graham
> AB-Write >< Professional AFL Writing Service
> Yes, I write AFL code to your requirements
> http://www.aflwriting.com
> 
> On 22/11/06, foginthehills [EMAIL PROTECTED] wrote:
> >
> > Hi there,
> >
> > Can someone please confirm this for me?
> >
> > I read about Timeframeset in the AFL help, but it's still not clear to
> > me.
> >
> > I have seen this code in an AFL explore script:
> >
> > TimeFrameSet(inWeekly);
> > myMA = MA(Close, 3);
> >
> > .... so is myMA a 3 day or a 3 week moving average?
> >
> > And what does the Expand function really do with the array - does it
> > add more elements? How are these calculated? (Likewise Compress?)
> >
> > Many thanks for any help. Trying to understand AFL better.
> >
> >
> >
> >
> >
> >
> > Please note that this group is for discussion between users only.
> >
> > To get support from AmiBroker please send an e-mail directly to
> > SUPPORT {at} amibroker.com
> >
> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> >
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
>


 

Reply via email to