[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Metastockusers] Binary leading & trailing edges



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