PureBytes Links
Trading Reference Links
|
Hi
Phillip,
<SPAN
class=523503520-05122003>
Your email may make
a little more sense to the group if you included the off-line communications as
well:
<SPAN
class=523503520-05122003>
See
below:
<SPAN
class=523503520-05122003>
<FONT face=Tahoma
size=2>-----Original Message-----From: Mike Sloane
[mailto:mfsloane@xxxxxxxxxxxxxx] Sent: Friday, 5 December 2003 11:47
PMTo: 'Philip'Subject: RE: [Metastockusers] Writing code
for "the first time an event happens"
Hi
Philip,
<SPAN
class=863082212-05122003>
<SPAN
class=863082212-05122003>1.0 Yes, you could replace Trend with
any variation of your definition of the trend.
<SPAN
class=863082212-05122003>2.0 Yes, you could replace Trigger
with any indicator, provided it is a binary signal (only possible values are 0
or 1)
<SPAN
class=863082212-05122003>3.0 No; in my code, Test rises to 1
when Trend is true and rises to 2 when "Trend is already true and Trigger
becomes true" (note Trigger is true for one bar only); Signal spikes when Test
rises from 1 -> 2 (i.e. Crosses 1.5).
<SPAN
class=863082212-05122003>
A couple of further
points:
<SPAN
class=863082212-05122003>
My code is an
example of a latched indicator that requires the use of the PREV function; for
some reason I tend to write a lot of my code this way. The code posted by
metarockx is a perfectly valid (and efficient) way of achieving the same result
without using the PREV function - an important factor if you have a slower
computer or many indicators that use the PREV function, as it requires
more processing time.
<SPAN
class=863082212-05122003>
However there were a
couple of small errors with ">" and "<" in the metarockx code; I
have taken the liberty of correcting it and rearranging it a
little:
<SPAN
class=863082212-05122003>
<FONT
color=#000000>Trend := Mov(C,55,E) >
Ref(Mov(C,55,E),-1);
<FONT
color=#000000>StartTrend := Trend AND
Ref(Mov(C,55,E),-1) <
Ref(Mov(C,55,E),-2);
<FONT
color=#000000>Trigger:=
Cross(Mov(C,8,E),Mov(C,13,E));
<FONT face="Times New Roman"
color=#000000 size=3>Signal:= Trend AND Trigger
<FONT face="Times New Roman"
color=#000000 size=3>AND BarsSince(Ref(Trigger,-1)) >
BarsSince(StartTrend);
<FONT face="Times New Roman"
color=#000000 size=3>
<FONT face="Times New Roman"
color=#000000 size=3>Signal
<FONT face="Times New Roman"
color=#000000 size=3>
Note
that when they are both plotted on a chart (see attached SPX - metarockx signal
is top/blue; my signal is bottom/purple), my signal requires Trend to be
established for one day before Trigger can give a signal; metarockx code will
give a signal in the case where Trend and Signal both become true on the same
day.
<SPAN
class=863082212-05122003>
It all
depends on what you wish to achieve.
<SPAN
class=863082212-05122003>
As
noted in my earlier post, when I am building an indicator like this I will often
create separate sub-indicators (Trend, Trigger, Test etc) and plot them in
separate windows on the chart, observe the interaction and make sure it is doing
exactly what I intended.
<SPAN
class=863082212-05122003>
<SPAN
class=863082212-05122003>
Good
trading,
<SPAN
class=863082212-05122003>Mike
<SPAN
class=863082212-05122003>
PS:
you may wish to post this to the group to "complete" the thread - I will leave
that up to you.
<SPAN
class=863082212-05122003>
<SPAN
class=863082212-05122003>Regards,
<SPAN
class=863082212-05122003>MS
<FONT face="Times New Roman"
color=#000000 size=3>
<FONT face="Times New Roman"
color=#000000 size=3>
<FONT
face=Tahoma size=2>-----Original Message-----From: Philip
[mailto:pschmi02@xxxxxxxxxxx] Sent: Friday, 5 December 2003 5:48
PMTo: mfsloane@xxxxxxxxxxxxxxSubject: RE:
[Metastockusers] Writing code for "the first time an event
happens"Mike,Many thanks for your help! I'll need
about a week or ten days to work with your formulas. SPECIAL thanks for
the tip about the "Using latches in MS.doc" -- that
might be just what I need.If you could spare another few
minutes, some questions have come to mind.1. Even with my limited
grasp of the syntax it seems that if I wanted to vary my trend definition, all
I would have to do is replace the statement following Trend:=, right? But what
about changing the trigger? Say my trigger is some formula I've cooked up in
the indicator builder called . . . I don't know . . . "TURN" consisting of an
oversold StoRSI or some price pattern. Would I simply substitute "TURN"
instead of Cross(Mov(C, 8, E), Mov(C, 13,
E)); following Trigger:=? And would this entail
making a change to the next to last line, the line that currently reads: <FONT
face=arial size=2>Signal:= Cross(Test, 1.5);? 2. The syntax
you''ve written could be used both as an indicator or an exploration filter,
correct?TIA,Philip
<BLOCKQUOTE class=cite cite=""
type="cite">"urn:schemas-microsoft-com:office:office"> <FONT
face=arial size=2>Philip, The
previous post from metarockx prompted me to take another look at the code I
posted earlier and I found a condition that is not in line with your
spec. As written, the signal
plot will spike if the 8 EMA is already above the 13 EMA when the 55 EMA
turns up; this can be solved by changing the Trigger condition from " > "
to a "cross" condition, as below: <FONT
face="Times New Roman, Times"> <FONT face=arial
size=2>Trend:= Mov(C, 55, E) > Ref(Mov(C, 55, E),
-1); Trigger:= Cross(Mov(C, 8, E), Mov(C, 13,
E)); Test:=
If(PREV = 0, If(Trend, 1, 0),
If(Trigger, 2, If(Trend + Trigger = 0, 0,
PREV)));
Signal:= Cross(Test, 1.5); <FONT face=arial
size=2> Signal <FONT face=arial
size=2>Good
trading,Mike
<SPAN
class=523503520-05122003>
-----Original
Message-----From: Philip [mailto:pschmi02@xxxxxxxxxxx]
Sent: Saturday, 6 December 2003 7:31 AMTo:
Metastockusers@xxxxxxxxxxxxxxxSubject: RE: [Metastockusers] Writing
code for "the first time an event happens"
Thanks, Mike, your explanations are
great! I don't always do as good a job of communicating these things
clearly, but when I posted originally I was trying to find a way to run an
exploration for an event which has occurred for the first time. More
specifically, the first retracement in a trend, regardless of how the
trend (or the retracement) is defined.In the past, I've simply created
an indicator and then "called" it in the symbol or highlight section of an
expert. So I would have written something like:Fml(
"Trenddefinition") and Fml("Retracement") . . . and then chosen a buy
arrow or some such. When both obtain I get my signal. Wouldn't that give
me the same result as the code you and metarockx have written? But now I'm
trying to isolate that first retracement and explore for that first event
alone -- and I'm stumped.In terms of watching the way price moves,
it seems that the first retracement after a trend kicks in has a better
chance of leading to a profitable trade than later retracements. I'm still
at the "hunch" stage about this, but I'd like to investigate further. So
how do I nail (i.e. explore for) that first retracement? Say my trend
definition has been true since October 1, 2003 (or even just since
yesterday, for that matter) and today, for the first time, my retracement
definition is met. Using your .jpg as an example, I'd like to run an
exploration that would identify only such retracements as the one signal
both you and metarockx have identified early in July -- the first signal
of its kind after the trend definition has kicked in.I'm afraid I
didn't do a good job of expressing this in my initial
post.Philip To
unsubscribe from this group, send an email
to:Metastockusers-unsubscribe@xxxxxxxxxxxYour use
of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Yahoo! Groups Sponsor
ADVERTISEMENT
To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxx
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Attachment:
SPX.jpg
Attachment:
Description: "Description: JPEG image"
|