[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=436291422-03122003>Philip,
<SPAN 
class=436291422-03122003> 
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.
<SPAN 
class=436291422-03122003> 
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:
<SPAN 
class=436291422-03122003> 
<FONT 
face="Times New Roman">    Trend:= Mov(C, 
55, E) > Ref(Mov(C, 55, E), -1);    Trigger:= Cross(Mov(C, 
8, E), Mov(C, 13, E));
 
<FONT 
face="Times New Roman">    Test:= If(PREV 
= 0,    If(Trend, 1, 0),    If(Trigger, 
2,     If(Trend + Trigger = 0, 0, 
PREV)));
 
<FONT 
face="Times New Roman">    Signal:= 
Cross(Test, 1.5);
 
<FONT 
face="Times New Roman">    
Signal
<SPAN 
class=436291422-03122003> 
<SPAN 
class=436291422-03122003>Good trading,
<SPAN 
class=436291422-03122003>Mike
<SPAN 
class=436291422-03122003> 
<SPAN 
class=436291422-03122003> 



  
  <FONT 
  face=Tahoma size=2>-----Original Message-----From: Mike Sloane 
  [mailto:mfsloane@xxxxxxxxxxxxxx] Sent: Thursday, 4 December 2003 
  7:31 AMTo: Metastockusers@xxxxxxxxxxxxxxxSubject: RE: 
  [Metastockusers] Writing code for "the first time an event 
  happens"
  <SPAN 
  class=079431920-03122003>Philip,
  <SPAN 
  class=079431920-03122003> 
  Try the 
  following:
  <SPAN 
  class=079431920-03122003> <FONT face=Arial 
  size=2>
  <FONT 
  face="Times New Roman"><SPAN 
  class=079431920-03122003>    Trend:= Mov(C, 55, E) > 
  Ref(Mov(C, 55, E), -1);
  <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






Yahoo! Groups Sponsor












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.