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

Re: [amibroker] Re: How to use EOD data to get weekly info?



PureBytes Links

Trading Reference Links

Greg,

Here is a formula for the indicator builder: load into indicator builder
, select show dates and click apply.

/****************************************/

LastBar = Cum(1)==LastValue(Cum(1));

WeeklyOpen=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1)OR
lastbar ,Open);

Weeklyhigh=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1)OR
Lastbar,High);
WeeklyLow=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1)OR
Lastbar ,Low);
WeeklyClose=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1)OR
Lastbar,Close);

Weekly_avg=(WeeklyOpen+Weeklyhigh+WeeklyLow+WeeklyClose)/4;

Filter=Cross(weekly_avg, EMA (weekly_avg,40) );
Buy=Filter;
Sell=0;
AddColumn( weekly_avg, "weekly_avg" );
AddColumn( EMA (weekly_avg,40), "ema (weekly_avg,40)" );

Plot(weekly_avg,"weeklyAvg",4,1);
Plot(EMA (weekly_avg,40) ,"ema",5,1);
Plot(Buy*weekly_avg,"",7,2);

Under the Range heading in AA, set n last quotations and n=150, ( n
last days and n=150 produces June 21 ) .

let me know

Anthony
liugq_99 wrote:

> Thank you very much, Anthony. It helps a lot.
>
> I do have a question. I load your formula and run to explore against
> KO for 150 bars (30 weeks). I get one crossing on June 21 while if I
> run an AFL codes( x=(O+H+L+C)/4; y=ema(x,40); plot(x,"",1,1);plot
> (y,"",3,1);) to weekly data I get at least two crossings on March 8
> and July 12. Why this happen?
>
> After I change from 40 bars to 200 bars(40 weeks) for the filter,
> (the code: Filter=Cross(weekly_avg, EMA (weekly_avg,200));)
> I get March 8 crossing but no July 12 crossing. Do you have any idea?
> Thanks a lot.
>
> Greg Liu
>
>
>
>
> --- In amibroker@xxxx, Anthony Faragasso <ajf1111@xxxx> wrote:
> > Greg,
> >
> > The last post had an unwanted line of code in it. Try this formula,
> this
> > uses up to current data.
> >
> > /****************************************/
> >
> > LastBar = Cum(1)==LastValue(Cum(1));
> >
> > WeeklyOpen=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1)OR
> Lastbar ,Open);
> >
> > Weeklyhigh=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1)OR
> Lastbar,High);
> > WeeklyLow=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1)OR
> Lastbar ,Low);
> > WeeklyClose=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1)OR
> > Lastbar,Close);
> >
> > Weekly_avg=(WeeklyOpen+Weeklyhigh+WeeklyLow+WeeklyClose)/4;
> >
> > Filter=Cross(weekly_avg, EMA (weekly_avg,40) );
> >
> > AddColumn( weekly_avg, "weekly_avg" );
> > AddColumn( EMA (weekly_avg,40), "ema (weekly_avg,40)" );
> >
> > Anthony
> >
> >
> > "Greg Q. Liu" wrote:
> >
> > > I try to write an AFL fomula to scan weekly crossing for 4 week
> > > periods by using daily data
> > > as weekly_avg=
> (weekly_high+weekly_low+weekly_open+weekly_close)/4;filter=cross
> (weekly_avg,
> > > ema (weekly_avg,40) );addcolumn(
> weekly_avg, "weekly_avg" );addcolumn(
> > > ema (weekly_avg,40), "ema (weekly_avg,40)" ); But I only have
> daily
> > > data, how this can be done? Thanks. GL
> > >
> > >
> > > Yahoo! Groups Sponsor
> > ADVERTISEMENT
> >
> > >
> > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
>
>
> Yahoo! Groups Sponsor
ADVERTISEMENT

>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.