[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

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



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/Lj3uPC/Me7FAA/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/