gsandral
15th September 2005, 03:20 PM
Dear Jose
Thanks for your last reply to my double exit question. It works very well in some systems. This time around I would like to test a time based exit with a twist.
It goes Something like this....
If bars since entry is >= 24 then exit when %R > 90, otherwise exit when bars >= 32.
any coding suggestions :)
Regards Graeme
Jose
16th September 2005, 06:24 AM
Graeme, entry-related exits are always a pain to code in Metastock, since the exit then affects the next entry.
Take a look at this entry-related timed exit indicator - maybe you can modify it for your own needs.
========================
Entry-related timed exit
========================
---8<--------------------------
{ Long entry-related timed exit }
{ ©Copyright 2004~2005 Jose Silva
For personal use only.
http://www.metastocktools.com }
{ User inputs }
exitPds:=Input("Exit trade at x periods",
1,2600,10);
delay:=Input("Entry and Exit delay",0,5,0);
{ Sample entry conditions }
In:=Cross(C,Mov(C,21,E));
{ Entry-related exit latch }
latch:=If(PREV>0,
If(BarsSince(PREV<=0)<exitPds,1,-1),In);
{ Clean Entry & Exit signals }
entry:=latch=1 AND Alert(latch<1,2);
exit:=latch=-1;
{ Plot signals in own window }
0;Ref(entry-exit,-delay)
---8<--------------------------
jose '-)
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.