PureBytes Links
Trading Reference Links
|
Hi Roy,
Sorry for the delayed response; some urgent stuff came up. I found your
reply and the attached document extremely useful to further my
understanding. I have now tweaked the fml for my needs and am quite
satsified with it. Thanks again and keep up the excellent work.
JD
==============================================
From: "Roy Larsen" <rlarsen@xxxxxxxxxxxxxx>
Reply-To: equismetastock@xxxxxxxxxxxxxxx
To: <equismetastock@xxxxxxxxxxxxxxx>
Subject: Re: [EquisMetaStock Group] Roy, please walk through your formula
with me...
Date: Sun, 8 Aug 2004 09:54:18 +1200
Hi JD
> 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:
Some of the details of these formulas are unnecessary "fluff", but the
various elements have been
added to build in flexibility.
> 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?
Pretty close. The simple purpose of 'G' is to discriminate between daily and
weekly periodicy
charts. 'G' is zero for daily periodicy, and one for weekly periodicy. This
feature allows an
equivalent standard MetaStock indicator to be compared for accuracy directly
with my "weekly
indicator" on a weekly periodicy chart. I recommend that the weekly values
be recorded and tested
against the same "weekly indicator" plotted on a daily chart as well, as a
double check for
accuracy.
Without the 'G' variable these indicators either won't plot at all on a
weekly chart, or the values
are meaningless. You may notice that 'G' is used in a number of
ValueWhen(2-G,1,x) functions. On
daily charts this gives a delay of one bar for "x", and no delay for weekly
charts (where there is
no need to reference past data to reconstruct the current weeks data).
> 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).
The 'I' is looking for a change in the "Calendar Week counter". If the chart
is weekly then 'G'
eliminates the "delay factor" of the then unused 'I' varible. 'G' (always
true on w a seekly chart)
is used to create "Monday" signals instead.
>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?
The ABS does appear be redundant. My arithmetic is poor. When I wrote this I
wanted the result to
spike positive. Since the value of "Calendar Week counter" can be negative I
assumed that
subtracting a negative number from another negative could give a negative
result. Not so in this
case, so you are right.
> 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.
Yes, on daily charts. On weekly charts, M:=G{=TRUE}; (where every bar is a
Monday, and a Friday too
for that matter).
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?
Absolutely. It ALWAYS represents the FIRST day of the week, whether that be
a real Monday or some
other day.
> 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?
Spot on. Only a genuine Friday (or nominated end-of-week bar) can be used as
signalling the last bar
of the week. If the friday data is missing then we won't know (logically in
the formula) that the
week has ended until the nominal Monday data is available (a new week has
started).
> 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!
The 'A' and 'B' variables are only used in a very special situation. This is
when the indicator is
operating in "dynamic mode", the last bar is a nominal Monday, and the
second last bar is NOT a real
Friday. To generate the appropriate end-of-week signals for the creation of
an accurate EMA (say)
the current bar (Monday) must signal the end of week for the currrent
dynamic week. As well as that
the previous bar (probably Thursday) must also signal an end-of-week so that
data for the end of
week just ended is also included in the EMA. In all other situations the
Monday bar can be used to
look bak to the previous weeks data if there was no Friday. However, when
operating in dynamic mode
there are actually TWO weeks worth of data to be calculated on the Monday
bar after a missing
Friday - The week just completed and the week just started.
The 'A' and 'B' variables allow me to identify this rare but real situation,
and still pick up all
the relevant daily data for the weekly data array being created. It's a
one-off situation where both
Thursday and Monday must be used as the end of the last two weeks of data
respectively. If you don't
use dynamic data then this feature doesn't come into play.
> 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'm attaching a document in which I comment on the weekly RSI for daily
charts. Hopefully that will
help.
The basic concept is that J=1 when there is a legitimate (real) Friday, J=2
when the end of week is
not a real Friday but a nominal Monday (first day of the new week). Added to
this are the
considerations that the indicator can be used to ignore all Friday's
(updates on nominal Monday
only), use Fridays when available and compensate when they aren't, or update
the current week with
each new daily bar. Not forgetting, of course, that the indicator may be
used on a weekly chart
where all previous bets are off.
I think my concept is quite simple. It's the implementation of the concept
that becomes difficult.
The value of the the last 'J' variable being one or two is what defines the
boundries of each week.
> 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.
I was thinking you would take everything up to 'J' at face value and only
look at the code from
there on. Hopefully this has not been a wast of time all the same.
Regards
Roy
Yahoo! Groups Links
<< CommentedWeeklyRSI-Close.doc >>
_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to
get there! http://lifeevents.msn.com/category.aspx?cid=Retirement
------------------------ 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/
|