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

[EquisMetaStock Group] Roy, please walk through your formula with me...



PureBytes Links

Trading Reference Links

Roy,

Thanks for the formula. I must admit its quite dense to follow. Let me try 
to explain how I understand some of its components (which is what you always 
encourage forum members to do); correct me wherever I have made a mistake 
and please remember my comments below only reflect my understanding (or lack 
thereof) of MS formula language and are not intended to criticize your work 
in any way:

1) G:=LastValue(Highest(Sum(DayOfWeek()=F,5))=5);
I guess G is looking for a situation where the Sum of the condition "Day of 
Week=Friday" over a 5 bar period =5. This, of course, is only possible on a 
weekly chart, not on a daily chart. When I plot G, its not surprising then 
that G returns a value of 1 on weekly charts and 0 on daily charts. You are 
using it, I guess, to exclude a weekly periodicity on the charts? Am I 
right?

2) I:=Abs(I-ValueWhen(2-G,1,I));

Lets look at the ValueWhen function contained in the formula above. The 
syntax for ValueWhen is: valuewhen( Nth, EXPRESSION, DATA ARRAY ). Since G=0 
on daily charts, I could rewrite the fml abv as: I:=Abs(I-ValueWhen(2,1,I)) 
i.e. the 2nd most recent occurrence of Expression. But the expression 1 is a 
constant and its value is always 1. So you are really looking for the 2nd 
most recent occurrence of "I" (the # of calendar weeks). So if a 2-bar 
period straddles a weekend, the 2nd most recent value will be 1 less than 
the most recent value; in other words, on the first day of the week, the 
difference between the current value of I (as of the last bar - 1st day of 
week) and its value of 2 bars ago (which will be on the last day of previous 
week) will be 1. Which is exactly what I see when I plot "I" on a chart; it 
blips up to 1 on the 1st day of the week, then falls back to 0 on the 2nd 
day of the week and stays there till the 1st day of next week. Hmm, I seem 
to have grasped that, except that I don't understand the use of G or the Abs 
functions as G is always 0 on a daily chart and the value of "I" as of 2 
bars ago can never be > its most recent value, the Abs seems redundant. Am I 
missing something here?

3)  M:=G OR I>0;
Lets rephrase it: M:=G=1 OR I>0. Since G=0 on daily charts, you are saying 
M:=I>0. Since I>0 only on the first day of a week, the value M is 1 on the 
1st day of the week and 0 at other times. So it essentially parallels the 
value of "I" which is what I see when M is plotted on a chart. I guess I can 
think of it as M=Monday. Am I right?

4) F:=G OR (DayOfWeek()=F AND I=0). Rephrased to: F:=G=1 OR (DayOfWeek()=F 
AND I=0). Since G=0 on daily charts, lets rephrase it to: F:=DayOfWeek()=F 
AND I=0. Since both conditions are true on the last day of the week (lets 
say Friday) on daily charts, you are saying F=Friday. Of course, when Friday 
is a holiday, then it will remain 0 till it gets to the next Friday. Am I 
right?

5) A:=LastValue(Cum(1)-1)=Cum(1). This condition is only true on the 2nd 
last bar i.e. last bar minus 1 bar. So you are looking for "yesterday". 
Also, A will always be true if there are atleast 2 bars loaded in a chart 
i.e. if 2 or more bars loaded, A=1.

6) B:=LastValue(Cum(1))=Cum(1). This is obviously only true for the last bar 
and will always be true for the last bar. So you are looking for "today". 
Also, B will always be true i.e. B=1 always since you cannot have a chart 
with <1 bar of data!

7) J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
Well, I am quite lost here. Can you explain what you are looking for here?

I spent about 4 hours on your code and have reached only this far. Please 
advise if I misunderstood some things along the way. I will tackle the rest 
of the code once I get your reply. Thanks in advance.

JD

================================================

