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

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


  • To: Metastockusers@xxxxxxxxxxxxxxx
  • Subject: RE: [Metastockusers] Writing code for "the first time an event happens"
  • From: Philip <pschmi02@xxxxxxxxxxx>
  • Date: Fri, 5 Dec 2003 12:30:10 -0800
  • In-reply-to: <6.0.1.1.0.20031205012740.01bb88d8@xxxxxxxxxxxxxxx>

PureBytes Links

Trading Reference Links

Greetings All,

Responding to a further question of mine, Mike Sloane has supplied some 
very helpful information and it should be shared with the list.

My questions follow below, then Mike's response:

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?

>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);<?xml:namespace prefix = o ns = 
>"urn:schemas-microsoft-com:office:office" />
>
>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


------------------------ 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/