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

[Metastockusers] Re: Writing code for "the first time an event happens"



PureBytes Links

Trading Reference Links

Thanks, Mike for the correction of the basic trend definition in my  
coding. That way it definitely makes more sense as a strategy.

greetings
Klaus


--- In Metastockusers@xxxxxxxxxxxxxxx, "Mike Sloane" <mfsloane@xxxx> 
wrote:
> Hi Phillip,
>  
> Your email may make a little more sense to the group if you 
included the
> off-line communications as well: 
>  
> See below:
>  
> -----Original Message-----
> From: Mike Sloane [mailto:mfsloane@x...] 
> Sent: Friday, 5 December 2003 11:47 PM
> To: 'Philip'
> Subject: RE: [Metastockusers] Writing code for "the first time an 
event
> happens"
> 
> 
> Hi Philip,
>  
> 1.0    Yes, you could replace Trend with any variation of your
> definition of the trend.
> 2.0    Yes, you could replace Trigger with any indicator, provided 
it is
> a binary signal (only possible values are 0 or 1)
> 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).
>  
> A couple of further points:
>  
> 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. 
>  
> 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:
>  
> Trend := Mov(C,55,E) > Ref(Mov(C,55,E),-1);
> 
> StartTrend := Trend AND Ref(Mov(C,55,E),-1) < Ref(Mov(C,55,E),-2);
> 
> Trigger:= Cross(Mov(C,8,E),Mov(C,13,E));
> 
> Signal:= Trend AND Trigger 
> 
> AND BarsSince(Ref(Trigger,-1)) > BarsSince(StartTrend);
> 
>  
> 
> Signal
> 
>  
> 
> 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.
>  
> It all depends on what you wish to achieve.
>  
> 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.
>  
>  
> Good trading,
> Mike
>  
> PS: you may wish to post this to the group to "complete" the 
thread - I
> will leave that up to you.
>  
> Regards,
> MS
> 
>  
> 
>  
> 
>  
> 
> -----Original Message-----
> From: Philip [mailto:pschmi02@x...] 
> Sent: Friday, 5 December 2003 5:48 PM
> To: mfsloane@xxxx
> Subject: 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: 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
> 
> 
> 
> "urn:schemas-microsoft-com:office:office"> 
> 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:
>  
>     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);
>  
>     Signal
>  
> Good trading,
> Mike
> 
> 
>  
> -----Original Message-----
> From: Philip [mailto:pschmi02@x...] 
> Sent: Saturday, 6 December 2003 7:31 AM
> To: Metastockusers@xxxxxxxxxxxxxxx
> Subject: 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
>    
> 
> 
> 
> Yahoo! Groups Sponsor	
> 
> ADVERTISEMENT
>  
> 
<http://rd.yahoo.com/SIG=12ch1q3jm/M=267637.4116730.5333196.1261774/D
=eg
> 
roupweb/S=1705001779:HM/EXP=1070742690/A=1853618/R=0/*http://www.netf
lix
> .com/Default?mqso=60178338&partid=4116730> click here	
>  
> <http://us.adserver.yahoo.com/l?
M=267637.4116730.5333196.1261774/D=egrou
> pmail/S=:HM/A=1853618/rand=494308586> 	
> 
> 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
> <http://docs.yahoo.com/info/terms/> .


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/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/