Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Try this indicator code:
[code:1:ae0d470eee]
============================
Exit-related timed new entry
============================
---8<----------------------------------------
{ Ignores new entry signals with x periods of
last exit.
©Copyright 2004~2006 Jose Silva
For personal use only.
http://www.metastocktools.com }
{ User inputs }
pds:=Input("Ignore new entry signals within x periods of exit",0,260,21);
plot:=Input("Signals: [1]Clean, [2]Original, [3]NoTrade flag",1,3,1);
{ Entry/Exit example conditions - do not trade!}
entry:=C>Mov(C,21,S);
exit:=C<Mov(C,10,S);
{ Original trade flag and exit }
init:=Cum(IsDefined(entry+exit))=1;
flag:=ValueWhen(1,entry-exit<>0 OR init,entry);
truExit:=(flag=0)*(Alert(flag,2)
OR exit*Cum(exit)=1);
{ Exit-related no-trade flag }
noTrade:=If(PREV>0,
If(BarsSince(PREV<=0)<pds,1,-1),truExit)>0;
{ New Entry signal }
NuEntry:=entry AND noTrade<1;
{ Clean Entry/Exit signals }
bin:=ValueWhen(1,NuEntry-exit<>0
OR init,NuEntry);
long:=bin*(Alert(bin=0,2)
OR entry*Cum(entry)=1);
short:=(bin=0)*(Alert(bin,2)
OR exit*Cum(exit)=1);
signals:=long-short;
{ Plot in own window }
If(plot=2,entry,0);
If(plot=1,signals,If(plot=2,-exit,noTrade))
---8<----------------------------------------
[/code:1:ae0d470eee]
jose '-)
|