From: "Roy Larsen" <rlarsen@xxxxxxxxxxxxxx>
Reply-To: equismetastock@xxxxxxxxxxxxxxx
To: <equismetastock@xxxxxxxxxxxxxxx>
Subject: Re: [SPAM] [EquisMetaStock Group] Weekly pivots on daily charts
Date: Sat, 7 Aug 2004 17:40:41 +1200

JD

 > Hi, all. I want to plot weekly pivot points on daily charts [a pivot high 
is
 > a high surrounded by lower highs on either side and a pivot low is a low
 > surrounded by higher lows on either side]. I want to start by plotting 
3week
 > high/low pivots on daily charts [a 3wk high pivot would be when a stock
 > makes a 3week high and the previous as well as next week's highs are 
lower;
 > opposite for a 3week low pivot]. Can anyone help? Thanks in advance.
 >
 > JD

These formulas would be a good starting place. You can't identify the peaks 
and troughs as they
happen but you can locate them after the fact and read off the high or low 
values.  Change anything
after the third 'J' variable to fit your needs. Notice that I'm not saying 
this already does what
you want, just that the structure is there for you to work with to create 
what you want.

Roy

   {Weekly Fractal Up}
   {2004 Roy Larsen, rlarsen@xxxxxxxxxxxxxx}
   {for use on daily charts with Jose Silva's "Calendar Week counter"}
F:=Input("End of Week,  5=Friday  6=Saturday  7=Sunday",5,7,5);
Q:=Input("Display Mode,  0=Static  1=Dynamic  2=Test",0,2,0);
   {0=Display, update on Friday when possible}
   {1=Display, update on each new bar}
   {2=Backtest, update on first bar of new week}
G:=LastValue(Highest(Sum(DayOfWeek()=F,5))=5);
I:=Fml("Calendar Week counter");
I:=Abs(I-ValueWhen(2-G,1,I)); M:=G OR I>0;
F:=G OR (DayOfWeek()=F AND I=0);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=LastValue(Cum(1))=Cum(1);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
H0:=HighestSince(1,M,H);
H0:=ValueWhen(1,J,If(J=1,H0,ValueWhen(2-G,1,H0)));
H1:=ValueWhen(2,J,H0);
H2:=ValueWhen(3,J,H0);
H3:=ValueWhen(4,J,H0);
H4:=ValueWhen(5,J,H0);
Single:=H2>H4 AND H2>H3 AND H2>H1;
ValueWhen(1,Single,H2);


   {Weekly Fractal Down}
   {2004 Roy Larsen, rlarsen@xxxxxxxxxxxxxx}
   {for use on daily charts with Jose Silva's "Calendar Week counter"}
F:=Input("End of Week,  5=Friday  6=Saturday  7=Sunday",5,7,5);
Q:=Input("Display Mode,  0=Static  1=Dynamic  2=Test",0,2,2);
   {0=Display, update on Friday when possible}
   {1=Display, update on each new bar}
   {2=Backtest, update on first bar of new week}
G:=LastValue(Highest(Sum(DayOfWeek()=F,5))=5);
I:=Fml("Calendar Week counter");
I:=Abs(I-ValueWhen(2-G,1,I)); M:=G OR I>0;
F:=G OR (DayOfWeek()=F AND I=0);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=LastValue(Cum(1))=Cum(1);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
L0:=LowestSince(1,M,L);
L0:=ValueWhen(1,J,If(J=1,L0,ValueWhen(2-G,1,L0)));
L1:=ValueWhen(2,J,L0);
L2:=ValueWhen(3,J,L0);
L3:=ValueWhen(4,J,L0);
L4:=ValueWhen(5,J,L0);
Single:=L2<L4 AND L2<L3 AND L2<L1;
ValueWhen(1,Single,L2);






Yahoo! Groups Links




_________________________________________________________________
Get ready for school! Find articles, homework help and more in the Back to 
School Guide! http://special.msn.com/network/04backtoschool.armx



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/BefplB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

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

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

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