PureBytes Links
Trading Reference Links
|
Sometimes it becomes necessary to detect the trailing edge of a binary
signal. The Peak() & related hindsight functions can be very useful
in signaling these trailing edge signals.
==============
Binary signals
==============
---8<-------------------
{ Leading/Trailing/Binary signals }
{ ©Copyright 2005 Jose Silva }
{ For personal use only }
{ http://www.metastocktools.com }
{ Signals reference example }
{ Note: simultaneous Long/Short signals cancel
each other }
entry:=C>Mov(C,21,E);
exit:=C<Mov(C,10,E);
{ User inputs }
plot:=Input("[1]Leading, [2]Trailing, [3]Binary, [4]BinaryX",1,4,4)
;
{ Leading signals }
x:=ValueWhen(1,entry-exit<>0,entry-exit);
Init:=Cum(IsDefined(x))=1;
lead:=x=1 AND (Alert(x<>1,2) OR Init);
{ Trade Binary }
short:=x=-1 AND (Alert(x<>-1,2) OR Init);
signals:=lead-short;
binary:=ValueWhen(1,signals<>0,signals);
{ Trailing signals }
trail:=PeakBars(1,binary,1)=0
OR Cum(1)=LastValue(Cum(1)) AND binary;
{ Binary with leading/trailing markers }
binaryX:=binary+lead*.2+trail*.2;
{ Plot in own window }
If(plot=1,lead,If(plot=2,trail,
If(plot=3,binary,binaryX)))
---8<-------------------
Another example of binary trailing edge detection:
The MS indicator code below signals correct 1st & last trading days of
the month.
========================
Month's true start & end
========================
---8<---------------------------
{ Signals true start & end of month:
confirms signal at start of following month,
and signals last day of month in retrospect.}
{ Plot only on daily & intraday charts }
{ http://www.metastocktools.com }
{ Start of month }
nuMonth:=Month()<>Ref(Month(),-1);
{ End of month }
endMonth:=PeakBars(1,-nuMonth,1)=0
OR nuMonth=0 AND Cum(1)=LastValue(Cum(1));
{ Plot in own window }
nuMonth;-endMonth
---8<---------------------------
jose '-)
http://www.metastocktools.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/BefplB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/equismetastock/
<*> 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/
|