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

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



PureBytes Links

Trading Reference Links




<SPAN 
class=079431920-03122003>Philip,
<SPAN 
class=079431920-03122003> 
Try the 
following:
<SPAN 
class=079431920-03122003> <SPAN 
class=079431920-03122003>
<FONT 
face="Times New Roman"><SPAN 
class=079431920-03122003>    Trend:= Mov(C, 55, E) > 
Ref(Mov(C, 55, E), -1);<?xml:namespace prefix = o ns = 
"urn:schemas-microsoft-com:office:office" />
<FONT 
face="Times New Roman"><SPAN 
class=079431920-03122003>    Trigger:= Mov(C, 8, E) > 
Mov(C, 13, E);
<FONT face="Times New Roman" 
size=3> 
<FONT 
face="Times New Roman"><SPAN 
class=079431920-03122003>    Test:= If(PREV = 
0,
<FONT 
face="Times New Roman"><SPAN 
class=079431920-03122003>    If(Trend, 1, 
0),
<FONT 
face="Times New Roman"><SPAN 
class=079431920-03122003>    If(Trigger, 2, 

<FONT 
face="Times New Roman"><SPAN 
class=079431920-03122003>    If(Trend + Trigger = 0, 0, 
PREV)));
<FONT face="Times New Roman" 
size=3> 
<FONT 
face="Times New Roman"><SPAN 
class=079431920-03122003>    Signal:= Cross(Test, 
1.5);
<FONT face="Times New Roman" 
size=3> 
<SPAN 
><SPAN 
class=079431920-03122003>    Signal
<SPAN 
> 
<SPAN 
>
The signal plot 
should spike up for one bar every time you get your first cross-over after the 
trend has been established; it will not reset until both the 55 EMA has turned 
down and the 8 EMA has crossed below the 13 EMA again; you can also create the 
separate indicators called Trend, Trigger, Test and Spike and drop them into 
separate windows below your price plot and observe the interaction between 
them.
<SPAN 
class=079431920-03122003> 
If you are also a 
member of the EquisMetaStock Yahoo group you should check out the files section 
and download "Using latches in MS.doc" posted there by Roy Larsen; this 
will give you a very detailed explanation of the structure and operation of 
latched indicators like the one above.
<SPAN 
class=079431920-03122003> 
Good 
trading.
<SPAN 
class=079431920-03122003> 
<SPAN 
class=079431920-03122003>Mike
 



  
  <FONT 
  face=Tahoma size=2>-----Original Message-----From: Philip 
  [mailto:pschmi02@xxxxxxxxxxx] Sent: Thursday, 4 December 2003 6:21 
  AMTo: Metastockusers@xxxxxxxxxxxxxxxSubject: RE: 
  [Metastockusers] Writing code for "the first time an event 
  happens"Thank you, the list of important functions is 
  very helpful. I'll go over it carefully. Meanwhile, I could be mistaken, 
  but I don't think that the ALERT function is the one I need.My 
  understanding is that ALERT would tell me that EventA took place during 
  the lookback period. Example:ALERT(EventA, 5) --> sometime 
  during/within the last 5 periods EventA did in fact take 
  place.This stuff can be tricky. It's never as clear to the other guy 
  as it is to oneself. So let me try to clarify. I'm trying to write 
  this:Sometime in the past condition1 began (say, the EMA(55) started 
  to decline).Condition1 continues to be true on the current bar. 
  EMA(55) is still declining today.During the period where 
  condition1 has been true -- in others words from the first bar where the 
  EMA(55) started to decline -- to the bar immediately preceeding the 
  present bar, EventA did not take place. Today, however, while condition1 
  continues to be true, while the EMA(55) continues to decline, EventA HAS 
  finally taken place. So this is the first time, the first bar, since the 
  bar on which the EMA(55) began to decline that EventA has occurred. Ever 
  since EMA(55) has been declining (from the first bar on) EventA  
  (say, cross(EMA(8), EMA(13)) has not taken place -- UNTIL TODAY, that is, 
  until the present bar. And today (cross(EMA(8), EMA(13).Since 
  everybody loves a bull market, let me use a further example. For stock XYZ 
  the EMA(55) began to rise in the first week of June, 2003. It's still 
  rising on December 3, 2003 (that's some run, huh?). But I'm not interested 
  any more in identifying occurrences of EventA at this stage of XYZ's 
  stellar performance. I see now, with 20-20 hindsight, that the time to 
  identify EventA would have been the very first time it occurred after the 
  EMA(55) had begun to rise. Perhaps that was sometime in early July, or 
  sometime in August. It doesn't matter. Just so long as it's the first time 
  EventA occurred since XYZ starting moving up according to whatever trend 
  definition I'm using, in this case that's a rising EMA(55).So 
  tonight, based on my experience with XYZ, I'm going to sit down and 
  explore for stocks/futures where EventA has taken place today for the 
  first time since my trend definition began to be true -- which could have 
  been the day after Labor Day, or Halloween or Thanskgiving.There, 
  have I succeeded in confusing matters beyond repair?  :-)Again, 
  your list of functions brings me a step further. I'd never boiled it down 
  that way, and there a couple of functions I definitely need to look 
  into.Thanks,PhilipTo 
  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.