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

Re: [EquisMetaStock Group] Referencing the most recent occurrence



PureBytes Links

Trading Reference Links

Hi Tim

OK, ValueWhen() may not be the best way to go with a dual long and short
latch. The problem there is that you may not have a "latch=0" point to
reference the ValueWhen() to. Also, you have already negated the advantage
of using ValueWhen() (1 less PREV) because of the need for PREV at the end
of the latch.

What I suggest you do is use the latch value as the entry price, or whatever
value you wish to remember, instead of using values of plus and minus one.
Still use negative for short.

The value to be stored in the latch must be available when the entry signal
received

N:="entry binary"*"entry price";

One problem to look out for when using PREV to make decisions inside the
latch is that this really does refer to the PREVIOUS bar value, not the
current bar value even though it's used as a defacto current bar value. This
can make for difficulties, particularly with a tri-state latch.

I think you could also incorporate your entry based ATR stops inside just
the one latch. This would allow you to keep all signals in sync, and
probably keep the total PREV count lower than when using several latches.

Roy



----- Original Message ----- 
From: "timinwaedi" <timinwaedi@xxxxxxxxxxx>
To: <equismetastock@xxxxxxxxxxxxxxx>
Sent: Thursday, May 22, 2003 4:36 AM
Subject: Re: [EquisMetaStock Group] Referencing the most recent occurrence


> --- In equismetastock@xxxxxxxxxxxxxxx, "Roy Larsen" <rlarsen@xxxx>
> wrote:
> > Tim
> >
> > > Can anyone suggest how I can reference the price at which a the
> most
> > > recent occurrence of a long entry took place. I need to know this
> > > price in order to define a stop loss or stop profit exit.
> >
> > Here's some more "latch" practice.
> >
> > There are many ways you can configure this latch. By not storing
> the entry
> > price in the latch but referencing it using ValueWhen(entry) we
> eliminate
> > one PREV.
> >
> > Have fun.
> >
> > Roy
> >
> >   {Trade Stop Tim}
> > N:=Fml("long entry signal (price spike)");
> > X:=Fml("nominal exit");
> > I:=Cum(N+X>-1)=1;
> > Tr:=If(PREV<=0,N>0,If( X {standard exit}
> >   OR {10% profit stop}
> >   ValueWhen(1,PREV=0, N {entry price} )>=C*1.1,
> >   {OR any other entry related exit}
> >   -1 {negative spike exit signal},
> >   1)); {or trade continues}
> > Xb:=Tr<0; {exit bar}
> > Tr:=Abs(Tr)*ValueWhen(1,I OR (Alert(Tr=0,2)
> > AND Tr),N); {trade acitive * entry price}
> > Tr;
>
> Thanks Roy,
>
> I've included an expert which functions ok, and I wanted to
> add to the long and short exit conditions a percentage profit
> target.I've added pseudo code to the exit conditions which I trust
> will explain my plight.
>
> ------------------------------
> {Enter on correction in trend with ATR stop or 10% profit target}
>
> {Long Entry}
>
> LE:=C <= Ref(C,-1) AND
> Ref(C, -1) <= Ref(C, -2) AND
> Ref(C, -2) <= Ref(C, -3) AND
> Mov(C, 21, E) > Ref(Mov(C, 21, E), -1)
> OR
> C <= Ref(C,-1) AND
> Ref(C, -1) <= Ref(C, -2) AND
> Ref(C, -2) <= Ref(C, -3) AND
> Ref(C, -3) <= Ref(C, -4) AND
> Mov(C, 21, E) > Ref(Mov(C, 21, E), -1);
>
> {Short Entry}
>
> SE:=C >= Ref(C,-1) AND
> Ref(C, -1) >= Ref(C, -2) AND
> Ref(C, -2) >= Ref(C, -3) AND
> Mov(C, 21, E) < Ref(Mov(C, 21, E), -1)
> OR
> C >= Ref(C,-1) AND
> Ref(C, -1) >= Ref(C, -2) AND
> Ref(C, -2) >= Ref(C, -3) AND
> Ref(C, -3) >= Ref(C, -4) AND
> Mov(C, 21, E) < Ref(Mov(C, 21, E), -1);
>
> {Long Exit}
>
> LongNumatr:=4;
> LongPeriods:=4;
> LongSL:=L-LongNumatr*ATR(LongPeriods);
> Longstop:=If(L<PREV,LongSL,If(LongSL>PREV,LongSL,PREV));
> LX:=L<Ref(Longstop,-1){or high >= Long entry price * 1.1};
>
> {Short Exit}
>
> ShortNumatr:=4;
> ShortPeriods:=4;
> ShortSL:=H+ShortNumatr*ATR(ShortPeriods);
> Shortstop:=If(H>PREV,ShortSL,If(ShortSL<PREV,ShortSL,PREV));
> SX:=H>Ref(Shortstop,-1){or low<= Short entry price /1.1};
>
> Trade:=If( LE=1, 1, If(SE=1, -1, If((LX AND PREV=1) OR (SX AND
> PREV=-1),0,PREV)));
>
> Long Entry: cross( trade, 0.5 )
> Short Entry: cross( -0.5, trade )
> Long Exit: cross( 0.5, trade )
> Short Exit: cross( trade, -0.5 )
>
> -----------------------------------------------------
>
> I understand that the use of the ValueWhen function can be used to
> store values of most recent occurrences, but am not sure how to
> integrate it. Would be grateful for your remarks.
>
> Regards,
>
> Tim
>
>
>
>
> To unsubscribe from this group, send an email to:
> equismetastock-unsubscribe@xxxxxxxxxxxxxxx
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading!
Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/aM1XQD/od7FAA/uetFAA/BefplB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/