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

Re: [EquisMetaStock Group] flag signal



PureBytes Links

Trading Reference Links

Thanks Roy - I find the MS ValueWhen() function for latch-type code 
better suited than the BarsSince() function.

Furthermore, the signal flag can be coded to react to signals in 
different ways.

For example, simultaneous entry/exit signals on the same bar can be 
allowed to cancel each other.  Or preference can be given to a new 
entry if currently Short, new exit if currently Long.


====================
System trade signals
====================
---8<--------------------------

{ System trade signals v2.5 }
{ ©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,
2);
delay:=Input("Entry and Exit delay",-1,5,0);

{ Initialize }
Init:=Cum(IsDefined(entry+exit))=1;

{ #1 - Ignore entry/exit on same bar }
bin1:=ValueWhen(1,entry-exit<>0 OR Init,
 entry-exit);
long:=bin1=1 AND (Alert(bin1<>1,2) OR Init);
short:=bin1=-1 AND (Alert(bin1<>-1,2) OR Init);
signals1:=long-short;

{ #2 - Preference to first entry/exit }
long:=entry AND (Alert(entry=0,2) OR Init);
short:=exit AND (Alert(exit=0,2) OR Init);
bin2:=ValueWhen(1,long-short<>0 OR Init,
 long-short);
long:=bin2=1 AND (Alert(bin2<1,2) OR Init);
short:=bin2=-1 AND (Alert(bin2>-1,2) OR Init);
signals2:=long-short;

{ Select #1 or #2 }
binary:=If(choose=1,bin1,bin2);
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



--- In equismetastock@xxxxxxxxxxxxxxx, "Roy Larsen" <rlarsen@xxxx> 
wrote:
> Hi Jose
> 
> The simplicity of using ValueWhen() as a latch has just hit me.
> Brilliant.
> 
> Adding an "initialisation" signal should help eliminate the annoying 
> N/A, though in this case an N/A result would be as good as a zero
> result that no signal had been seen.
> 
> ---8<------------------
> {+1 = Long,  -1 = Short, 0 = no signal yet}
> x:=FmlVar("Trailing Stop - ATR Chandelier Exit", "SIGNALS");
> i:=Cum(x>-1)=1;
> ValueWhen(1,i OR x<>0,x)
> ---8<------------------
> 
> 
> Regards
> 
> Roy
> 
>
> Column C (Hold):
> 
> ---8<------------------
> {+1 = Long,  -1 = Short}
> x:=FmlVar("Trailing Stop - ATR Chandelier Exit", "SIGNALS");
> ValueWhen(1,x<>0,x)
> ---8<------------------
> 
> 
> jose
> http://www.metastocktools.com
> 
> 
> 
> --- In equismetastock@xxxxxxxxxxxxxxx, "Robert Jolley" <rjolley@xxxx
> wrote:
> In the Exploration Editor:
> 
> 
> If 
> 
> Column A (Buy) has:
> 
> FmlVar("Trailing Stop - ATR Chandelier Exit", "SIGNALS") =1
>  
> 
> Column B (Sell) has:
> 
> FmlVar("Trailing Stop - ATR Chandelier Exit", "SIGNALS") =-1
> 
> 
> Then
> 
> How can I code Column C (Hold) to look back and determine if the
> last signal was a Buy (1) or a Sell (0)?
> 
>  
> 
> Robert Jolley
> 
> The Smart Retirement <http://www.smartretirementinvestor.com/>  
> Investor






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/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/