PureBytes Links
Trading Reference Links
|
Either by deliberate or (more likely) poor design, sometimes a trading
strategy can give both Long & Short signals on the same bar.
What to do then? Ignore simultaneous entry/exit signals on the same
bar, or take the latest signal?
The MetaStock indicator below allows the choice of either ignoring
conflicting entry/exit signals, or taking the latest signal.
====================
System trade signals
====================
---8<--------------------------
{ System trade signals }
{ ©Copyright 2005 Jose Silva }
{ For personal use only }
{ http://www.metastocktools.com }
{ Note on simultaneous entry/exit on same bar:
#1 Ignore:
entry/exit signals cancel each other;
#2 Preference given to:
new entry if currently Short,
new exit if currently Long.}
{ 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);
choose:=Input("Simultaneous entry/exit: [1]Ignore, [2]Preference",1,2,
1);
delay:=Input("Entry and Exit delay",-1,5,0);
{ Initialize plot }
Init:=Cum(IsDefined(entry+exit))=1;
{ #1 - Ignore entry/exit on same bar }
x:=ValueWhen(1,entry-exit<>0,entry-exit);
long:=x=1 AND (Alert(x<>1,2) OR Init);
short:=x=-1 AND (Alert(x<>-1,2) OR Init);
signals1:=long-short;
binary1:=ValueWhen(1,signals1<>0,signals1);
{ #2 - Preference to first entry/exit }
long:=entry AND (Alert(entry=0,2) OR Init);
short:=exit AND (Alert(exit=0,2) OR Init);
binary2:=ValueWhen(1,long-short<>0,long-short);
long:=binary2=1 AND (Alert(binary2<1,2) OR Init);
short:=binary2=-1 AND (Alert(binary2>-1,2) OR Init);
signals2:=long-short;
{ Select #1 or #2 }
binary:=If(choose=1,binary1,binary2);
signals:=If(choose=1,signals1,signals2);
{ Plot in own window }
Ref(If(plot=2,entry,0),-delay);
Ref(If(plot=1,signals,
If(plot=2,-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/
|