PureBytes Links
Trading Reference Links
|
Thanks Andrew, you've explained it better than I could. :)
The new binary/signals code will plot the first defined entry/exit
signal, independent of which comes first.
jose '-)
http://www.metastocktools.com
--- In Metastockusers@xxxxxxxxxxxxxxx, "Andrew Tomlinson"
<andrew_tomlinson@xxxx> wrote:
> Got it now. It became much clearer to me when I used unrelated spike
> signals for a long-only test, like
>
> entry:=Cross(C,Mov(C,21,E));
> exit:=Cross(15,Stoch(3,3));
>
> Then all the plots are identical except the initial bars. Your new
> formulation keys off the fact that
>
> x:=ValueWhen(1,entry-exit<>0,entry-exit);
> long:=x=1
> AND (Alert(x<>1,2) OR Cum(IsDefined(x))=1);
> short:=x=-1
> AND (Alert(x<>-1,2) OR Cum(IsDefined(x))=1);
>
> means you don't care whether its an entry or an exit signal (or
> isdefined) that comes first.
>
> Thanks Jose, this is very useful.
>
> Andrew
>
>
>
> -----Original Message-----
> From: Andrew Tomlinson [mailto:andrew_tomlinson@x...]
> Sent: Saturday, February 12, 2005 3:57 PM
> To: Metastockusers@xxxxxxxxxxxxxxx
> Subject: RE: [Metastockusers] Re: A better trade binary
>
>
>
>
> Thanks Jose.
>
> The formula is a crossover system that reverses from long to short
> when the close crosses the band whose limits are defined by the 21
> and 10 day EMAs, and vice versa. The formulation
>
> entry:=C>Mov(C,10,E);
> exit:=C<Mov(C,21,E);
>
> is non-intuitive to me, since by itself it creates whipsaws.
> My instinctive reaction was to do what I would do for my own code,
> which was to move it around to create something that was clearer to
> my skill level. However, as a result I changed a formulation where
> entry and exit were independent variables to one where they were
> dependent, inadvertently side-stepping half the point of your
> example (I imagine the ability to avoid repeated signals of
> unrelated entries and exits is connected to the property you pointed
> out, of capturing the first exit, which is why the "signal" readout
> from the two formulas looks so different).
>
> I have to spend some more time on this tomorrow. Bear with us.
>
> Andrew
>
> -----Original Message-----
> From: Jose [mailto:josesilva22@x...]
> Sent: Saturday, February 12, 2005 3:18 PM
> To: Metastockusers@xxxxxxxxxxxxxxx
> Subject: [Metastockusers] Re: A better trade binary
>
>
>
>
> Andrew, for all practical purposes, your amended entry/exit signals
> are almost identical to:
>
> entry:=C>Mov(C,10,E);
> exit:=C<Mov(C,21,E);
>
> This makes it very unlikely that an exit signal will appear before
> an entry, so the trade binaries for your system example will be
> identical.
>
> The answer to your question is then "yes", your particular example
> precludes any differences in the trade binary or flag output.
>
> However, try "signals" instead of "flag" for the last line of code,
> and the missing first trade signal will then become apparent.
>
>
> jose '-)
>
>
>
> --- In Metastockusers@xxxxxxxxxxxxxxx, "Andrew Tomlinson"
> <andrew_tomlinson@xxxx> wrote:
> I'm missing something. I can get the same results as the trade
> binary signals in the "new" formulation, while still using
> barssince, by a small change in the entry/exit inputs to the second
> formula, as follows:
>
> -------------------------------------------
> entry:=C>Mov(C,21,E) AND C>Mov(C,10,E);
> exit:=C<Mov(C,10,E) AND C<Mov(C,21,E);
>
> Init:=Cum(entry+exit>-1)=1;
> entryInit:=Cum(entry)=1;
> flag:=BarsSince(Init OR entry)
> <BarsSince(Init OR exit)+entryInit;
> signals:=(entryInit AND Alert(entryInit=0,2)
> OR flag AND Alert(flag=0,2))
> -(flag=0 AND Alert(flag,2));
> flag;
> -------------------------------------------
>
> Is this just a product of this particular example?
>
> Andrew
>
>
>
> -----Original Message-----
> From: Jose [mailto:josesilva22@x...]
> Sent: Friday, February 11, 2005 10:04 AM
> To: Metastockusers@xxxxxxxxxxxxxxx
> Subject: [Metastockusers] A better trade binary
>
>
> I recently stumbled on an improvement to the basic trade binary
> code, which allows the use of ValueWhen() instead of BarsSince()
> MetaStock functions.
>
> Avoiding the BarsSince() function means that the indicator code now
> does not need to wait for the first entry signal before plotting an
> exit signal. This is best illustrated by plotting and comparing the
> two trade signal indicators below.
>
>
> MetaStock -> Tools -> Indicator Builder -> New ->
> Copy and paste complete formulae between "---8<---" lines.
>
>
> ====================
> System trade signals
> ====================
> ---8<--------------------------
>
> { System trade signals - note: simultaneous
> Long/Short signals cancel each other }
> { http://www.metastocktools.com }
>
> { Signals reference example }
> entry:=C>Mov(C,21,E);
> exit:=C<Mov(C,10,E);
>
> { User inputs }
> plot:=Input("Signals: [1]Clean, [2]All, [3]Trade binary",1,3,1);
> delay:=Input("Entry and Exit delay",-1,5,0);
>
> { Clean signals }
> x:=ValueWhen(1,entry-exit<>0,entry-exit);
> long:=x=1
> AND (Alert(x<>1,2) OR Cum(IsDefined(x))=1);
> short:=x=-1
> AND (Alert(x<>-1,2) OR Cum(IsDefined(x))=1); signals:=long-short;
> binary:=ValueWhen(1,signals<>0,signals);
>
> { Plot in own window }
> Ref(If(plot=1,signals,
> If(plot=2,entry-exit,binary)),-delay)
>
> ---8<--------------------------
>
>
> ===============================
> System trade signals - original ===============================
> ---8<--------------------------
>
> { Original trade signals code }
> { BarsSince() function prevents first exit plot}
> { With thanks to Roy Larsen at
> http://www.metastocktips.co.nz }
>
> { Signals reference example }
> entry:=C>Mov(C,21,E);
> exit:=C<Mov(C,10,E);
>
> { User inputs }
> plot:=Input("Signals: [1]Clean, [2]All, [3]Trade binary",1,3,1);
> delay:=Input("Entry and Exit delay",-1,5,0);
>
> { Clean signals }
> Init:=Cum(entry+exit>-1)=1;
> entryInit:=Cum(entry)=1;
> flag:=BarsSince(Init OR entry)
> <BarsSince(Init OR exit)+entryInit;
> signals:=(entryInit AND Alert(entryInit=0,2)
> OR flag AND Alert(flag=0,2))
> -(flag=0 AND Alert(flag,2)); binary:=ValueWhen(1,signals<>0,
> signals);
>
> { Plot in own window }
> Ref(If(plot=1,signals,
> If(plot=2,entry-exit,binary)),-delay)
>
> ---8<--------------------------
>
>
> jose '-)
> http://www.metastocktools.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/zMEolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Metastockusers/
<*> To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|