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

[EquisMetaStock Group] Re: Trailing stop



PureBytes Links

Trading Reference Links

===================================
Trailing Stop - ATR Chandelier Exit
===================================

---8<---------------------------

{ Trailing Stop - ATR Chandelier Exit v2.0 }
{ Triggers: Long (+1) & Short (-1) signals
 at crossover of user-defined trailing stops }
{ ©Copyright 2003 Jose Silva }
{ http://users.bigpond.com/prominex/pegasus.htm }

pds:=Input("ATR periods",1,252,10);
pds1:=Input("ATR lookback periods",1,252,21);
multi:=Input("ATR multiplier",0,10,2.5);
plot:=Input("plot:  trailing stop=1,  Long+Short=2,  signals=3",1,3,1)
;
adv:=Input("plot:  today's trailing stop=0,  tomorrow's stop=1",0,1,0)
;
delay:=Input("Entry and Exit signal delay",
 0,5,0);

StLong:=HHV(C-multi*ATR(pds),pds1);
StShort:=LLV(C+multi*ATR(pds),pds1);
stopLong:=If(C<PREV,StLong,Max(StLong,PREV));
stopShort:=If(C>PREV,StShort,Min(StShort,PREV));

In:=Cross(C,Ref(stopShort,-1));
Out:=Cross(Ref(stopLong,-1),C);
Init:=Cum(In+Out>-1)=1;
InInit:=Cum(In)=1;
flag:=BarsSince(Init OR In)
 < BarsSince(Init OR Out)+InInit;
signals:=Ref((InInit AND Alert(InInit=0,2)
 OR flag AND Alert(flag=0,2))
 +(flag=0 AND Alert(flag,2))*-1,-delay);
stop:=Ref(If(flag=1,stopLong,stopShort),-1+adv);

If(plot=1,stop,
 If(plot=2,Ref(stopLong,-1+adv),0));
If(plot=1,stop,
 If(plot=2,Ref(stopShort,-1+adv),signals))

---8<---------------------------

jose '-)


--- In equismetastock@xxxxxxxxxxxxxxx, "arenzo2" <arenzo2@xxxx> wrote:
> Hi,
> I would like to have a simple exit signal based for example on  
> close - ATR,  for long entry, but I would like that the formula can 
> only give higher values (without declining) until price hit the 
> value (exit signal).
> 
> Could someone please suggest I could program it ?
> 
> Many thanks
> 
> Renato



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com.  Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/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/