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

[Metastockusers] Re: Multiple timeframes



PureBytes Links

Trading Reference Links

--- In Metastockusers@xxxxxxxxxxxxxxx, "Roy Larsen" <rlarsen@xxxx> 
wrote:
> Pring
> 
> > I don't know if it is me but I'm sure we all have our
> > own ways of writing formulas and I find it difficult
> > to follow what you have below.  I do write quite a
> > number of formulas, experts, etc. so I understand the
> > basic ideas.
> 
> Don't worry. Often I can't understand my own stuff when I go back to 
it
> either : (
> 
> I don't use long variable names because when repeated often they 
take up
> more room than I can afford. Comments ditto.
> 
> > Would you mind inserting some comments explaining what
> > you are doing after each line of code?  For example, I
> > know the DayOfWeek is looking for a close on Friday
> > but what about the rest of the lines?
> >
> > That would be greatly appreciated!
> 
> Will do. Forgive me for not addressing the issues in the timeframe 
of your
> choice but I don't own MS Pro and so prefer to post only that code 
that I
> can actually test as OK.
> 
>   {Weekly Frame CLOSE}
> W1:=DayOfWeek()=5;
>   {is this bar a Friday?}
> W2:=Alert(W1,2);
>   {extend Friday bar across next trade day}
> W3:=DayOfWeek()<Ref(DayOfWeek(),-1);
>   {Is this the day after the last day of the week?}
> We:=If(W1,1,If(W2=0 AND W3,2,0));
>   {end of week - if Friday then assign a value of one, if first day 
of week
> following a missing Friday then assign a value of two}
> Wcl:=ValueWhen(1,We>0,If(We=1,C,Ref(C,-1)));
>   {weeks CLOSE - if end of week was a Friday then use CLOSE, if end 
of week
> was not a friday then use CLOSE for the previous bar}
> Wcl;

Hi, Roy

I also had to struggle somewhat to follow your program. I wonder if 
the following modifications might help the next time you post it for 
someone? If so, feel free to use them. :-)

{Weekly Frame CLOSE}
Fri := DayOfWeek()=5;
NoHoliday := Alert(Friday, 2);
Mon := DayOfWeek()=1;
EoW := If(Fri, 1, If(NoHoliday=0 AND Mon, 2, 0));
{end of week - if Friday then assign a value of one; if Monday 
following a holiday Friday then assign a value of two}
Wcl := ValueWhen(1, EoW>0, If(EoW=1, C, Ref(C,-1)));
{weeks CLOSE - if end of week was Friday then use CLOSE, if end 
of week was not Friday then use CLOSE for Thursday}
Wcl;

kut2k2

>    {Weekly Frame EMA}
> Pds:=Input("Weekly periods",3,99,34);
>   {ema periods}
> Pct:=2/(Pds+1);
>   {percentage calculation to determine how much of current CLOSE to 
add to
> previos value of ema, and how much to discard. This information is 
contained
> in the manual}
> W1:=DayOfWeek()=5;
> W2:=Alert(W1,2);
> W3:=DayOfWeek()<Ref(DayOfWeek(),-1);
> We:=If(W1,1,If(W2=0 AND W3,2,0));
> Wcl:=ValueWhen(1,We>0,If(We=1,C,Ref(C,-1)));
>   {all same as prevoius formula above}
> {Ema:=If(We>0,PREV + Wcl*Pct,PREV);} {per MS manual}
>   {I think this line is faulty - ignore it anyway}
> Ema:=If(We>0,If(Cum(We>0)=1,C,PREV)*(1-Pct) +Wcl*Pct,PREV); 
{modified}
>   {each end of week this var will be updated with the appropriate 
percentage
> of the weekly CLOSE. There is also a "seeding" piece of code to 
start the
> var off with the CLOSE at the end if the first week. See my earlier 
post
> about moving averages to get the equivalent daily EMA variables.}
> Ema;  {output}
> 
> The reason for assigning a value of either one or two to the end of 
week bar
> is so that I know whether it was a regular Friday end of week or a 
missing
> Friday end of week. For the missing Friday event I don't know about 
it until
> the following bar, and then I need to back up one bar to get the 
correct
> CLOSE (in the 'Wcl' variable).
> 
> Roy


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/Lj3uPC/Me7FAA/CNxFAA/zMEolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxx

 

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